@dotdev/harmony-sdk 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +132 -0
  2. package/dist/HarmonyAPI.d.ts +37 -0
  3. package/dist/HarmonyAPI.js +113 -0
  4. package/dist/errors/index.d.ts +15 -0
  5. package/dist/errors/index.js +18 -0
  6. package/dist/helpers/index.d.ts +50 -0
  7. package/dist/helpers/index.js +167 -0
  8. package/dist/helpers/index.spec.d.ts +1 -0
  9. package/dist/helpers/index.spec.js +147 -0
  10. package/dist/helpers/mapper.d.ts +2 -0
  11. package/dist/helpers/mapper.js +28 -0
  12. package/dist/helpers/utils.d.ts +71 -0
  13. package/dist/helpers/utils.js +133 -0
  14. package/dist/helpers/utils.spec.d.ts +1 -0
  15. package/dist/helpers/utils.spec.js +96 -0
  16. package/dist/index.d.ts +5 -0
  17. package/dist/index.js +5 -0
  18. package/dist/modules/auth/auth.module.d.ts +7 -0
  19. package/dist/modules/auth/auth.module.js +42 -0
  20. package/dist/modules/auth/auth.module.spec.d.ts +1 -0
  21. package/dist/modules/auth/auth.module.spec.js +55 -0
  22. package/dist/modules/auth/index.d.ts +2 -0
  23. package/dist/modules/auth/index.js +2 -0
  24. package/dist/modules/auth/types/index.d.ts +7 -0
  25. package/dist/modules/auth/types/index.js +1 -0
  26. package/dist/modules/carrier/carrier.module.d.ts +10 -0
  27. package/dist/modules/carrier/carrier.module.js +39 -0
  28. package/dist/modules/carrier/carrier.module.spec.d.ts +1 -0
  29. package/dist/modules/carrier/carrier.module.spec.js +187 -0
  30. package/dist/modules/carrier/index.d.ts +3 -0
  31. package/dist/modules/carrier/index.js +3 -0
  32. package/dist/modules/carrier/mappings/index.d.ts +5 -0
  33. package/dist/modules/carrier/mappings/index.js +36 -0
  34. package/dist/modules/carrier/types/index.d.ts +42 -0
  35. package/dist/modules/carrier/types/index.js +2 -0
  36. package/dist/modules/diary/diary.module.d.ts +9 -0
  37. package/dist/modules/diary/diary.module.js +28 -0
  38. package/dist/modules/diary/index.d.ts +3 -0
  39. package/dist/modules/diary/index.js +3 -0
  40. package/dist/modules/diary/mappings/diary.mapper.d.ts +4 -0
  41. package/dist/modules/diary/mappings/diary.mapper.js +101 -0
  42. package/dist/modules/diary/mappings/diary.mapper.spec.d.ts +1 -0
  43. package/dist/modules/diary/mappings/diary.mapper.spec.js +18 -0
  44. package/dist/modules/diary/mappings/index.d.ts +1 -0
  45. package/dist/modules/diary/mappings/index.js +1 -0
  46. package/dist/modules/diary/types/diary.interface.d.ts +138 -0
  47. package/dist/modules/diary/types/diary.interface.js +24 -0
  48. package/dist/modules/diary/types/index.d.ts +1 -0
  49. package/dist/modules/diary/types/index.js +1 -0
  50. package/dist/modules/gift-voucher/gift-voucher.module.d.ts +12 -0
  51. package/dist/modules/gift-voucher/gift-voucher.module.js +55 -0
  52. package/dist/modules/gift-voucher/gift-voucher.module.spec.d.ts +1 -0
  53. package/dist/modules/gift-voucher/gift-voucher.module.spec.js +296 -0
  54. package/dist/modules/gift-voucher/index.d.ts +1 -0
  55. package/dist/modules/gift-voucher/index.js +1 -0
  56. package/dist/modules/gift-voucher/mappings/index.d.ts +6 -0
  57. package/dist/modules/gift-voucher/mappings/index.js +70 -0
  58. package/dist/modules/gift-voucher/mappings/index.spec.d.ts +1 -0
  59. package/dist/modules/gift-voucher/mappings/index.spec.js +21 -0
  60. package/dist/modules/gift-voucher/types/index.d.ts +92 -0
  61. package/dist/modules/gift-voucher/types/index.js +1 -0
  62. package/dist/modules/index.d.ts +8 -0
  63. package/dist/modules/index.js +8 -0
  64. package/dist/modules/point-of-sale/index.d.ts +3 -0
  65. package/dist/modules/point-of-sale/index.js +3 -0
  66. package/dist/modules/point-of-sale/mappings/index.d.ts +1 -0
  67. package/dist/modules/point-of-sale/mappings/index.js +1 -0
  68. package/dist/modules/point-of-sale/mappings/process-sale-order.mapper.d.ts +6 -0
  69. package/dist/modules/point-of-sale/mappings/process-sale-order.mapper.js +142 -0
  70. package/dist/modules/point-of-sale/point-of-sale.module.d.ts +43 -0
  71. package/dist/modules/point-of-sale/point-of-sale.module.js +64 -0
  72. package/dist/modules/point-of-sale/point-of-sale.module.spec.d.ts +1 -0
  73. package/dist/modules/point-of-sale/point-of-sale.module.spec.js +205 -0
  74. package/dist/modules/point-of-sale/types/cancel-existing-sales-order.interface.d.ts +13 -0
  75. package/dist/modules/point-of-sale/types/cancel-existing-sales-order.interface.js +1 -0
  76. package/dist/modules/point-of-sale/types/index.d.ts +124 -0
  77. package/dist/modules/point-of-sale/types/index.js +31 -0
  78. package/dist/modules/point-of-sale/types/modify-existing-sales-order.interface.d.ts +12 -0
  79. package/dist/modules/point-of-sale/types/modify-existing-sales-order.interface.js +1 -0
  80. package/dist/modules/point-of-sale/types/process-returns.interface.d.ts +17 -0
  81. package/dist/modules/point-of-sale/types/process-returns.interface.js +1 -0
  82. package/dist/modules/point-of-sale/types/process-sale-order.interface.d.ts +67 -0
  83. package/dist/modules/point-of-sale/types/process-sale-order.interface.js +1 -0
  84. package/dist/modules/shared/index.d.ts +1 -0
  85. package/dist/modules/shared/index.js +1 -0
  86. package/dist/modules/shared/types/index.d.ts +93 -0
  87. package/dist/modules/shared/types/index.js +53 -0
  88. package/dist/modules/stock-level-lookup/index.d.ts +3 -0
  89. package/dist/modules/stock-level-lookup/index.js +3 -0
  90. package/dist/modules/stock-level-lookup/mappings/index.d.ts +1 -0
  91. package/dist/modules/stock-level-lookup/mappings/index.js +1 -0
  92. package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.d.ts +4 -0
  93. package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.js +78 -0
  94. package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.spec.d.ts +1 -0
  95. package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.spec.js +57 -0
  96. package/dist/modules/stock-level-lookup/stock-level-lookup.module.d.ts +10 -0
  97. package/dist/modules/stock-level-lookup/stock-level-lookup.module.js +39 -0
  98. package/dist/modules/stock-level-lookup/stock-level-lookup.module.spec.d.ts +1 -0
  99. package/dist/modules/stock-level-lookup/stock-level-lookup.module.spec.js +317 -0
  100. package/dist/modules/stock-level-lookup/types/index.d.ts +1 -0
  101. package/dist/modules/stock-level-lookup/types/index.js +1 -0
  102. package/dist/modules/stock-level-lookup/types/stock-level-lookup.interface.d.ts +162 -0
  103. package/dist/modules/stock-level-lookup/types/stock-level-lookup.interface.js +61 -0
  104. package/dist/modules/stock-lookup/index.d.ts +3 -0
  105. package/dist/modules/stock-lookup/index.js +3 -0
  106. package/dist/modules/stock-lookup/mappings/index.d.ts +1 -0
  107. package/dist/modules/stock-lookup/mappings/index.js +1 -0
  108. package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.d.ts +22 -0
  109. package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.js +156 -0
  110. package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.spec.d.ts +1 -0
  111. package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.spec.js +92 -0
  112. package/dist/modules/stock-lookup/stock-lookup.module.d.ts +65 -0
  113. package/dist/modules/stock-lookup/stock-lookup.module.js +141 -0
  114. package/dist/modules/stock-lookup/stock-lookup.module.spec.d.ts +1 -0
  115. package/dist/modules/stock-lookup/stock-lookup.module.spec.js +419 -0
  116. package/dist/modules/stock-lookup/types/index.d.ts +1 -0
  117. package/dist/modules/stock-lookup/types/index.js +1 -0
  118. package/dist/modules/stock-lookup/types/stock-lookup.interface.d.ts +242 -0
  119. package/dist/modules/stock-lookup/types/stock-lookup.interface.js +82 -0
  120. package/dist/modules/stock-lookup/types/stock-lookup.interface.spec.d.ts +1 -0
  121. package/dist/modules/stock-lookup/types/stock-lookup.interface.spec.js +76 -0
  122. package/dist/types/index.d.ts +5 -0
  123. package/dist/types/index.js +6 -0
  124. package/package.json +39 -0
