laravel-square
laravel-square copied to clipboard
Adds support for fulfillments
Fulfillments
This merge request seeks to add support for fulfillments and creates models that are reflective of the Square data model. Orders can have Fulfillments, which themselves have Fulfillments Details of varying types (details on the model update below). This merge request adds the following:
- Fulfillment and Fulfillment Details models and migrations
- Fulfillment and Recipient builders
- SquareRequest builder calls to support updating of fulfillment details related to orders
- Tests that cover all the individually added models as well as scenarios for creating and adding orders that contain various Fulfillment Detail types.
Square API support
This adds support via the SquareRequestBuilder
to update and modify data on square, and ensure it's synced properly with your application. Some notable assumptions are baked in here:
- Orders CANNOT have line-item fulfillment data
- This also means a single order CANNOT have multiple fulfillments. This is how the Square UI currently works, so this functionality is only available via the API. As it's currently an edge case - one that could likely be worked around by creating multiple orders, for now, this will be left out with no plans to add it in.
Model Updates
This creates a polymorphic relationship between orders via the Fulfillment model. Adding a fulfillment to an order requires both adding a Fulfillment model and a FulfillmentDetails model - which can be one of three types: DeliveryDetails
, PickupDetails
or ShipmentDetails
. These relationships are handled through the trait HasFulfillments
.
Recipient Addition
The recipients have been added as a distinct model. This distinction could be useful for adding future support for additional recipient type, for example Invoice Recipients.
Adds Order ID to Payment API request (fulfilling the requirements Square has for orders to show up on the Square Dashboard):
This PR contains a minor fix for adding in the order id to the payments API request, so the payment and order are connected within Square's System. This update exposed a few bugs that have now been addressed:
- The Tax calculations in
Util::calculateTotalOrderCost/ByModel
were not taking in to account discounts and inclusive taxes properly. This now makes sure that Additive taxes are calculated based off the Net Price (taking in to account Discounts and Inclusive Taxes). Added a private_calculateNetPrice
method to support this. - The Order Builder
buildOrderCopyFromModel
method was not properly creating taxes at the order level. AddedConstants::DEDUCTIBLE_SCOPE_ORDER
.