v1

latestOpenAPI 3.0.1Apache 2.02026-07-2473111182.6 KB
Purchase

Create a purchase

Create and return a purchase for the specified business id and branch id. Purchase can be for various items including appointments, products, courses and vouchers. <br/>One thing to note is the rounding strategy employed when applying taxes and discounts. Tax and discounts are always rounded HALF UP up to the cent. This applies to all currencies. For example: <br/>With VAT of 20% on $100 the tax is $16.6666... which is rounded to $16.67. With a sales tax of 10.5% on $1 we get $0.105 which is rounded to $0.11. 10.4% would be rounded to $0.10. <br/>For salons where the price of goods / services are inclusive of tax, you should provide the gross amount as price for each purchase item. For example: <br/>A purchase item whose net price is €100 with tax at 20%, should have its gross price of €120 specified as the item price in the request. <br/>For salons where the price of goods / services are exclusive of tax, you should provide the net amount as price for each purchase item. For example: <br/>A purchase item whose net price is $100 with tax at 20%, should have its net price of $100 specified as the item price in the request. However, the total payment amount for the sale must be the gross amount. In this example, where a single item with a net price of $100 is purchased at a 20% tax rate, the total payment amount for the sale is $120. <br/><h2>Payment</h2> <p> If the request contains a larger payment amount than is needed to cover the total cost of items being purchased, we return the difference as change. Please note that overpayment is determined based on the tax rates currently assigned in Phorest to the items being purchased, and not on the tax rates specified in the API request. <br/>If the request contains a smaller payment amount than is needed to cover the total cost of items being purchased, we reject the purchase and return an error. Please note that underpayment is determined based on the tax rates currently assigned in Phorest to the items being purchased, and not on the tax rates specified in the API request. </p> <br/><h2>Credit Account Transaction</h2> <p> A purchase of for clients credit account transaction needs outstandingBalancePayment set to true. With this request you'll also need a staffId and price. </p> <br/><h2>Voucher</h2> <p> System supports creating vouchers sales via <code>purchase</code> operation. If purchase item contains voucher data, it will be treated as a voucher purchase item. <br/> In that case, following rules will apply: <ul> <li> <code>serial</code> <br/> If voucher's serial number is not provided, system will generate it </li> <li> <code>expiry date</code> <br/> Expiry date must be in future. </li> <li> <code>quantity</code> <br/> Number of vouchers to be created depends on the <code>quantity</code> field. Example: For <code>quantity=2</code> and <code>price=1.00</code>, System will generate 2 vouchers with balance 1.00. </li> <li> <code>tax-voucher</code> <br/> On the voucher sale, tax won't be calculated so the tax field is not required. </li> </ul> </p>

post/api/business/{businessId}/branch/{branchId}/purchase

Path parameters

businessIdstring required
branchIdstring required

Request body

numberstring required

Must be unique across all purchases

clientIdstring required

The client making the purchase

Example request

{
  "number": "588b1601-cd57-40ad-b206-ddb5e5b9359l",
  "clientId": "UGiia_GpNmkR9dZQbgtLaA",
  "payments": [
    {
      "type": "CREDIT",
      "amount": 399.9,
      "customPaymentTypeId": "RCq7f3ez5JC2qxGlq434qQ"
    }
  ],
  "items": [
    {
      "description": "The course description",
      "price": 199.95,
      "courseId": "eT9l8zjGevYQonvm5tJhrg",
      "staffId": "t52lOhAWWMU-sGGDgwOk7Q",
      "outstandingBalancePayment": true,
      "quantity": 2,
      "appointmentId": "t52lOhAWWMU-sGGDgwOk7Q",
      "branchProductId": "t52lOhAWWMU-sGGDgwOk7Q",
      "taxRates": [
        {
          "taxId": "mWkA6EjdLDyTGL7APWsPxw",
          "name": "VAT 12.5% rate",
          "rate": 12.35,
          "type": "SERVICE"
        }
      ],
      "voucher": {
        "serialNumber": "123456",
        "voucherRef": "urn:x-memento:Voucher:123"
      }
    }
  ]
}

Response

Purchase created successfully

statusCodeinteger
idstring
detailstring
errorCodestring