@@ -0,0 +1,142 @@
1
+ import { Utils } from "../../../helpers";
2
+ export function mapProcessSaleOrderQueryParams(params) {
3
+ // XML body in JSON format, to be converted to XML string
4
+ const body = {
5
+ mode: params?.mode,
6
+ audit_no: params?.auditNo,
7
+ export_no: params?.exportNo,
8
+ header: mapProcessSaleOrderQueryHeaders(params?.header),
9
+ extra: mapProcessSaleOrderQueryExtra(params?.extra),
10
+ stock: params?.stock.map(mapProcessSaleOrderQueryStock),
11
+ debtor: mapProcessSaleOrderQueryDebtor((params?.debtor ?? [])[0]),
12
+ };
13
+ return Utils.toXml(Utils.deleteEmptyProps(body));
14
+ }
15
+ export function mapProcessSaleOrderQueryHeaders(params) {
16
+ // XML body in JSON format, to be converted to XML string
17
+ const body = {
18
+ invoice_no: params?.invoiceNo,
19
+ order_no: params?.orderNo,
20
+ customer_order_no: params?.customerOrderNo,
21
+ transaction_date: params?.transactionDate,
22
+ transaction_time_hour: params?.transactionTimeHour,
23
+ transaction_time_min: params?.transactionTimeMin,
24
+ transaction_time_sec: params?.transactionTimeSec,
25
+ shop_debtor: params?.shopDebtor,
26
+ diary: params?.diary,
27
+ diary_name_1: params?.diaryName1,
28
+ diary_name_2: params?.diaryName2,
29
+ warehouse: params?.warehouse,
30
+ originated_warehouse: params?.originatedWarehouse,
31
+ fulfillment_warehouse: params?.fulfillmentWarehouse,
32
+ agent_zone_1: params?.agentZone1,
33
+ agent_zone_2: params?.agentZone2 ?? "",
34
+ agent_zone_3: params?.agentZone3 ?? "",
35
+ terminal_id: params?.terminalId,
36
+ cancel_layby_no: params?.cancelLaybyNo,
37
+ order_class: params?.orderClass,
38
+ user: params?.user,
39
+ order_lines: params?.orderLines,
40
+ order_deposit_total: params?.orderDepositTotal,
41
+ order_version: params?.orderVersion,
42
+ comment_1: params?.comment1,
43
+ comment_2: params?.comment2,
44
+ comment_3: params?.comment3,
45
+ comment_4: params?.comment4,
46
+ comment_5: params?.comment5,
47
+ comment_6: params?.comment6,
48
+ comment_7: params?.comment7,
49
+ comment_8: params?.comment8,
50
+ comment_9: params?.comment9,
51
+ comment_10: params?.comment10,
52
+ order_delivery_date: params?.orderDeliveryDate,
53
+ order_cancel_after_date: params?.orderCancelAfterDate,
54
+ order_tax_exemption: params?.orderTaxExemption,
55
+ originator_software: params?.originatorSoftware,
56
+ account_sale_flag: params?.accountSaleFlag,
57
+ web_order_type: params?.webOrderType,
58
+ };
59
+ return Utils.toXml(Utils.deleteEmptyProps(body));
60
+ }
61
+ export function mapProcessSaleOrderQueryExtra(params) {
62
+ // XML body in JSON format, to be converted to XML string
63
+ const body = {
64
+ delivery_address_1: params?.deliveryAddress1,
65
+ delivery_address_2: params?.deliveryAddress2,
66
+ delivery_address_3: params?.deliveryAddress3,
67
+ delivery_address_4: params?.deliveryAddress4,
68
+ delivery_postcode: params?.deliveryPostcode,
69
+ delivery_instruction_1: params?.deliveryInstruction1,
70
+ delivery_instruction_2: params?.deliveryInstruction2,
71
+ carrier: params?.carrier,
72
+ email: params?.email,
73
+ telephone_home: params?.telephoneHome,
74
+ telephone_mobile: params?.telephoneMobile,
75
+ telephone_work: params?.telephoneWork,
76
+ billing_surname: params?.billingSurname,
77
+ billing_first_name: params?.billingFirstname,
78
+ billing_address_1: params?.billingAddress1,
79
+ billing_address_2: params?.billingAddress2,
80
+ billing_address_3: params?.billingAddress3,
81
+ billing_address_4: params?.billingAddress4,
82
+ billing_postcode: params?.billingPostcode,
83
+ billing_telephone_home: params?.billingTelephoneHome,
84
+ billing_telephone_mobile: params?.billingTelephoneMobile,
85
+ billing_telephone_work: params?.billingTelephoneWork,
86
+ customised_info: params?.customisedInfo,
87
+ };
88
+ return Utils.toXml(Utils.deleteEmptyProps(body));
89
+ }
90
+ export function mapProcessSaleOrderQueryStock(params) {
91
+ // XML body in JSON format, to be converted to XML string
92
+ const body = {
93
+ dispatch_date: params?.dispatchDate,
94
+ stock: params?.stock,
95
+ stock_description: params?.stockDescription,
96
+ size: params?.size,
97
+ qdp: params?.qdp,
98
+ pdp: params?.pdp,
99
+ invoice_qty: params?.invoiceQty,
100
+ order_qty: params?.orderQty,
101
+ discount_price: params?.discountPrice,
102
+ line_tax: params?.lineTax,
103
+ discount_rate: params?.discountRate,
104
+ discount_reason: params?.discountReason,
105
+ credit_note_reason: params?.creditNoteReason,
106
+ serial_no: params?.serialNo,
107
+ deposit_amount: params?.depositAmount,
108
+ export_line_no: params?.exportLineNo,
109
+ comment: params?.comment,
110
+ markdown_Reason: params?.markdownReason,
111
+ sku_barcode: params?.skuBarcode,
112
+ credit_note_reference: params?.creditNoteReference,
113
+ current_rrp_inc: params?.currentRrpInc,
114
+ per: params?.per,
115
+ singles_per_pack: params?.singlesPerPack,
116
+ packs_per_carton: params?.packsPerCarton,
117
+ size_pack_name: params?.sizePackName,
118
+ };
119
+ return Utils.toXml(Utils.deleteEmptyProps(body));
120
+ }
121
+ export function mapProcessSaleOrderQueryDebtor(params) {
122
+ // XML body in JSON format, to be converted to XML string
123
+ const body = {
124
+ payment_type: params?.paymentType,
125
+ credit_reference: params?.creditReference,
126
+ payment_amount: params?.paymentAmount,
127
+ invoice_price_inc: params?.invoicePriceInc,
128
+ rounding: params?.rounding,
129
+ total_tax: params?.totalTax,
130
+ card_name: params?.cardName,
131
+ card_no: params?.cardNo,
132
+ card_holder: params?.cardHolder,
133
+ card_expiry_month: params?.cardExpiryMonth,
134
+ card_expiry_year: params?.cardExpiryYear,
135
+ comment: params?.comment,
136
+ cash_drawer_id: params?.cashDrawerId,
137
+ gift_voucher_stock: params?.giftVoucherStock,
138
+ gift_voucher_serial_no: params?.giftVoucherSerialNo,
139
+ reservation_history_no: params?.reservationHistoryNo,
140
+ };
141
+ return Utils.toXml(Utils.deleteEmptyProps(body));
142
+ }
@@ -0,0 +1,43 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { ProcessSaleOrderQueryParams } from "./types";
3
+ export declare class PointOfSaleModule {
4
+ private axiosInstance;
5
+ private readonly SERVICE_URL;
6
+ constructor(axiosInstance: AxiosInstance);
7
+ /**
8
+ * Function to call the ProcessSalesOrder endpoint in Harmony Point Of Sale service
9
+ *
10
+ * @async
11
+ * @param {ProcessSaleOrderQueryParams} params
12
+ * @param {string} sessionId
13
+ * @returns {Promise<boolean>}
14
+ */
15
+ processSalesOrder(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<boolean>;
16
+ /**
17
+ * Function to call the ProcessReturns endpoint in Harmony Point Of Sale service
18
+ *
19
+ * @async
20
+ * @param {ProcessSaleOrderQueryParams} params
21
+ * @param {string} sessionId
22
+ * @returns {Promise<boolean>}
23
+ */
24
+ processReturns(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<boolean>;
25
+ /**
26
+ * Function to call the ModifyExistingSalesOrder endpoint in Harmony Point Of Sale service
27
+ *
28
+ * @async
29
+ * @param {ProcessSaleOrderQueryParams} params
30
+ * @param {string} sessionId
31
+ * @returns {Promise<boolean>}
32
+ */
33
+ modifyExistingSalesOrder(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<boolean>;
34
+ /**
35
+ * Function to call the CancelExistingSalesOrder endpoint in Harmony Point Of Sale service
36
+ *
37
+ * @async
38
+ * @param {ProcessSaleOrderQueryParams} params
39
+ * @param {string} sessionId
40
+ * @returns {Promise<boolean>}
41
+ */
42
+ cancelExistingSalesOrder(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<boolean>;
43
+ }
@@ -0,0 +1,64 @@
1
+ import { ApiHelper } from "../../helpers";
2
+ import { ServiceAlias } from "../shared";
3
+ import { mapProcessSaleOrderQueryParams } from "./mappings/process-sale-order.mapper";
4
+ export class PointOfSaleModule {
5
+ axiosInstance;
6
+ SERVICE_URL = "PointOfSaleService/PointOfSaleService";
7
+ constructor(axiosInstance) {
8
+ this.axiosInstance = axiosInstance;
9
+ }
10
+ /**
11
+ * Function to call the ProcessSalesOrder endpoint in Harmony Point Of Sale service
12
+ *
13
+ * @async
14
+ * @param {ProcessSaleOrderQueryParams} params
15
+ * @param {string} sessionId
16
+ * @returns {Promise<boolean>}
17
+ */
18
+ async processSalesOrder(params, sessionId) {
19
+ try {
20
+ const requestBody = mapProcessSaleOrderQueryParams(params);
21
+ const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, ["ProcessSalesOrder", "Request"], sessionId, ServiceAlias.POINT_OF_SALE, this.axiosInstance, requestBody);
22
+ return Boolean(response?.result[0] ?? "false");
23
+ }
24
+ catch (error) {
25
+ throw await ApiHelper.parseError(error);
26
+ }
27
+ }
28
+ /**
29
+ * Function to call the ProcessReturns endpoint in Harmony Point Of Sale service
30
+ *
31
+ * @async
32
+ * @param {ProcessSaleOrderQueryParams} params
33
+ * @param {string} sessionId
34
+ * @returns {Promise<boolean>}
35
+ */
36
+ async processReturns(params, sessionId) {
37
+ // TODO: add implementation
38
+ return true;
39
+ }
40
+ /**
41
+ * Function to call the ModifyExistingSalesOrder endpoint in Harmony Point Of Sale service
42
+ *
43
+ * @async
44
+ * @param {ProcessSaleOrderQueryParams} params
45
+ * @param {string} sessionId
46
+ * @returns {Promise<boolean>}
47
+ */
48
+ async modifyExistingSalesOrder(params, sessionId) {
49
+ // TODO: add implementation
50
+ return true;
51
+ }
52
+ /**
53
+ * Function to call the CancelExistingSalesOrder endpoint in Harmony Point Of Sale service
54
+ *
55
+ * @async
56
+ * @param {ProcessSaleOrderQueryParams} params
57
+ * @param {string} sessionId
58
+ * @returns {Promise<boolean>}
59
+ */
60
+ async cancelExistingSalesOrder(params, sessionId) {
61
+ // TODO: add implementation
62
+ return true;
63
+ }
64
+ }
@@ -0,0 +1,205 @@
1
+ import axios from "axios";
2
+ import { ApiHelper, Utils } from "../../helpers";
3
+ import { ServiceAlias } from "../shared";
4
+ import { PointOfSaleModule } from "./point-of-sale.module";
5
+ import { AccountSaleFlag, PosPaymentType, PosQueryMode, } from "./types";
6
+ jest.mock("axios");
7
+ const mAxios = axios;
8
+ describe("PointOfSaleModule", () => {
9
+ const sessionId = "test-sid"; // process.env.SESSION_ID as string;
10
+ let posModule;
11
+ let mockApiHelperSendRequest;
12
+ beforeAll(() => {
13
+ posModule = new PointOfSaleModule(mAxios);
14
+ mockApiHelperSendRequest = jest.spyOn(ApiHelper, "sendSoapRequest");
15
+ });
16
+ test("ProcessSaleOrder should process the order correctly and return response", async () => {
17
+ const token = "test-token";
18
+ const ns = "S";
19
+ const expectedPayload = `
20
+ <${ns}:Envelope xmlns:${ns}="http://schemas.xmlsoap.org/soap/envelope/" xmlns:${ServiceAlias.POINT_OF_SALE}="http://${ServiceAlias.POINT_OF_SALE}.ws.fbsaust.com.au">
21
+ <${ns}:Header>
22
+ <${ServiceAlias.POINT_OF_SALE}:SessionId>${token}</${ServiceAlias.POINT_OF_SALE}:SessionId>
23
+ </${ns}:Header>
24
+ <${ns}:Body>
25
+ <${ServiceAlias.POINT_OF_SALE}:ProcessSalesOrderRequest >
26
+ <mode>U</mode>
27
+ <audit_no>106942</audit_no>
28
+ <header>
29
+ <order_no>W00106943</order_no>
30
+ <customer_order_no>W00106943</customer_order_no>
31
+ <transaction_date>02-06-2015</transaction_date>
32
+ <transaction_time_hour>11</transaction_time_hour>
33
+ <transaction_time_min>52</transaction_time_min>
34
+ <transaction_time_sec>0</transaction_time_sec>
35
+ <shop_debtor>ABC</shop_debtor>
36
+ <diary>0005353</diary>
37
+ <diary_name_1>AMMY</diary_name_1>
38
+ <diary_name_2>WHITE</diary_name_2>
39
+ <warehouse>WEB</warehouse>
40
+ <agent_zone_1>1111</agent_zone_1>
41
+ <terminal_id>online</terminal_id>
42
+ <user>WEB</user>
43
+ <order_lines>0</order_lines>
44
+ <order_deposit_total>119.95</order_deposit_total>
45
+ <order_version>0</order_version>
46
+ <originator_software>WEB</originator_software>
47
+ <account_sale_flag>Y</account_sale_flag>
48
+ </header>
49
+ <extra>
50
+ <delivery_address_1>37</delivery_address_1>
51
+ <delivery_address_2>HOTHAM ST</delivery_address_2>
52
+ <delivery_address_3>ST KILDA EAST</delivery_address_3>
53
+ <delivery_address_4>VIC</delivery_address_4>
54
+ <delivery_postcode>3111</delivery_postcode>
55
+ <delivery_instruction_1>Enter backdoor</delivery_instruction_1>
56
+ <delivery_instruction_2>Then frontdoor</delivery_instruction_2>
57
+ <carrier>APOST</carrier>
58
+ <email>test@example.com</email>
59
+ <telephone_home>0444888885</telephone_home>
60
+ <telephone_mobile>0444888884</telephone_mobile>
61
+ <telephone_work>0444888883</telephone_work>
62
+ <billing_surname>DOE</billing_surname>
63
+ <billing_first_name>JOHN</billing_first_name>
64
+ <billing_address_1>37</billing_address_1>
65
+ <billing_address_2>HOTHAM ST</billing_address_2>
66
+ <billing_address_3>ST KILDA EAST</billing_address_3>
67
+ <billing_address_4>VIC</billing_address_4>
68
+ <billing_postcode>3111</billing_postcode>
69
+ <billing_telephone_home>0444888888</billing_telephone_home>
70
+ <billing_telephone_mobile>0444888887</billing_telephone_mobile>
71
+ <billing_telephone_work>0444888886</billing_telephone_work>
72
+ <customised_info>CUSTOM</customised_info>
73
+ </extra>
74
+ <stock>
75
+ <stock>7281VL.100</stock>
76
+ <stock_description>3/4 SLV CROSS OVER DRESS W/ TUCKS</stock_description>
77
+ <size>S</size>
78
+ <qdp>0</qdp>
79
+ <pdp>2</pdp>
80
+ <invoice_qty>0</invoice_qty>
81
+ <order_qty>1</order_qty>
82
+ <discount_price>119.95</discount_price>
83
+ <line_tax>0</line_tax>
84
+ <discount_rate>30</discount_rate>
85
+ <discount_reason>210</discount_reason>
86
+ <current_rrp_inc>149.95</current_rrp_inc>
87
+ </stock>
88
+ <debtor>
89
+ <payment_type>4</payment_type>
90
+ <payment_amount>119.95</payment_amount>
91
+ <invoice_price_inc>0</invoice_price_inc>
92
+ <rounding>0</rounding>
93
+ <total_tax>0</total_tax>
94
+ <card_name>PPAL</card_name>
95
+ <card_no>ABC123</card_no>
96
+ <card_expiry_month>0</card_expiry_month>
97
+ <card_expiry_year>0</card_expiry_year>
98
+ <cash_drawer_id>ABC1</cash_drawer_id>
99
+ <reservation_history_no>0</reservation_history_no>
100
+ </debtor>
101
+ </${ServiceAlias.POINT_OF_SALE}:ProcessSalesOrderRequest>
102
+ </${ns}:Body>
103
+ </${ns}:Envelope>
104
+ `;
105
+ const params = {
106
+ mode: PosQueryMode.UPDATE,
107
+ auditNo: "106942",
108
+ header: {
109
+ orderNo: "W00106943",
110
+ customerOrderNo: "W00106943",
111
+ transactionDate: "02-06-2015",
112
+ transactionTimeHour: 11,
113
+ transactionTimeMin: 52,
114
+ transactionTimeSec: 0,
115
+ shopDebtor: "ABC",
116
+ diary: "0005353",
117
+ diaryName1: "AMMY",
118
+ diaryName2: "WHITE",
119
+ warehouse: "WEB",
120
+ agentZone1: 1111,
121
+ terminalId: "online",
122
+ user: "WEB",
123
+ orderLines: 0,
124
+ orderDepositTotal: 119.95,
125
+ orderVersion: 0,
126
+ originatorSoftware: "WEB",
127
+ accountSaleFlag: AccountSaleFlag.YES,
128
+ },
129
+ stock: [
130
+ {
131
+ stock: "7281VL.100",
132
+ stockDescription: "3/4 SLV CROSS OVER DRESS W/ TUCKS",
133
+ size: "S",
134
+ qdp: 0,
135
+ pdp: 2,
136
+ invoiceQty: 0.0,
137
+ orderQty: 1.0,
138
+ discountPrice: 119.95,
139
+ lineTax: 0.0,
140
+ discountRate: 30.0,
141
+ discountReason: "210",
142
+ currentRrpInc: 149.95,
143
+ },
144
+ ],
145
+ extra: {
146
+ deliveryAddress1: "37",
147
+ deliveryAddress2: "HOTHAM ST",
148
+ deliveryAddress3: "ST KILDA EAST",
149
+ deliveryAddress4: "VIC",
150
+ deliveryPostcode: "3111",
151
+ deliveryInstruction1: "Enter backdoor",
152
+ deliveryInstruction2: "Then frontdoor",
153
+ telephoneHome: "0444888885",
154
+ telephoneMobile: "0444888884",
155
+ telephoneWork: "0444888883",
156
+ email: "test@example.com",
157
+ billingAddress1: "37",
158
+ billingAddress2: "HOTHAM ST",
159
+ billingAddress3: "ST KILDA EAST",
160
+ billingAddress4: "VIC",
161
+ billingPostcode: "3111",
162
+ billingFirstname: "JOHN",
163
+ billingSurname: "DOE",
164
+ billingTelephoneHome: "0444888888",
165
+ billingTelephoneMobile: "0444888887",
166
+ billingTelephoneWork: "0444888886",
167
+ carrier: "APOST",
168
+ customisedInfo: "CUSTOM",
169
+ },
170
+ debtor: [
171
+ {
172
+ paymentType: PosPaymentType.CARD,
173
+ paymentAmount: 119.95,
174
+ invoicePriceInc: 0.0,
175
+ rounding: 0.0,
176
+ totalTax: 0.0,
177
+ cardName: "PPAL",
178
+ cardNo: "ABC123",
179
+ cardExpiryMonth: 0,
180
+ cardExpiryYear: 0,
181
+ cashDrawerId: "ABC1",
182
+ reservationHistoryNo: 0,
183
+ },
184
+ ],
185
+ };
186
+ const mockedResp = `
187
+ <?xml version='1.0' encoding='UTF-8'?>
188
+ <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
189
+ <S:Body><ns2:ProcessSalesOrderResponse xmlns:ns2="http://pos.ws.fbsaust.com.au">
190
+ <result>true</result>
191
+ </ns2:ProcessSalesOrderResponse></S:Body>
192
+ </S:Envelope>
193
+ `;
194
+ const expectedResult = true;
195
+ mAxios.post.mockResolvedValueOnce({ data: mockedResp });
196
+ const response = await posModule.processSalesOrder(params, token);
197
+ // Test that expected response is correct
198
+ expect(typeof response).toEqual("boolean");
199
+ expect(response).toEqual(expectedResult);
200
+ const actualPayload = mAxios.post.mock.calls[0][1];
201
+ // Test that actual payload sent in the API matches expected payload
202
+ expect(Utils.removeEmptySpaces(actualPayload)).toEqual(Utils.removeEmptySpaces(expectedPayload));
203
+ mAxios.post.mockClear();
204
+ });
205
+ });
@@ -0,0 +1,13 @@
1
+ import { LineOperation, PosBaseQueryParams, PosQueryDebtor, PosQueryHeader, PosQueryInvoice, ProcessSaleOrderQueryStock } from ".";
2
+ export interface CancelExistingSalesOrderExistingSalesOrderQueryParams extends PosBaseQueryParams {
3
+ header: CancelExistingSalesOrderQueryHeader;
4
+ stock: CancelExistingSalesOrderQueryStock[];
5
+ debtor?: CancelExistingSalesOrderDebtor[];
6
+ }
7
+ export interface CancelExistingSalesOrderQueryHeader extends PosQueryHeader {
8
+ orderNo: string;
9
+ }
10
+ export interface CancelExistingSalesOrderQueryStock extends ProcessSaleOrderQueryStock {
11
+ lineOperation: LineOperation;
12
+ }
13
+ export type CancelExistingSalesOrderDebtor = PosQueryInvoice & PosQueryDebtor;
@@ -0,0 +1,124 @@
1
+ export * from "./cancel-existing-sales-order.interface";
2
+ export * from "./modify-existing-sales-order.interface";
3
+ export * from "./process-returns.interface";
4
+ export * from "./process-sale-order.interface";
5
+ export interface PosBaseQueryParams {
6
+ mode?: PosQueryMode;
7
+ auditNo: string;
8
+ exportNo?: string;
9
+ }
10
+ export interface PosQueryHeader {
11
+ customerOrderNo?: string;
12
+ transactionDate: string;
13
+ transactionTimeHour: number;
14
+ transactionTimeMin: number;
15
+ transactionTimeSec: number;
16
+ shopDebtor: string;
17
+ diary?: string;
18
+ diaryName1?: string;
19
+ diaryName2?: string;
20
+ warehouse: string;
21
+ originatedWarehouse?: string;
22
+ agentZone1: number;
23
+ agentZone2?: number;
24
+ agentZone3?: number;
25
+ terminalId: string;
26
+ orderClass?: string;
27
+ user: string;
28
+ comment1?: string;
29
+ comment2?: string;
30
+ comment3?: string;
31
+ comment4?: string;
32
+ comment5?: string;
33
+ comment6?: string;
34
+ comment7?: string;
35
+ comment8?: string;
36
+ comment9?: string;
37
+ comment10?: string;
38
+ orderTaxExemption?: OrderTaxExemption;
39
+ originatorSoftware: string;
40
+ accountSaleFlag: AccountSaleFlag;
41
+ }
42
+ export interface PosQueryExtra {
43
+ email: string;
44
+ telephoneHome?: string;
45
+ telephoneMobile?: string;
46
+ telephoneWork?: string;
47
+ billingSurname?: string;
48
+ billingFirstname?: string;
49
+ billingAddress1?: string;
50
+ billingAddress2?: string;
51
+ billingAddress3?: string;
52
+ billingAddress4?: string;
53
+ billingPostcode?: string;
54
+ billingTelephoneHome?: string;
55
+ billingTelephoneMobile?: string;
56
+ billingTelephoneWork?: string;
57
+ customisedInfo?: string;
58
+ }
59
+ export interface PosQueryStock {
60
+ /**
61
+ * Stock namekey of the item
62
+ *
63
+ * @type {string}
64
+ */
65
+ stock: string;
66
+ stockDescription?: string;
67
+ size?: string;
68
+ qdp: number;
69
+ pdp: number;
70
+ discountPrice: number;
71
+ lineTax?: number;
72
+ discountRate?: number;
73
+ discountReason?: string;
74
+ creditNoteReason?: string;
75
+ serialNo?: string;
76
+ comment?: string;
77
+ creditNoteReference?: string;
78
+ currentRrpInc: number;
79
+ per?: string;
80
+ singlesPerPack?: string;
81
+ packsPerCarton?: string;
82
+ sizePackName?: string;
83
+ }
84
+ export interface PosQueryDebtor {
85
+ paymentType: PosPaymentType;
86
+ creditReference?: string;
87
+ paymentAmount: number;
88
+ cardName?: string;
89
+ cardNo?: string;
90
+ cardHolder?: string;
91
+ cardExpiryMonth?: number;
92
+ cardExpiryYear?: number;
93
+ comment?: string;
94
+ giftVoucherStock?: string;
95
+ giftVoucherSerialNo?: string;
96
+ reservationHistoryNo?: number;
97
+ }
98
+ export interface PosQueryInvoice {
99
+ invoicePriceInc?: number;
100
+ rounding?: number;
101
+ totalTax?: number;
102
+ cashDrawerId: string;
103
+ }
104
+ export declare enum PosPaymentType {
105
+ CARD = "4",
106
+ GIFT_VOUCHER = "6",
107
+ POLI = "11"
108
+ }
109
+ export declare enum PosQueryMode {
110
+ UPDATE = "U",
111
+ TEST_UPDATE = "T"
112
+ }
113
+ export declare enum OrderTaxExemption {
114
+ EXPORT = "EXPORT",
115
+ BLANK = ""
116
+ }
117
+ export declare enum AccountSaleFlag {
118
+ YES = "Y",
119
+ NO = ""
120
+ }
121
+ export declare enum LineOperation {
122
+ ADD = "A",
123
+ DELETE = "D"
124
+ }
@@ -0,0 +1,31 @@
1
+ export * from "./cancel-existing-sales-order.interface";
2
+ export * from "./modify-existing-sales-order.interface";
3
+ export * from "./process-returns.interface";
4
+ export * from "./process-sale-order.interface";
5
+ export var PosPaymentType;
6
+ (function (PosPaymentType) {
7
+ PosPaymentType["CARD"] = "4";
8
+ PosPaymentType["GIFT_VOUCHER"] = "6";
9
+ PosPaymentType["POLI"] = "11";
10
+ })(PosPaymentType || (PosPaymentType = {}));
11
+ export var PosQueryMode;
12
+ (function (PosQueryMode) {
13
+ PosQueryMode["UPDATE"] = "U";
14
+ PosQueryMode["TEST_UPDATE"] = "T";
15
+ })(PosQueryMode || (PosQueryMode = {}));
16
+ export var OrderTaxExemption;
17
+ (function (OrderTaxExemption) {
18
+ OrderTaxExemption["EXPORT"] = "EXPORT";
19
+ OrderTaxExemption["BLANK"] = "";
20
+ })(OrderTaxExemption || (OrderTaxExemption = {}));
21
+ export var AccountSaleFlag;
22
+ (function (AccountSaleFlag) {
23
+ //If the sale is on account, set to Y otherwise leave blank
24
+ AccountSaleFlag["YES"] = "Y";
25
+ AccountSaleFlag["NO"] = "";
26
+ })(AccountSaleFlag || (AccountSaleFlag = {}));
27
+ export var LineOperation;
28
+ (function (LineOperation) {
29
+ LineOperation["ADD"] = "A";
30
+ LineOperation["DELETE"] = "D";
31
+ })(LineOperation || (LineOperation = {}));
@@ -0,0 +1,12 @@
1
+ import { LineOperation, PosBaseQueryParams, PosQueryDebtor, PosQueryHeader, PosQueryInvoice, PosQueryStock, ProcessSaleOrderQueryExtra } from ".";
2
+ export interface ModifyExistingSalesOrderQueryParams extends PosBaseQueryParams {
3
+ header: PosQueryHeader;
4
+ extra?: ProcessSaleOrderQueryExtra;
5
+ stock: ModifyExistingSalesOrderQueryStock[];
6
+ debtor?: ModifyExistingSalesOrderDebtor[];
7
+ }
8
+ export interface ModifyExistingSalesOrderQueryStock extends PosQueryStock {
9
+ lineOperation: LineOperation;
10
+ dispatchDate?: string;
11
+ }
12
+ export type ModifyExistingSalesOrderDebtor = PosQueryInvoice & PosQueryDebtor;
@@ -0,0 +1,17 @@
1
+ import { PosBaseQueryParams, PosQueryDebtor, PosQueryExtra, PosQueryHeader, PosQueryInvoice, PosQueryStock } from ".";
2
+ export interface ProcessReturnsQueryParams extends PosBaseQueryParams {
3
+ header: ProcessReturnsQueryHeader;
4
+ extra?: ProcessReturnsQueryExtra;
5
+ stock: ProcessReturnsQueryStock[];
6
+ invoice: ProcessReturnsQueryInvoice;
7
+ debtor?: ProcessReturnsQueryDebtor[];
8
+ }
9
+ export interface ProcessReturnsQueryHeader extends PosQueryHeader {
10
+ creditNo: string;
11
+ }
12
+ export interface ProcessReturnsQueryStock extends PosQueryStock {
13
+ returnQty?: number;
14
+ }
15
+ export type ProcessReturnsQueryExtra = PosQueryExtra;
16
+ export type ProcessReturnsQueryInvoice = PosQueryInvoice;
17
+ export type ProcessReturnsQueryDebtor = PosQueryDebtor;