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 line amounts, but it checks that they add up. Line amounts, discount amounts, VAT, additional taxes and withholding are stored as you send them; a line whose amounts do not follow Noyax’s rules is rejected (6120). The order totals and AverageExchangeRate are filled from the lines; values sent for them are ignored. The rules are on the quote calculations page; order lines have the same fields as quote lines. The API also calculates the line’s main unit quantity and the order’s currency (derived from the lines). A line’s AdditionalTaxes follow the same rules as the product’s additional taxes: at most 3, each Code required and one of the listed codes, and a code can be used only once on a line.

Required fields

  • OrderType: 1 purchase order, 2 sales order. It cannot be changed after the order is created (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.
  • Lines: at least one line (6012).
The order currency is not a request field: each line sends its own CurrencyCode. The document currency is derived from the lines (the single currency they share, or the company’s default currency when they differ) and returned as CurrencyCode. AverageExchangeRate is not sent either; it is filled from the lines (a value in the request is ignored): when all lines share one currency, the average of the line exchange rates weighted by the line amounts (the sum of AmountExcludingTax × ExchangeRate divided by the sum of AmountExcludingTax); when the lines have different currencies, 1. See currencies. DueDays (payment term in days) is stored with the order and used for the due date of the customer movement below; the movement’s rate is the order’s AverageExchangeRate, filled from the lines.

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, filled from the lines) 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.
The customer movement of a sales order is also checked against the customer’s risk limit when the customer’s RiskAction is 2; an order that would exceed it is rejected with 6020. Purchase orders are not checked. On update, the check runs only when the customer changes or the amount increases.

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

  • The product is given with ProductCode (the product’s code) or ECommerceProductCode (its e-commerce integration code); one of them is required. If both are sent, ProductCode is used. UnitCode is 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 and must exclude VAT. VatIncluded is ignored (it is still accepted so that existing requests keep working).
  • CurrencyCode is required on every line. ExchangeRate must be 1 when the line currency is the company’s default currency; otherwise it is required and must be greater than 0.
  • 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. It is negative on a sales order and positive on a purchase order.
  • 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 (despatch, 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.