Skip to main content

Named Calculations

Endpoints

GET /named-calculation/master

Summary

Returns an array of calculation records, each with a defined formula.

Request Parameters

In

Field Name

Type

Required

Description

header

X-Company-ID

string

Yes

The identifier of the company to manage data for

query

$filter

string

No

A filter expression in OData v4 format

query

$top

int32

No

The maximum documents to return

query

$skip

int32

No

The documents to skip before returning

query

$orderby

string

No

An order by expression in OData v4 format

query

effective_date

string

Yes

The date and time to query against

query

entity_ids

string

No

An array of entity identifiers

query

include_audit

boolean

No

Adds audit fields to each document when returning a result (is_active, is_master, created_at, created_by, updated_at, updated_by)

query

include_inactive

boolean

No

Includes the documents that are inactive for the current sites

Response

Description

200 OK

Success

A sample of the Named Calculation response body is shown below this table.

400 Bad Request

Bad request, for more information look at body error

403 Forbidden

Invalid token

404 Not Found

Not found

422 Unprocessable Entity

Unprocessable error

Default

Unexpected error

Sample Named Calculation Response Body

{ "items": [ { "_id": "9999999999999999", "name": "Tax Total", "named_code": "total_tax", "description": "Total tax", "data_type": "amount", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "order", "refund" ] }, "order_state": { "in": [ "closed", "paid" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('order','refund') AND order_state IN ('closed','paid') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "tax_inclusive + tax_exclusive", "formula_object": { "type": "BinaryExpression", "operator": "+", "left": { "type": "Identifier", "name": "tax_inclusive" }, "right": { "type": "Identifier", "name": "tax_exclusive" } }, "transaction_id": "9999999999999999", "is_default": true }, { "_id": "9999999999999999", "name": "Net Sales", "named_code": "net_sales", "description": "Net Sales", "data_type": "amount", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "order", "refund" ] }, "order_state": { "in": [ "closed", "paid" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('order','refund') AND order_state IN ('closed','paid') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "item_unit_price * item_quantity - discount_amount - tax_inclusive", "formula_object": { "type": "BinaryExpression", "operator": "-", "left": { "type": "BinaryExpression", "operator": "-", "left": { "type": "BinaryExpression", "operator": "*", "left": { "type": "Identifier", "name": "item_unit_price" }, "right": { "type": "Identifier", "name": "item_quantity" } }, "right": { "type": "Identifier", "name": "discount_amount" } }, "right": { "type": "Identifier", "name": "tax_inclusive" } }, "transaction_id": "9999999999999999", "is_default": true, "is_primary_calculation": false }, { "_id": "9999999999999999", "name": "Discount Total", "named_code": "discount_total", "description": "Discount total", "data_type": "amount", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "order", "refund" ] }, "order_state": { "in": [ "closed", "paid" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('order','refund') AND order_state IN ('closed','paid') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "discount_amount", "formula_object": { "type": "Identifier", "name": "discount_amount" }, "transaction_id": "9999999999999999", "is_default": true }, { "_id": "9999999999999999", "name": "Voided Post Payment", "named_code": "voided_post_payment", "description": "Voided post payment", "data_type": "amount", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "order" ] }, "order_state": { "in": [ "voided-post-payment" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('order') AND order_state IN ('voided-post-payment') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "(item_unit_price * item_quantity) + tax_exclusive", "formula_object": { "type": "BinaryExpression", "operator": "+", "left": { "type": "BinaryExpression", "operator": "*", "left": { "type": "Identifier", "name": "item_unit_price" }, "right": { "type": "Identifier", "name": "item_quantity" } }, "right": { "type": "Identifier", "name": "tax_exclusive" } }, "transaction_id": "9999999999999999", "is_default": true }, { "_id": "9999999999999999", "name": "Refund Total", "named_code": "refund_total", "description": "Refund total", "data_type": "amount", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "refund" ] }, "order_state": { "in": [ "closed", "paid" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('refund') AND order_state IN ('closed','paid') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "(item_unit_price * item_quantity) + tax_exclusive", "formula_object": { "type": "BinaryExpression", "operator": "+", "left": { "type": "BinaryExpression", "operator": "*", "left": { "type": "Identifier", "name": "item_unit_price" }, "right": { "type": "Identifier", "name": "item_quantity" } }, "right": { "type": "Identifier", "name": "tax_exclusive" } }, "transaction_id": "9999999999999999", "is_default": true }, { "_id": "9999999999999999", "name": "Gross Sales", "named_code": "gross_sales", "description": "Gross sales", "data_type": "amount", "entity_id": "9999999999999999", "formula_text": "FORMULA(CODE_net_sales) + FORMULA(CODE_discount_total) + FORMULA(CODE_total_tax) + FORMULA(CODE_voided_post_payment) + FORMULA(CODE_refund_total)", "nested_formulas_entity_ids": [ "9999999999999999", "9999999999999999", "9999999999999999", "9999999999999999", "9999999999999999" ], "formula_object": { "type": "BinaryExpression", "operator": "+", "left": { "type": "BinaryExpression", "operator": "+", "left": { "type": "BinaryExpression", "operator": "+", "left": { "type": "BinaryExpression", "operator": "+", "left": { "type": "CallExpression", "arguments": [ { "type": "Identifier", "name": "CODE_net_sales" } ], "callee": { "type": "Identifier", "name": "FORMULA" } }, "right": { "type": "CallExpression", "arguments": [ { "type": "Identifier", "name": "CODE_discount_total" } ], "callee": { "type": "Identifier", "name": "FORMULA" } } }, "right": { "type": "CallExpression", "arguments": [ { "type": "Identifier", "name": "CODE_total_tax" } ], "callee": { "type": "Identifier", "name": "FORMULA" } } }, "right": { "type": "CallExpression", "arguments": [ { "type": "Identifier", "name": "9999999999999999" } ], "callee": { "type": "Identifier", "name": "FORMULA" } } }, "right": { "type": "CallExpression", "arguments": [ { "type": "Identifier", "name": "CODE_refund_total" } ], "callee": { "type": "Identifier", "name": "FORMULA" } } }, "transaction_id": "9999999999999999", "is_default": true, "is_primary_calculation": true }, { "_id": "9999999999999999", "name": "Net Sales Quantity", "named_code": "net_sales_quantity", "description": "Net Sales Quantity", "data_type": "number", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "order" ] }, "order_state": { "in": [ "closed", "paid" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('order') AND order_state IN ('closed','paid') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "item_quantity", "formula_object": { "type": "Identifier", "name": "item_quantity" }, "transaction_id": "9999999999999999", "is_default": true }, { "_id": "9999999999999999", "name": "Gross Sales Quantity", "named_code": "gross_sales_quantity", "description": "Gross Sales Quantity", "data_type": "number", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "order" ] }, "order_state": { "in": [ "closed", "paid", "voided-post-payment" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('order') AND order_state IN ('closed','paid','voided-post-payment') "formula_text": "item_quantity", "formula_object": { "type": "Identifier", "name": "item_quantity" }, "transaction_id": "9999999999999999", "is_default": true }, { "_id": "9999999999999999", "name": "Liability Items Total", "named_code": "liability_items_total", "description": "Liability Items Total", "data_type": "amount", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "order", "refund" ] }, "order_state": { "in": [ "closed", "paid" ] }, "item_type": { "in": [ "gift_card", "gift_certificate" ] } }, "condition_text": "order_type IN ('order','refund') AND order_state IN ('closed','paid') AND item_type IN ('gift_card','gift_certificate')", "formula_text": "item_unit_price * item_quantity", "formula_object": { "type": "BinaryExpression", "operator": "*", "left": { "type": "Identifier", "name": "item_unit_price" }, "right": { "type": "Identifier", "name": "item_quantity" } }, "transaction_id": "9999999999999999", "is_default": true }, { "_id": "9999999999999999", "name": "Voided Orders Total", "named_code": "voided_orders_total", "description": "Voided Orders Total", "data_type": "amount", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "order" ] }, "order_state": { "in": [ "voided" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('order') AND order_state IN ('voided') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "item_unit_price * item_quantity + tax_exclusive", "formula_object": { "type": "BinaryExpression", "operator": "+", "left": { "type": "BinaryExpression", "operator": "*", "left": { "type": "Identifier", "name": "item_unit_price" }, "right": { "type": "Identifier", "name": "item_quantity" } }, "right": { "type": "Identifier", "name": "tax_exclusive" } }, "transaction_id": "9999999999999999", "is_default": true }, { "_id": "9999999999999999", "name": "Total Refunded Tax", "named_code": "total_refunded_tax", "description": "Total Refunded Tax", "data_type": "amount", "entity_id": "9999999999999999", "condition_object": { "order_type": { "in": [ "refund" ] }, "order_state": { "in": [ "closed", "paid" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('refund') AND order_state IN ('closed','paid') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "tax_inclusive + tax_exclusive", "formula_object": { "type": "BinaryExpression", "operator": "+", "left": { "type": "Identifier", "name": "tax_inclusive" }, "right": { "type": "Identifier", "name": "tax_exclusive" } }, "transaction_id": "9999999999999999", "is_default": true } ], "total": 11, "page_count": 1, "current_page": 1, "page_size": 100 }

GET /named-calculation/document/<_id>

Request Parameters

In

Field Name

Type

Required

Description

header

X-Company-ID

string

Yes

The identifier of the company to manage data for

path

_id

string

Yes

The identifier of the document

Response

Description

200 OK

Success

A sample Named Calculation response body is shown below this table.

400 Bad Request

Bad request, for more information look at body error

403 Forbidden

Invalid token

404 Not Found

Not found

422 Unprocessable Entity

Unprocessable error

Default

Unexpected error

Sample Named Calculation Response Body

{ "_id": "9999999999999999", "name": "Refund Total", "named_code": "refund_total", "description": "Refund total", "data_type": "amount", "entity_id": "9999999999999999", "is_master": true, "condition_object": { "order_type": { "in": [ "refund" ] }, "order_state": { "in": [ "closed", "paid" ] }, "item_type": { "nin": [ "gift_card", "gift_certificate", "fee", "comment" ] } }, "condition_text": "order_type IN ('refund') AND order_state IN ('closed','paid') AND item_type NOT IN ('gift_card','gift_certificate','fee','comment')", "formula_text": "(item_unit_price * item_quantity) + tax_exclusive", "is_active": true, "formula_object": { "type": "BinaryExpression", "operator": "+", "left": { "type": "BinaryExpression", "operator": "*", "left": { "type": "Identifier", "name": "item_unit_price" }, "right": { "type": "Identifier", "name": "item_quantity" } }, "right": { "type": "Identifier", "name": "tax_exclusive" } }, "company_id": "9999999999999999", "created_at": "20YY-09-17T04:29:26.241Z", "created_by": "9999999999999999", "updated_at": "20YY-09-17T04:29:26.241Z", "updated_by": "9999999999999999", "transaction_id": "9999999999999999", "is_default": true }