Overview
This documentation outlines the required imports and initializations for the Purchase Order module in both Python and PHP. These imports ensure that the necessary classes, services, and configurations are available to manage purchase orders.
Common Imports Requirements
The following imports are required for running the Purchase Order module in Python and PHP:
from exsited.exsited.common.dto.common_dto import TaxDTO
from exsited.exsited.exsited_sdk import ExsitedSDK
from exsited.exsited.purchase_order.dto.purchase_order_dto import (
PurchaseOrderListDTO, PurchaseOrderDetailsDTO, PurchaseOrderDTO,PurchaseOrderCreateDTO, PurchaseOrderDataDTO
)
from exsited.common.ab_exception import ABException
from exsited.common.sdk_conf import SDKConfig
from config import CommonData
require '../../vendor/autoload.php';
use Api\Component\ApiConfig;
use Api\AppService\PurchaseOrder\PurchaseOrderData;
use Api\ApiHelper\Config\ConfigManager;
Function: listPurchaseOrdersBasic
Purpose
listPurchaseOrdersBasic()
is used to obtain a complete list of purchase orders, allowing users to view details for multiple orders in one request. This function manages the request, processes the response, and handles exceptions, supporting straightforward integration in both Python and PHP environments.
Parameters
This function does not require any input parameters.
Use Case
The listPurchaseOrdersBasic()
function retrieves and displays a list of all purchase orders in the Exsited Portal. This feature is designed to allow users to view and manage purchase orders from various suppliers easily. By calling list() in Python or readAll() in PHP, the function fetches purchase orders and outputs them in a readable format. In case of any errors during the request, the code captures and displays relevant error messages for debugging. This functionality is beneficial for supplier-based order tracking, ensuring that users can access comprehensive purchase order details directly in the Exsited Portal.
def list_PurchaseOrders_Basic():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.purchase_order.list()
print(response)
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function listPurchaseOrdersBasic()
{
try {
$response = $this->purchaseOrderService->readAll();
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
The output of listPurchaseOrdersBasic()
is a JSON object containing a purchase_orders array, where each entry represents a purchase order with details such as id, accountId, item, quantity, currency, price, date, and status. This standardized output allows for efficient tracking and management of purchase orders across both Python and PHP implementations.
{
purchaseOrders: [
{
status: "ACTIVE",
id: "PURCHASE_ORDER_ID",
currency: {
uuid: "CURRENCY_UUID",
name: "CURRENCY_NAME",
link: "CURRENCY_LINK"
},
supplierInvoiceId: "SUPPLIER_INVOICE_ID",
issueDate: "ISSUE_DATE",
dueDate: "DUE_DATE",
expectedCompletionDate: "EXPECTED_COMPLETION_DATE",
subtotal: "SUBTOTAL",
tax: "TAX",
total: "TOTAL",
priceTaxInclusive: "PRICE_TAX_INCLUSIVE",
purchaseOrderNote: "PURCHASE_ORDER_NOTE",
accountId: "ACCOUNT_ID",
createdBy: "CREATED_BY",
createdOn: "CREATED_ON",
lastUpdatedBy: "LAST_UPDATED_BY",
lastUpdatedOn: "LAST_UPDATED_ON",
uuid: "PURCHASE_ORDER_UUID",
version: "VERSION",
customAttributes: [],
customObjects: [],
lines: [
{
subtotal: "LINE_SUBTOTAL",
total: "LINE_TOTAL",
tax: "LINE_TAX",
itemUuid: "ITEM_UUID",
itemId: "ITEM_ID",
itemName: "ITEM_NAME",
itemQuantity: "ITEM_QUANTITY",
itemPriceSnapshot: {
pricingRule: {
uuid: "PRICING_RULE_UUID",
version: "PRICING_RULE_VERSION",
priceType: "PRICE_TYPE",
price: "PRICE",
uom: "UNIT_OF_MEASURE",
warehouse: "WAREHOUSE",
pricingVersion: "PRICING_VERSION",
latestUsedPricingVersion: "LATEST_USED_PRICING_VERSION"
}
},
itemPurchaseTaxConfiguration: {
purchasePriceIsTaxInclusive: "PURCHASE_PRICE_TAX_INCLUSIVE",
taxCode: {
uuid: "TAX_CODE_UUID",
code: "TAX_CODE",
rate: "TAX_RATE",
link: "TAX_LINK"
}
},
itemPriceTaxExempt: "ITEM_PRICE_TAX_EXEMPT",
itemPriceTax: {
uuid: "ITEM_TAX_UUID",
code: "ITEM_TAX_CODE",
rate: "ITEM_TAX_RATE",
link: "ITEM_TAX_LINK"
},
purchaseOrderNote: "LINE_PURCHASE_ORDER_NOTE",
itemAccountingCode: {
costOfGoodsSold: "COST_OF_GOODS_SOLD"
},
uuid: "LINE_UUID",
version: "LINE_VERSION",
itemSerialOrBatchNumber: "ITEM_SERIAL_OR_BATCH_NUMBER"
}
],
kpis: {
totalExpense: "TOTAL_EXPENSE",
estimatedTotal: "ESTIMATED_TOTAL",
totalOutstanding: "TOTAL_OUTSTANDING",
totalOverdue: "TOTAL_OVERDUE",
lastInvoiceIssueDate: "LAST_INVOICE_ISSUE_DATE",
lastInvoiceTotal: "LAST_INVOICE_TOTAL",
totalPurchaseInvoice: "TOTAL_PURCHASE_INVOICE",
lastReactivatedOn: "LAST_REACTIVATED_ON",
lastCancelledOn: "LAST_CANCELLED_ON",
lastChangedOn: "LAST_CHANGED_ON",
lastDeletedOn: "LAST_DELETED_ON",
issueDate: "KPI_ISSUE_DATE"
}
}
]
}
{
{
"purchase_orders": [
{
"status": "{STATUS}",
"id": "{PURCHASE_ORDER_ID}",
"currency": {
"uuid": "{CURRENCY_UUID}",
"name": "{CURRENCY_NAME}",
"link": "{CURRENCY_LINK}"
},
"supplier_invoice_id": "{SUPPLIER_INVOICE_ID}",
"issue_date": "{ISSUE_DATE}",
"due_date": "{DUE_DATE}",
"expected_completion_date": "{EXPECTED_COMPLETION_DATE}",
"subtotal": "{SUBTOTAL}",
"tax": "{TAX}",
"total": "{TOTAL}",
"price_tax_inclusive": "{PRICE_TAX_INCLUSIVE}",
"purchase_order_note": "{PURCHASE_ORDER_NOTE}",
"account_id": "{ACCOUNT_ID}",
"created_by": "{CREATED_BY}",
"created_on": "{CREATED_ON}",
"last_updated_by": "{LAST_UPDATED_BY}",
"last_updated_on": "{LAST_UPDATED_ON}",
"uuid": "{PURCHASE_ORDER_UUID}",
"version": "{VERSION}",
"custom_attributes": [],
"custom_objects": [],
"lines": [
{
"subtotal": "{LINE_SUBTOTAL}",
"total": "{LINE_TOTAL}",
"tax": "{LINE_TAX}",
"item_uuid": "{ITEM_UUID}",
"item_id": "{ITEM_ID}",
"item_name": "{ITEM_NAME}",
"item_quantity": "{ITEM_QUANTITY}",
"item_price_snapshot": {
"pricing_rule": {
"uuid": "{PRICING_RULE_UUID}",
"version": "{PRICING_RULE_VERSION}",
"price_type": "{PRICE_TYPE}",
"price": "{PRICE}",
"uom": "{UNIT_OF_MEASURE}",
"warehouse": "{WAREHOUSE}",
"pricing_version": "{PRICING_VERSION}",
"latest_used_pricing_version": "{LATEST_USED_PRICING_VERSION}"
}
},
"item_purchase_tax_configuration": {
"purchase_price_is_tax_inclusive": "{PURCHASE_PRICE_TAX_INCLUSIVE}",
"tax_code": {
"uuid": "{TAX_CODE_UUID}",
"code": "{TAX_CODE}",
"rate": "{TAX_RATE}",
"link": "{TAX_LINK}"
}
},
"item_price_tax_exempt": "{ITEM_PRICE_TAX_EXEMPT}",
"item_price_tax": {
"uuid": "{ITEM_TAX_UUID}",
"code": "{ITEM_TAX_CODE}",
"rate": "{ITEM_TAX_RATE}",
"link": "{ITEM_TAX_LINK}"
},
"purchase_order_note": "{LINE_PURCHASE_ORDER_NOTE}",
"item_accounting_code": {
"cost_of_goods_sold": "{COST_OF_GOODS_SOLD}"
},
"uuid": "{LINE_UUID}",
"version": "{LINE_VERSION}"
}
],
"kpis": {
"total_expense": "{TOTAL_EXPENSE}",
"estimated_total": "{ESTIMATED_TOTAL}",
"total_outstanding": "{TOTAL_OUTSTANDING}",
"total_overdue": "{TOTAL_OVERDUE}",
"last_invoice_issue_date": "{LAST_INVOICE_ISSUE_DATE}",
"last_invoice_total": "{LAST_INVOICE_TOTAL}",
"total_purchase_invoice": "{TOTAL_PURCHASE_INVOICE}",
"last_reactivated_on": "{LAST_REACTIVATED_ON}",
"last_calcelled_on": "{LAST_CANCELLED_ON}",
"last_changed_on": "{LAST_CHANGED_ON}",
"last_deleted_on": "{LAST_DELETED_ON}",
"issue_date": "{KPI_ISSUE_DATE}"
}
}
// Additional purchase orders follow the same structure
]
}
},
Function: getPurchaseOrderDetails
Purpose
getPurchaseOrderDetails()
is used to obtain detailed information about a specific purchase order, allowing users to view all relevant details in one request. This function manages the request, processes the response, and handles exceptions, ensuring seamless integration in both Python and PHP environments.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | Unique identifier for the purchase order |
Use Case
The getPurchaseOrderDetails()
function in Python and PHP retrieves detailed information for a specific purchase order in the Exsited Portal, using the unique order ID. This function is helpful for users needing a closer look at individual purchase order data. By calling "details(id)" in Python or "readDetails(id)" in PHP, the function fetches and displays purchase order information in a structured format. In cases where the retrieval fails, relevant error messages are provided for troubleshooting. This functionality enhances visibility into each purchase order's specifics, supporting detailed supplier order management in the Exsited Portal.
def getPurchaseOrderDetails():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.purchase_order.details(id="PO-ID")
print(response)
return response
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function GetPurchaseOrderDetails()
{
$id = 'PO-ID';
try {
$response = $this->purchaseOrderService->readDetails($id);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
The output of getPurchaseOrderDetails()
is a JSON object containing detailed information about the specified purchase order. This includes attributes such as id, accountId, item, quantity, currency, price, date, status, and additional details like supplier, billingTerm, fulfillmentDate, and deliveryMethod. This output format provides comprehensive insights into the purchase order for tracking and management in both Python and PHP implementations.
{
"purchaseOrder": {
"status": "{STATUS}",
"id": "{PURCHASE_ORDER_ID}",
"currency": {
"uuid": "{CURRENCY_UUID}",
"name": "{CURRENCY_NAME}",
"link": "{CURRENCY_LINK}"
},
"supplierInvoiceId": "{SUPPLIER_INVOICE_ID}",
"issueDate": "{ISSUE_DATE}",
"dueDate": "{DUE_DATE}",
"expectedCompletionDate": "{EXPECTED_COMPLETION_DATE}",
"subtotal": "{SUBTOTAL}",
"tax": "{TAX}",
"total": "{TOTAL}",
"priceTaxInclusive": "{PRICE_TAX_INCLUSIVE}",
"purchaseOrderNote": "{PURCHASE_ORDER_NOTE}",
"accountId": "{ACCOUNT_ID}",
"createdBy": "{CREATED_BY}",
"createdOn": "{CREATED_ON}",
"lastUpdatedBy": "{LAST_UPDATED_BY}",
"lastUpdatedOn": "{LAST_UPDATED_ON}",
"uuid": "{PURCHASE_ORDER_UUID}",
"version": "{VERSION}",
"customAttributes": [],
"customObjects": [],
"lines": [
{
"subtotal": "{LINE_SUBTOTAL}",
"total": "{LINE_TOTAL}",
"tax": "{LINE_TAX}",
"itemUuid": "{ITEM_UUID}",
"itemId": "{ITEM_ID}",
"itemName": "{ITEM_NAME}",
"itemQuantity": "{ITEM_QUANTITY}",
"itemPriceSnapshot": {
"pricingRule": {
"uuid": "{PRICING_RULE_UUID}",
"version": "{PRICING_RULE_VERSION}",
"priceType": "{PRICE_TYPE}",
"price": "{PRICE}",
"uom": "{UOM}",
"warehouse": "{WAREHOUSE}",
"pricingVersion": "{PRICING_VERSION}",
"latestUsedPricingVersion": "{LATEST_USED_PRICING_VERSION}"
}
},
"itemPurchaseTaxConfiguration": {
"purchasePriceIsTaxInclusive": "{TAX_INCLUSIVE}",
"taxCode": {
"uuid": "{TAX_CODE_UUID}",
"code": "{TAX_CODE}",
"rate": "{TAX_RATE}",
"link": "{TAX_CODE_LINK}"
}
},
"itemPriceTaxExempt": "{PRICE_TAX_EXEMPT}",
"itemPriceTax": {
"uuid": "{ITEM_TAX_UUID}",
"code": "{ITEM_TAX_CODE}",
"rate": "{ITEM_TAX_RATE}",
"link": "{ITEM_TAX_LINK}"
},
"purchaseOrderNote": "{LINE_PURCHASE_ORDER_NOTE}",
"itemAccountingCode": {
"costOfGoodsSold": "{COST_OF_GOODS_SOLD}"
},
"uuid": "{LINE_UUID}",
"version": "{LINE_VERSION}",
"itemSerialOrBatchNumber": "{ITEM_SERIAL_OR_BATCH_NUMBER}"
}
],
"kpis": {
"totalExpense": "{TOTAL_EXPENSE}",
"estimatedTotal": "{ESTIMATED_TOTAL}",
"totalOutstanding": "{TOTAL_OUTSTANDING}",
"totalOverdue": "{TOTAL_OVERDUE}",
"lastInvoiceIssueDate": "{LAST_INVOICE_ISSUE_DATE}",
"lastInvoiceTotal": "{LAST_INVOICE_TOTAL}",
"totalPurchaseInvoice": "{TOTAL_PURCHASE_INVOICE}",
"lastReactivatedOn": "{LAST_REACTIVATED_ON}",
"lastCancelledOn": "{LAST_CANCELLED_ON}",
"lastChangedOn": "{LAST_CHANGED_ON}",
"lastDeletedOn": "{LAST_DELETED_ON}",
"issueDate": "{KPI_ISSUE_DATE}"
}
}
}{
"purchaseOrder": {
"status": "{STATUS}",
"id": "{PURCHASE_ORDER_ID}",
"currency": {
"uuid": "{CURRENCY_UUID}",
"name": "{CURRENCY_NAME}",
"link": "{CURRENCY_LINK}"
},
"supplierInvoiceId": "{SUPPLIER_INVOICE_ID}",
"issueDate": "{ISSUE_DATE}",
"dueDate": "{DUE_DATE}",
"expectedCompletionDate": "{EXPECTED_COMPLETION_DATE}",
"subtotal": "{SUBTOTAL}",
"tax": "{TAX}",
"total": "{TOTAL}",
"priceTaxInclusive": "{PRICE_TAX_INCLUSIVE}",
"purchaseOrderNote": "{PURCHASE_ORDER_NOTE}",
"accountId": "{ACCOUNT_ID}",
"createdBy": "{CREATED_BY}",
"createdOn": "{CREATED_ON}",
"lastUpdatedBy": "{LAST_UPDATED_BY}",
"lastUpdatedOn": "{LAST_UPDATED_ON}",
"uuid": "{PURCHASE_ORDER_UUID}",
"version": "{VERSION}",
"customAttributes": [],
"customObjects": [],
"lines": [
{
"subtotal": "{LINE_SUBTOTAL}",
"total": "{LINE_TOTAL}",
"tax": "{LINE_TAX}",
"itemUuid": "{ITEM_UUID}",
"itemId": "{ITEM_ID}",
"itemName": "{ITEM_NAME}",
"itemQuantity": "{ITEM_QUANTITY}",
"itemPriceSnapshot": {
"pricingRule": {
"uuid": "{PRICING_RULE_UUID}",
"version": "{PRICING_RULE_VERSION}",
"priceType": "{PRICE_TYPE}",
"price": "{PRICE}",
"uom": "{UOM}",
"warehouse": "{WAREHOUSE}",
"pricingVersion": "{PRICING_VERSION}",
"latestUsedPricingVersion": "{LATEST_USED_PRICING_VERSION}"
}
},
"itemPurchaseTaxConfiguration": {
"purchasePriceIsTaxInclusive": "{TAX_INCLUSIVE}",
"taxCode": {
"uuid": "{TAX_CODE_UUID}",
"code": "{TAX_CODE}",
"rate": "{TAX_RATE}",
"link": "{TAX_CODE_LINK}"
}
},
"itemPriceTaxExempt": "{PRICE_TAX_EXEMPT}",
"itemPriceTax": {
"uuid": "{ITEM_TAX_UUID}",
"code": "{ITEM_TAX_CODE}",
"rate": "{ITEM_TAX_RATE}",
"link": "{ITEM_TAX_LINK}"
},
"purchaseOrderNote": "{LINE_PURCHASE_ORDER_NOTE}",
"itemAccountingCode": {
"costOfGoodsSold": "{COST_OF_GOODS_SOLD}"
},
"uuid": "{LINE_UUID}",
"version": "{LINE_VERSION}",
"itemSerialOrBatchNumber": "{ITEM_SERIAL_OR_BATCH_NUMBER}"
}
],
"kpis": {
"totalExpense": "{TOTAL_EXPENSE}",
"estimatedTotal": "{ESTIMATED_TOTAL}",
"totalOutstanding": "{TOTAL_OUTSTANDING}",
"totalOverdue": "{TOTAL_OVERDUE}",
"lastInvoiceIssueDate": "{LAST_INVOICE_ISSUE_DATE}",
"lastInvoiceTotal": "{LAST_INVOICE_TOTAL}",
"totalPurchaseInvoice": "{TOTAL_PURCHASE_INVOICE}",
"lastReactivatedOn": "{LAST_REACTIVATED_ON}",
"lastCancelledOn": "{LAST_CANCELLED_ON}",
"lastChangedOn": "{LAST_CHANGED_ON}",
"lastDeletedOn": "{LAST_DELETED_ON}",
"issueDate": "{KPI_ISSUE_DATE}"
}
}
}
{
{
"purchase_order": {
"status": "{STATUS}",
"id": "{PURCHASE_ORDER_ID}",
"currency": {
"uuid": "{CURRENCY_UUID}",
"name": "{CURRENCY_NAME}",
"link": "{CURRENCY_LINK}"
},
"supplier_invoice_id": "{SUPPLIER_INVOICE_ID}",
"issue_date": "{ISSUE_DATE}",
"due_date": "{DUE_DATE}",
"expected_completion_date": "{EXPECTED_COMPLETION_DATE}",
"subtotal": "{SUBTOTAL}",
"tax": "{TAX}",
"total": "{TOTAL}",
"price_tax_inclusive": "{PRICE_TAX_INCLUSIVE}",
"purchase_order_note": "{PURCHASE_ORDER_NOTE}",
"account_id": "{ACCOUNT_ID}",
"created_by": "{CREATED_BY}",
"created_on": "{CREATED_ON}",
"last_updated_by": "{LAST_UPDATED_BY}",
"last_updated_on": "{LAST_UPDATED_ON}",
"uuid": "{PURCHASE_ORDER_UUID}",
"version": "{VERSION}",
"custom_attributes": [],
"custom_objects": [],
"lines": [
{
"subtotal": "{LINE_SUBTOTAL}",
"total": "{LINE_TOTAL}",
"tax": "{LINE_TAX}",
"item_uuid": "{ITEM_UUID}",
"item_id": "{ITEM_ID}",
"item_name": "{ITEM_NAME}",
"item_quantity": "{ITEM_QUANTITY}",
"item_price_snapshot": {
"pricing_rule": {
"uuid": "{PRICING_RULE_UUID}",
"version": "{PRICING_RULE_VERSION}",
"price_type": "{PRICE_TYPE}",
"price": "{PRICE}",
"uom": "{UNIT_OF_MEASURE}",
"warehouse": "{WAREHOUSE}",
"pricing_version": "{PRICING_VERSION}",
"latest_used_pricing_version": "{LATEST_USED_PRICING_VERSION}"
}
},
"item_purchase_tax_configuration": {
"purchase_price_is_tax_inclusive": "{PURCHASE_PRICE_TAX_INCLUSIVE}",
"tax_code": {
"uuid": "{TAX_CODE_UUID}",
"code": "{TAX_CODE}",
"rate": "{TAX_RATE}",
"link": "{TAX_LINK}"
}
},
"item_price_tax_exempt": "{ITEM_PRICE_TAX_EXEMPT}",
"item_price_tax": {
"uuid": "{ITEM_TAX_UUID}",
"code": "{ITEM_TAX_CODE}",
"rate": "{ITEM_TAX_RATE}",
"link": "{ITEM_TAX_LINK}"
},
"purchase_order_note": "{LINE_PURCHASE_ORDER_NOTE}",
"item_accounting_code": {
"cost_of_goods_sold": "{COST_OF_GOODS_SOLD}"
},
"uuid": "{LINE_UUID}",
"version": "{LINE_VERSION}"
}
],
"kpis": {
"total_expense": "{TOTAL_EXPENSE}",
"estimated_total": "{ESTIMATED_TOTAL}",
"total_outstanding": "{TOTAL_OUTSTANDING}",
"total_overdue": "{TOTAL_OVERDUE}",
"last_invoice_issue_date": "{LAST_INVOICE_ISSUE_DATE}",
"last_invoice_total": "{LAST_INVOICE_TOTAL}",
"total_purchase_invoice": "{TOTAL_PURCHASE_INVOICE}",
"last_reactivated_on": "{LAST_REACTIVATED_ON}",
"last_calcelled_on": "{LAST_CANCELLED_ON}",
"last_changed_on": "{LAST_CHANGED_ON}",
"last_deleted_on": "{LAST_DELETED_ON}",
"issue_date": "{KPI_ISSUE_DATE}"
}
}
}
Function: createPurchaseOrder
Purpose
createPurchaseOrder()
facilitates the creation of a detailed purchase order, including information such as item quantity, pricing, tax configuration, and supplier account details. The function manages the creation request, processes the response, and handles exceptions for seamless integration in Python and PHP.
Note: For successful purchase order creation:
- Item quantity must be set to "unlimited."
- Each item must have both sale and purchase prices configured.
- The account ID provided must be a valid supplier ID.
Parameters
Parameter |
Type |
Description |
---|---|---|
currency |
String |
Currency code for the purchase order |
issueDate |
Date |
Date the purchase order is issued |
dueDate |
Date |
Payment due date for the purchase order |
expectedCompletionDate |
Date |
Expected completion date for the order |
priceTaxInclusive |
Boolean |
Flag to include tax in price |
accountId |
String |
Supplier’s account ID |
itemUuid |
String |
Unique identifier for the item |
itemQuantity |
Integar |
Quantity of the item |
priceType |
String |
Pricing model for the item |
price |
Integar |
Price of the item |
Use Case
The createPurchaseOrder()
function in both Python and PHP creates a new purchase order in the Exsited Portal. Users can define various order details, such as currency, issue date, due date, item details, tax information, and pricing rules. The Python version assembles a "PurchaseOrderDataDTO" object with these specifications, while the PHP version builds a structured array ("$params") with corresponding details. This function enables seamless integration of new orders into the system, allowing businesses to automate order management efficiently. Error handling is implemented to display specific error messages if order creation fails, improving user troubleshooting and reliability in order creation.
def CreatePurchaseOrder():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
purchase_order_data = PurchaseOrderDataDTO(
currency="{CURRENCY}",
issueDate="{ISSUE_DATE}",
dueDate="{DUE_DATE}",
expectedCompletionDate="{EXPECTED_COMPLETION_DATE}",
priceTaxInclusive="{PRICE_TAX_INCLUSIVE}",
purchaseOrderNote="{PURCHASE_ORDER_NOTE}",
accountId="{ACCOUNT_ID}",
lines=[
PurchaseOrderLineDTO(
itemUuid="{ITEM_UUID}",
itemQuantity="{ITEM_QUANTITY}",
itemPriceSnapshot=PurchaseOrderItemPriceSnapshotDTO(
pricingRule=PurchaseOrderPricingRuleDTO(
priceType="{PRICE_TYPE}",
price="{PRICE}"
)
),
itemPurchaseTaxConfiguration=PurchaseOrderItemPurchaseTaxConfigurationDTO(
purchasePriceIsTaxInclusive="{PURCHASE_PRICE_TAX_INCLUSIVE}",
taxCode=PurchaseOrderTaxCodeDTO(
uuid="{TAX_UUID}",
code="{TAX_CODE}",
rate="{TAX_RATE}",
link="{TAX_LINK}"
)
),
itemPriceTaxExempt="{ITEM_PRICE_TAX_EXEMPT}",
itemPriceTax=TaxDTO(
uuid="{TAX_UUID}",
code="{TAX_CODE}",
rate="{TAX_RATE}",
link="{TAX_LINK}"
),
purchaseOrderNote="{LINE_PURCHASE_ORDER_NOTE}",
itemAccountingCode=PurchaseOrderItemAccountingCodeDTO(
costOfGoodsSold="{COST_OF_GOODS_SOLD}"
)
)
]
)
request_obj = PurchaseOrderCreateDTO(purchaseOrder=purchase_order_data)
response = exsited_sdk.purchase_order.create(request_data=request_obj)
print(response)
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function CreatePurchaseOrder()
{
$params = [
"purchase-order" => [
"currency" => "{CURRENCY}",
"price_tax_inclusive" => "{PRICE_TAX_INCLUSIVE}",
"account_id" => "{ACCOUNT_ID}",
"lines" => [
[
"item_uuid" => "{ITEM_UUID}",
"item_quantity" => "{ITEM_QUANTITY}",
"item_price_snapshot" => [
"pricing_rule" => [
"price_type" => "{PRICE_TYPE}",
"price" => "{PRICE}"
]
],
"item_purchase_tax_configuration" => [
"purchase_price_is_tax_inclusive" => "{PURCHASE_PRICE_IS_TAX_INCLUSIVE}",
"tax_code" => [
"uuid" => "{TAX_UUID}",
"code" => "{TAX_CODE}",
"rate" => "{TAX_RATE}"
]
],
"item_price_tax_exempt" => "{ITEM_PRICE_TAX_EXEMPT}",
"item_price_tax" => [
"uuid" => "{ITEM_TAX_UUID}",
"code" => "{ITEM_TAX_CODE}",
"rate" => "{ITEM_TAX_RATE}"
]
]
]
]
];
try {
$response = $this->purchaseOrderService->create($params);
echo '' . json_encode($response, JSON_PRETTY_PRINT) . '';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
The output of createPurchaseOrder()
is a JSON object confirming the successful creation of the purchase order. It includes status, message, and details of the purchase order, such as id, accountId, currency, issueDate, dueDate, and item-specific information under lines. This response provides a clear and detailed confirmation of the new purchase order in both Python and PHP implementations.
{
"purchaseOrder": {
"status": "{STATUS}",
"id": "{PURCHASE_ORDER_ID}",
"currency": {
"uuid": "{CURRENCY_UUID}",
"name": "{CURRENCY_NAME}",
"link": "{CURRENCY_LINK}"
},
"supplierInvoiceId": "{SUPPLIER_INVOICE_ID}",
"issueDate": "{ISSUE_DATE}",
"dueDate": "{DUE_DATE}",
"expectedCompletionDate": "{EXPECTED_COMPLETION_DATE}",
"subtotal": "{SUBTOTAL}",
"tax": "{TAX}",
"total": "{TOTAL}",
"priceTaxInclusive": "{PRICE_TAX_INCLUSIVE}",
"purchaseOrderNote": "{PURCHASE_ORDER_NOTE}",
"accountId": "{ACCOUNT_ID}",
"createdBy": "{CREATED_BY}",
"createdOn": "{CREATED_ON}",
"lastUpdatedBy": "{LAST_UPDATED_BY}",
"lastUpdatedOn": "{LAST_UPDATED_ON}",
"uuid": "{PURCHASE_ORDER_UUID}",
"version": "{VERSION}",
"customAttributes": [],
"customObjects": [],
"lines": [
{
"subtotal": "{LINE_SUBTOTAL}",
"total": "{LINE_TOTAL}",
"tax": "{LINE_TAX}",
"itemUuid": "{ITEM_UUID}",
"itemId": "{ITEM_ID}",
"itemName": "{ITEM_NAME}",
"itemQuantity": "{ITEM_QUANTITY}",
"itemPriceSnapshot": {
"pricingRule": {
"uuid": "{PRICING_RULE_UUID}",
"version": "{PRICING_RULE_VERSION}",
"priceType": "{PRICE_TYPE}",
"price": "{PRICE}",
"uom": "{UOM}",
"warehouse": "{WAREHOUSE}",
"pricingVersion": "{PRICING_VERSION}",
"latestUsedPricingVersion": "{LATEST_USED_PRICING_VERSION}"
}
},
"itemPurchaseTaxConfiguration": {
"purchasePriceIsTaxInclusive": "{TAX_INCLUSIVE}",
"taxCode": {
"uuid": "{TAX_CODE_UUID}",
"code": "{TAX_CODE}",
"rate": "{TAX_RATE}",
"link": "{TAX_CODE_LINK}"
}
},
"itemPriceTaxExempt": "{PRICE_TAX_EXEMPT}",
"itemPriceTax": {
"uuid": "{ITEM_TAX_UUID}",
"code": "{ITEM_TAX_CODE}",
"rate": "{ITEM_TAX_RATE}",
"link": "{ITEM_TAX_LINK}"
},
"purchaseOrderNote": "{LINE_PURCHASE_ORDER_NOTE}",
"itemAccountingCode": {
"costOfGoodsSold": "{COST_OF_GOODS_SOLD}"
},
"uuid": "{LINE_UUID}",
"version": "{LINE_VERSION}",
"itemSerialOrBatchNumber": "{ITEM_SERIAL_OR_BATCH_NUMBER}"
}
],
"kpis": {
"totalExpense": "{TOTAL_EXPENSE}",
"estimatedTotal": "{ESTIMATED_TOTAL}",
"totalOutstanding": "{TOTAL_OUTSTANDING}",
"totalOverdue": "{TOTAL_OVERDUE}",
"lastInvoiceIssueDate": "{LAST_INVOICE_ISSUE_DATE}",
"lastInvoiceTotal": "{LAST_INVOICE_TOTAL}",
"totalPurchaseInvoice": "{TOTAL_PURCHASE_INVOICE}",
"lastReactivatedOn": "{LAST_REACTIVATED_ON}",
"lastCancelledOn": "{LAST_CANCELLED_ON}",
"lastChangedOn": "{LAST_CHANGED_ON}",
"lastDeletedOn": "{LAST_DELETED_ON}",
"issueDate": "{KPI_ISSUE_DATE}"
}
}
}
{
{
"purchase_order": {
"status": "{STATUS}",
"id": "{PURCHASE_ORDER_ID}",
"currency": {
"uuid": "{CURRENCY_UUID}",
"name": "{CURRENCY_NAME}",
"link": "{CURRENCY_LINK}"
},
"supplier_invoice_id": "{SUPPLIER_INVOICE_ID}",
"issue_date": "{ISSUE_DATE}",
"due_date": "{DUE_DATE}",
"expected_completion_date": "{EXPECTED_COMPLETION_DATE}",
"subtotal": "{SUBTOTAL}",
"tax": "{TAX}",
"total": "{TOTAL}",
"price_tax_inclusive": "{PRICE_TAX_INCLUSIVE}",
"purchase_order_note": "{PURCHASE_ORDER_NOTE}",
"account_id": "{ACCOUNT_ID}",
"created_by": "{CREATED_BY}",
"created_on": "{CREATED_ON}",
"last_updated_by": "{LAST_UPDATED_BY}",
"last_updated_on": "{LAST_UPDATED_ON}",
"uuid": "{UUID}",
"version": "{VERSION}",
"custom_attributes": [],
"custom_objects": [],
"lines": [
{
"subtotal": "{LINE_SUBTOTAL}",
"total": "{LINE_TOTAL}",
"tax": "{LINE_TAX}",
"item_uuid": "{ITEM_UUID}",
"item_id": "{ITEM_ID}",
"item_name": "{ITEM_NAME}",
"item_quantity": "{ITEM_QUANTITY}",
"item_price_snapshot": {
"pricing_rule": {
"uuid": "{PRICING_RULE_UUID}",
"version": "{PRICING_RULE_VERSION}",
"price_type": "{PRICE_TYPE}",
"price": "{PRICE}",
"uom": "{UNIT_OF_MEASURE}",
"warehouse": "{WAREHOUSE}",
"pricing_version": "{PRICING_VERSION}",
"latest_used_pricing_version": "{LATEST_USED_PRICING_VERSION}"
}
},
"item_purchase_tax_configuration": {
"purchase_price_is_tax_inclusive": "{PURCHASE_PRICE_TAX_INCLUSIVE}",
"tax_code": {
"uuid": "{TAX_CODE_UUID}",
"code": "{TAX_CODE}",
"rate": "{TAX_RATE}",
"link": "{TAX_LINK}"
}
},
"item_price_tax_exempt": "{ITEM_PRICE_TAX_EXEMPT}",
"item_price_tax": {
"uuid": "{ITEM_TAX_UUID}",
"code": "{ITEM_TAX_CODE}",
"rate": "{ITEM_TAX_RATE}",
"link": "{ITEM_TAX_LINK}"
},
"purchase_order_note": "{LINE_PURCHASE_ORDER_NOTE}",
"item_accounting_code": {
"cost_of_goods_sold": "{COST_OF_GOODS_SOLD}"
},
"uuid": "{LINE_UUID}",
"version": "{LINE_VERSION}"
}
],
"kpis": {
"total_expense": "{TOTAL_EXPENSE}",
"estimated_total": "{ESTIMATED_TOTAL}",
"total_outstanding": "{TOTAL_OUTSTANDING}",
"total_overdue": "{TOTAL_OVERDUE}",
"last_invoice_issue_date": "{LAST_INVOICE_ISSUE_DATE}",
"last_invoice_total": "{LAST_INVOICE_TOTAL}",
"total_purchase_invoice": "{TOTAL_PURCHASE_INVOICE}",
"last_reactivated_on": "{LAST_REACTIVATED_ON}",
"last_calcelled_on": "{LAST_CANCELLED_ON}",
"last_changed_on": "{LAST_CHANGED_ON}",
"last_deleted_on": "{LAST_DELETED_ON}",
"issue_date": "{KPI_ISSUE_DATE}"
}
}
}
Function : deletePurchaseOrder
Purpose
Deletes a purchase order by its ID in both Python and PHP implementations.
Parameters
Parameter | Type | Description |
---|---|---|
id | String | The unique identifier of the purchase order to delete |
Use Case
Used to remove a purchase order from the system by specifying its ID. This function is essential for managing and maintaining accurate records, allowing businesses to clean up obsolete or incorrect purchase orders.
def Delete_PurchaseOrder():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.purchase_order.delete(id='PO_ID')
print(response)
return response
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function DeletePurchaseOrder()
{
$id = 'PO_ID';
try {
$response = $this->purchaseOrderService->delete($id);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
A response object indicating success or failure of the purchase order deletion.
{'success': True, 'status_code': 204}
null
Function : readPurchaseOrderInformation
Purpose
Retrieves detailed information about a specific purchase order by its ID.
Parameters
Parameter | Type | Description |
---|---|---|
id | String | The unique identifier of the purchase order |
Use Case
Used to fetch the details of an existing purchase order using the specified order ID. readPurchaseOrderInformation()
function allows businesses to access and review purchase order information, ensuring visibility and accuracy in procurement processes.
def read_PurchaseOrder_Information():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.purchase_order.information(id='PO-ID')
print(response)
return response
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function readPurchaseOrderInformation()
{
$id = 'PO-L8GX8U-0008';
try {
$response = $this->purchaseOrderService->readDetails($id);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
A response object containing the detailed information of the specified purchase order.
PurchaseOrderDetailsDTO(
purchaseOrder=PurchaseOrderDTO(
status='{STATUS}',
id='{PURCHASE_ORDER_ID}',
currency=PurchaseOrderCurrencyDTO(
uuid='{CURRENCY_UUID}',
name='{CURRENCY_NAME}',
link='{CURRENCY_LINK}'
),
supplierInvoiceId='{SUPPLIER_INVOICE_ID}',
issueDate='{ISSUE_DATE}',
dueDate='{DUE_DATE}',
expectedCompletionDate='{EXPECTED_COMPLETION_DATE}',
subtotal='{SUBTOTAL}',
tax='{TAX}',
total='{TOTAL}',
priceTaxInclusive='{PRICE_TAX_INCLUSIVE}',
purchaseOrderNote='{PURCHASE_ORDER_NOTE}',
accountId='{ACCOUNT_ID}',
createdBy='{CREATED_BY}',
createdOn='{CREATED_ON}',
lastUpdatedBy='{LAST_UPDATED_BY}',
lastUpdatedOn='{LAST_UPDATED_ON}',
uuid='{ORDER_UUID}',
version='{VERSION}',
customAttributes=[],
customObjects=[],
lines=None,
kpis=None
)
)
{
"purchase_order": {
"status": "{STATUS}",
"id": "{PURCHASE_ORDER_ID}",
"currency": {
"uuid": "{CURRENCY_UUID}",
"name": "{CURRENCY_NAME}",
"link": "{CURRENCY_LINK}"
},
"supplier_invoice_id": "{SUPPLIER_INVOICE_ID}",
"issue_date": "{ISSUE_DATE}",
"due_date": "{DUE_DATE}",
"expected_completion_date": "{EXPECTED_COMPLETION_DATE}",
"subtotal": "{SUBTOTAL}",
"tax": "{TAX}",
"total": "{TOTAL}",
"price_tax_inclusive": "{PRICE_TAX_INCLUSIVE}",
"purchase_order_note": "{PURCHASE_ORDER_NOTE}",
"account_id": "{ACCOUNT_ID}",
"created_by": "{CREATED_BY}",
"created_on": "{CREATED_ON}",
"last_updated_by": "{LAST_UPDATED_BY}",
"last_updated_on": "{LAST_UPDATED_ON}",
"uuid": "{PURCHASE_ORDER_UUID}",
"version": "{VERSION}",
"custom_attributes": [],
"custom_objects": [],
"lines": [
{
"subtotal": "{ITEM_SUBTOTAL}",
"total": "{ITEM_TOTAL}",
"tax": "{ITEM_TAX}",
"item_uuid": "{ITEM_UUID}",
"item_id": "{ITEM_ID}",
"item_name": "{ITEM_NAME}",
"item_quantity": "{ITEM_QUANTITY}",
"item_price_snapshot": {
"pricing_rule": {
"uuid": "{PRICING_RULE_UUID}",
"version": "{PRICING_RULE_VERSION}",
"price_type": "{PRICE_TYPE}",
"price": "{PRICE}",
"uom": "{UOM}",
"warehouse": "{WAREHOUSE}",
"pricing_version": "{PRICING_VERSION}",
"latest_used_pricing_version": "{LATEST_USED_PRICING_VERSION}"
}
},
"item_purchase_tax_configuration": {
"purchase_price_is_tax_inclusive": "{PURCHASE_PRICE_IS_TAX_INCLUSIVE}",
"tax_code": {
"uuid": "{TAX_CODE_UUID}",
"code": "{TAX_CODE}",
"rate": "{TAX_RATE}",
"link": "{TAX_LINK}"
}
},
"item_price_tax_exempt": "{ITEM_PRICE_TAX_EXEMPT}",
"item_price_tax": {
"uuid": "{ITEM_PRICE_TAX_UUID}",
"code": "{ITEM_PRICE_TAX_CODE}",
"rate": "{ITEM_PRICE_TAX_RATE}",
"link": "{ITEM_PRICE_TAX_LINK}"
},
"purchase_order_note": "{ITEM_PURCHASE_ORDER_NOTE}",
"item_accounting_code": {
"cost_of_goods_sold": "{COST_OF_GOODS_SOLD}"
},
"uuid": "{LINE_UUID}",
"version": "{LINE_VERSION}"
}
],
"kpis": {
"total_expense": "{TOTAL_EXPENSE}",
"estimated_total": "{ESTIMATED_TOTAL}",
"total_outstanding": "{TOTAL_OUTSTANDING}",
"total_overdue": "{TOTAL_OVERDUE}",
"last_invoice_issue_date": "{LAST_INVOICE_ISSUE_DATE}",
"last_invoice_total": "{LAST_INVOICE_TOTAL}",
"total_purchase_invoice": "{TOTAL_PURCHASE_INVOICE}",
"last_reactivated_on": "{LAST_REACTIVATED_ON}",
"last_calcelled_on": "{LAST_CANCELLED_ON}",
"last_changed_on": "{LAST_CHANGED_ON}",
"last_deleted_on": "{LAST_DELETED_ON}",
"issue_date": "{KPIS_ISSUE_DATE}"
}
}
}
Function: cancelPurchaseOrder
Purpose
This cancelPurchaseOrder()
function cancels a specific purchase order using its unique identifier.
Parameters
Parameter |
Type |
Description |
---|---|---|
id |
String |
The unique identifier of the purchase order |
request_data |
Object |
Additional data required for cancellation (Python) |
Use Case
Used to cancel an active or pending purchase order by providing its ID. Cancellation requests may include optional parameters or contextual data.
def cancel_PurchaseOrder():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.purchase_order.cancel(id="PO-ID", request_data=request_data)
print(response)
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function CancelPurchaseOrder()
{
$id = 'PO-ID';
try {
$response = $this->purchaseOrderService->cancel($id);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
A response confirming the cancellation of the specified purchase order, or an error message if the cancellation fails.
{'success': True, 'status_code': 204}
null
Function: reactivatePurchaseOrder
Purpose
This reactivatePurchaseOrder()
function reactivates a previously canceled purchase order using its unique identifier.
Parameters
Parameter |
Type |
Description |
---|---|---|
id |
String |
The unique identifier of the purchase order |
request_data |
Object |
Additional data required for reactivation (Python) |
Use Case
This <b><i>reactivatePurchaseOrder()</i></b>
is used to bring a canceled purchase order back into an active state, allowing further processing or transactions.
def reactivate_PurchaseOrder():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.purchase_order.reactivate(id="PO-ID", request_data=request_data)
print(response)
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function ReactivatePurchaseOrder()
{
$id = 'PO-ID';
try {
$response = $this->purchaseOrderService->reactivate($id);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
A response confirming the successful reactivation of the specified purchase order, or an error message if the reactivation fails.
{'success': True, 'status_code': 204}
NULL
Function: GetPurchaseOrderLineDetails
Purpose
Retrieves detailed information about a specific line item within a purchase order using its unique line UUID. This allows you to review the exact status, pricing, quantities, and related metadata of a particular line in the purchase order.
Parameters
Parameter |
Type |
Description |
---|---|---|
id |
String |
The unique identifier of the purchase order |
uuid |
String |
The unique line UUID associated with the order |
Use Case
Use this function when you need to inspect or verify the details of a specific line in a purchase order. For example, a retailer might need to confirm pricing, quantity, item specifications, or other key attributes before processing a shipment or updating inventory. This can also help in identifying discrepancies in a complex order where multiple items, custom attributes, or special conditions are involved, ensuring that each line is accurately managed and accounted for in operational workflows.
def Get_PurchaseOrder_Line_Details():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.purchase_order.line_uuid(id='PO-ID', uuid='UUID')
print(response)
return response
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function GetPurchaseOrderLineDetails()
{
$id = 'PO-ID';
$uuId = 'uuid';
try {
$response = $this->purchaseOrderService->readLineDetails($id, $uuId);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
A response object containing the detailed information for the specified purchase order line, including item details, pricing, and any associated attributes.
PurchaseOrderDetailsDTO
{
"purchase_order": {
"line": {
"subtotal": "{SUBTOTAL}",
"total": "{TOTAL}",
"tax": "{TAX}",
"item_uuid": "{ITEM_UUID}",
"item_id": "{ITEM_ID}",
"item_name": "{ITEM_NAME}",
"item_quantity": "{ITEM_QUANTITY}",
"item_price_snapshot": {
"pricing_rule": {
"uuid": "{PRICING_RULE_UUID}",
"version": "{PRICING_RULE_VERSION}",
"price_type": "{PRICE_TYPE}",
"price": "{PRICE}",
"uom": "{UOM}",
"warehouse": "{WAREHOUSE}",
"pricing_version": "{PRICING_VERSION}",
"latest_used_pricing_version": "{LATEST_USED_PRICING_VERSION}"
}
},
"item_purchase_tax_configuration": {
"purchase_price_is_tax_inclusive": "{PURCHASE_PRICE_IS_TAX_INCLUSIVE}",
"tax_code": {
"uuid": "{TAX_CODE_UUID}",
"code": "{TAX_CODE}",
"rate": "{TAX_RATE}",
"link": "{TAX_LINK}"
}
},
"item_price_tax_exempt": "{ITEM_PRICE_TAX_EXEMPT}",
"item_price_tax": {
"uuid": "{ITEM_PRICE_TAX_UUID}",
"code": "{ITEM_PRICE_TAX_CODE}",
"rate": "{ITEM_PRICE_TAX_RATE}",
"link": "{ITEM_PRICE_TAX_LINK}"
},
"purchase_order_note": "{PURCHASE_ORDER_NOTE}",
"item_accounting_code": {
"cost_of_goods_sold": "{COST_OF_GOODS_SOLD}"
},
"uuid": "{LINE_UUID}",
"version": "{VERSION}"
}
}
}
Function: purchaseOrderLine
Purpose
This function is designed to test the retrieval of detailed information about one or more lines within a purchase order. It allows developers or system integrators to ensure that the SDK or service layer correctly fetches the line-level data associated with a specific purchase order ID. This function is essential for verifying the integration and accurate data retrieval from the backend system for use cases such as validating line items, pricing details, quantities, tax configurations, or any related metadata required for processing or analysis. The function ensures smooth operational workflows by identifying potential discrepancies in purchase orders or their lines before they impact downstream processes like inventory updates, shipment handling, or financial reconciliation.
Parameters
Parameter |
Type |
Description |
---|---|---|
id |
String |
The unique identifier of the purchase order |
Use Case
Use this purchaseOrderLine()
function when you need to confirm that the integration for retrieving line-level details of a purchase order is functioning as expected. For example, during a system integration test, developers might use this to verify that line items' pricing, tax configurations, and quantities are accurately retrieved and match expected values in the backend database.
def purchase_order_line():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.purchase_order.line_uuid(id='PO-ID')
print(response)
return response
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function PurchaseOrderLine()
{
$id = 'PO-ID';
try {
$response = $this->purchaseOrderService->readLines($id);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
A response object containing the detailed information for the specified lines in the purchase order, including item details, pricing, quantities, tax configurations, and other associated metadata.
PurchaseOrderDetailsDTO(
purchaseOrder=PurchaseOrderDTO(
status=STATUS,
id=PURCHASE_ORDER_ID,
currency=CURRENCY,
supplierInvoiceId=SUPPLIER_INVOICE_ID,
issueDate=ISSUE_DATE,
dueDate=DUE_DATE,
expectedCompletionDate=EXPECTED_COMPLETION_DATE,
subtotal=SUBTOTAL,
tax=TAX,
total=TOTAL,
priceTaxInclusive=PRICE_TAX_INCLUSIVE,
purchaseOrderNote=PURCHASE_ORDER_NOTE,
accountId=ACCOUNT_ID,
createdBy=CREATED_BY,
createdOn=CREATED_ON,
lastUpdatedBy=LAST_UPDATED_BY,
lastUpdatedOn=LAST_UPDATED_ON,
uuid=UUID,
version=VERSION,
customAttributes=CUSTOM_ATTRIBUTES,
customObjects=CUSTOM_OBJECTS,
lines=[
PurchaseOrderLineDTO(
subtotal=LINE_SUBTOTAL,
total=LINE_TOTAL,
tax=LINE_TAX,
itemUuid=ITEM_UUID,
itemId=ITEM_ID,
itemName=ITEM_NAME,
itemQuantity=ITEM_QUANTITY,
itemPriceSnapshot=PurchaseOrderItemPriceSnapshotDTO(
pricingRule=PurchaseOrderPricingRuleDTO(
uuid=PRICING_RULE_UUID,
version=PRICING_RULE_VERSION,
priceType=PRICE_TYPE,
price=PRICE,
uom=UNIT_OF_MEASURE,
warehouse=WAREHOUSE,
pricingVersion=PRICING_VERSION,
latestUsedPricingVersion=LATEST_USED_PRICING_VERSION
)
),
itemPurchaseTaxConfiguration=PurchaseOrderItemPurchaseTaxConfigurationDTO(
purchasePriceIsTaxInclusive=PURCHASE_PRICE_IS_TAX_INCLUSIVE,
taxCode=PurchaseOrderTaxCodeDTO(
uuid=TAX_CODE_UUID,
code=TAX_CODE,
rate=TAX_RATE,
link=TAX_LINK
)
),
itemPriceTaxExempt=ITEM_PRICE_TAX_EXEMPT,
itemPriceTax=TaxDTO(
uuid=TAX_UUID,
code=TAX_CODE,
rate=TAX_RATE,
link=TAX_LINK,
amount=TAX_AMOUNT
),
purchaseOrderNote=LINE_PURCHASE_ORDER_NOTE,
itemAccountingCode=PurchaseOrderItemAccountingCodeDTO(
costOfGoodsSold=COST_OF_GOODS_SOLD
),
uuid=LINE_UUID,
version=LINE_VERSION,
itemSerialOrBatchNumber=ITEM_SERIAL_OR_BATCH_NUMBER
)
],
kpis=KPIS
)
)
{
"purchase_order": {
"lines": [
{
"subtotal": "SUBTOTAL",
"total": "TOTAL",
"tax": "TAX",
"item_uuid": "ITEM_UUID",
"item_id": "ITEM_ID",
"item_name": "ITEM_NAME",
"item_quantity": "ITEM_QUANTITY",
"item_price_snapshot": {
"pricing_rule": {
"uuid": "PRICING_RULE_UUID",
"version": "PRICING_RULE_VERSION",
"price_type": "PRICE_TYPE",
"price": "PRICE",
"uom": "UOM",
"warehouse": "WAREHOUSE",
"pricing_version": "PRICING_VERSION",
"latest_used_pricing_version": "LATEST_USED_PRICING_VERSION"
}
},
"item_purchase_tax_configuration": {
"purchase_price_is_tax_inclusive": "PURCHASE_PRICE_IS_TAX_INCLUSIVE",
"tax_code": {
"uuid": "TAX_CODE_UUID",
"code": "TAX_CODE",
"rate": "TAX_RATE",
"link": "TAX_LINK"
}
},
"item_price_tax_exempt": "ITEM_PRICE_TAX_EXEMPT",
"item_price_tax": {
"uuid": "ITEM_PRICE_TAX_UUID",
"code": "ITEM_PRICE_TAX_CODE",
"rate": "ITEM_PRICE_TAX_RATE",
"link": "
Configuration
Before using any of these functions, ensure that your API credentials are properly configured.
- Python: The request token is retrieved from CommonData.get_request_token_dto().
- PHP: Configuration is managed via ConfigManager and $this->purchaseOrderService
Language-Specific Features
Feature | Python Implementation | PHP Implementation |
---|---|---|
SDK Initialization | ExsitedSDK().init_sdk() | $this->purchaseOrderService |
Exception Handling | ABException handles errors and raw response | try-catch block for exceptions |
Response Format | Prints response using print() | Outputs response using json_encode() |
Configuration | Managed through SDKConfig | Managed via ConfigManager |
Authentication Method | OAuth token via CommonData.get_request_token_dto() | API credentials via $this->purchaseOrderService |
Error Logging | Captures errors with ABException and prints raw response | Captures exceptions and prints error message |
Data Parsing | JSON response parsed natively in Python | JSON encoded and displayed using PHP |
Error Output | print(ab.get_errors()) and ab.raw_response | echo 'Error: ' . $e->getMessage() |