Skip to main content
An order has a header and one or more lines. Purchase orders (OrderType 1) and sales orders (OrderType 2) use the same endpoints.
The API does not calculate amounts and does not check that they are consistent. Line amounts, discount amounts, VAT, additional taxes, withholding, order totals and the weighted average exchange rate are stored exactly as you send them. For the calculation rules see the quote calculations page; order lines have the same fields as quote lines. The only exception is the line’s main unit quantity, which the API calculates.

Required fields

  • OrderType: 1 purchase order, 2 sales order. It cannot be changed while the order has a customer movement (6015).
  • OrderNumber: unique within the company for the same OrderType, at most 10 characters (6002). Send "Next" on create to generate it from the company’s number series: ALSİPNO for purchase orders and SATSİPNO for sales orders. "Next" cannot be sent on update (6003).
  • Date: the order date. If you send a time it is stored as the order time, otherwise the current time is used.
  • CustomerCode: a customer the user can see. The order is written with the customer’s address: the invoice address when the customer has one, otherwise the first address.
  • CurrencyCode: the order currency.
  • Lines: at least one line (6012).
DueDays (payment term in days) and AverageExchangeRate (weighted average rate of the lines, default 1) are stored with the order; both are also used for the due date and the rate of the customer movement below.

Customer movement

The CreateCustomerMovement field decides whether the order is reflected on the customer’s account. You do not send a separate request or field: the movement is written together with the order, in the same transaction. When true, the order amount (GrandTotal) is written to the customer’s account as follows: The movement takes its date, time, document number (the order number), description, currency (CurrencyCode) and rate (AverageExchangeRate) from the order. The due date is Date + DueDays; when DueDays is 0 there is no due date. In responses, CreateCustomerMovement shows whether the order has a customer movement. On update the movement is brought in line with the request:
If the movement has been closed by a collection or payment (even partially), its customer, currency and amount cannot be changed, it cannot be deleted, and the order that owns it cannot be deleted. The operation is cancelled with one of these errors: 6016 for a purchase order, 6017 for a sales order. An update that keeps the customer, currency and amount unchanged does not affect a closed movement and is accepted.

Approvals and status

When an order is created, the following are assigned automatically; there are no request fields for them:
  • Approvals: for each of the company’s active order approval definitions whose minimum amount is below GrandTotal and that applies to the order type (a definition applies to both purchase and sales, or only to the order’s type), a “pending” approval record is created, in the definition’s sequence order.
  • Status: if the company has a default order status defined, the order starts with that status. Otherwise the status stays empty.
StatusId and StatusName in responses show the order’s current status. Update and partial update do not change approvals or the status, and approvals are not recalculated even if GrandTotal changes.

Lines

  • ProductCode and UnitCode are required. The unit must be one of the product’s own units (its main unit, or its second/third unit).
  • Quantity must be greater than 0; UnitPrice cannot be negative.
  • If a line has no CurrencyCode, the order currency is used; ExchangeRate is the rate of the line currency.
  • Discounts is the list of the line’s discount rates. They are applied one after another in list order: 10, 10 and 10 give a 27.1% line discount. Leave the list empty when the line has no discount.
  • LineGroupName is optional and comes from the line groups definition.
  • WarehouseName is optional and must be one of the company’s warehouses (6112).
  • Lines have no ID: their position in the list is their position in the order, and an update replaces all lines.

Main unit quantity

Quantity is in the line’s unit. MainUnitQuantity in responses is the same quantity expressed in the product’s main unit; it is calculated by the API and you do not send it.
  • If UnitCode is the product’s main unit, MainUnitQuantity equals Quantity.
  • If it is the product’s second or third unit, the multiplier of that unit is found first: the quantity the product defines for that unit divided by its counter quantity (a counter quantity of 0 counts as 1). MainUnitQuantity = Quantity / multiplier.
For example, if the product defines a quantity of 100 and a counter quantity of 3 for its second unit, the multiplier is 33.33, and a line of 1000 in the second unit is 30 in the main unit. If the product defines no quantity for that unit (0), the main unit quantity cannot be calculated and the line is rejected with 6113.

Editing and deleting

Editing and deleting are not restricted by the order’s status or by whether it has been transferred to other documents (waybill, invoice). The only restrictions are a closed customer movement (see above) and other records (for example a quote or an opportunity) referring to the order (6014).

Sharing

SharingCode limits who can see the order: empty means visible to everyone, otherwise it must be one of the user’s sharing codes (6011). Orders the user cannot see return 404.