OrderType 1) and sales orders (OrderType 2) use the same endpoints.
Required fields
OrderType:1purchase order,2sales order. It cannot be changed while the order has a customer movement (6015).OrderNumber: unique within the company for the sameOrderType, 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
TheCreateCustomerMovement 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:
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
GrandTotaland 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
ProductCodeandUnitCodeare required. The unit must be one of the product’s own units (its main unit, or its second/third unit).Quantitymust be greater than 0;UnitPricecannot be negative.- If a line has no
CurrencyCode, the order currency is used;ExchangeRateis the rate of the line currency. Discountsis 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.LineGroupNameis optional and comes from the line groups definition.WarehouseNameis 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
UnitCodeis the product’s main unit,MainUnitQuantityequalsQuantity. - 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
0counts as1).MainUnitQuantity=Quantity/ multiplier.
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.