@dotdev/harmony-sdk 1.6.2 → 1.7.0
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.
- package/dist/HarmonyAPI.d.ts +1 -0
- package/dist/HarmonyAPI.js +3 -0
- package/dist/modules/point-of-sale/mappings/process-sale-order.mapper.d.ts +10 -1
- package/dist/modules/point-of-sale/mappings/process-sale-order.mapper.js +10 -2
- package/dist/modules/point-of-sale/point-of-sale.module.d.ts +10 -1
- package/dist/modules/point-of-sale/point-of-sale.module.js +19 -1
- package/dist/modules/point-of-sale/point-of-sale.module.spec.js +161 -0
- package/dist/modules/point-of-sale/types/process-sale-order.interface.d.ts +4 -2
- package/package.json +1 -1
package/dist/HarmonyAPI.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare class HarmonyAPI {
|
|
|
23
23
|
stockLevelLookup(params: StockLevelLookupQueryParams, sessionId: string): Promise<StockLevel[]>;
|
|
24
24
|
stockLevelLookupByWarehouseQuickView(params: StockLevelLookupQueryParams, sessionId: string): Promise<StockLevel[]>;
|
|
25
25
|
processSalesOrder(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<boolean>;
|
|
26
|
+
processSalesOrderWithoutPayment(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<boolean>;
|
|
26
27
|
mapOrderPayloadToXml(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<string>;
|
|
27
28
|
processReturns(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<boolean>;
|
|
28
29
|
modifyExistingSalesOrder(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<boolean>;
|
package/dist/HarmonyAPI.js
CHANGED
|
@@ -83,6 +83,9 @@ export class HarmonyAPI {
|
|
|
83
83
|
async processSalesOrder(params, sessionId) {
|
|
84
84
|
return await this.pointOfSaleModule.processSalesOrder(params, sessionId);
|
|
85
85
|
}
|
|
86
|
+
async processSalesOrderWithoutPayment(params, sessionId) {
|
|
87
|
+
return await this.pointOfSaleModule.processSalesOrderWithoutPayment(params, sessionId);
|
|
88
|
+
}
|
|
86
89
|
async mapOrderPayloadToXml(params, sessionId) {
|
|
87
90
|
return await this.pointOfSaleModule.mapOrderPayloadToXml(params, sessionId);
|
|
88
91
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { ProcessSaleOrderQueryDebtor, ProcessSaleOrderQueryExtra, ProcessSaleOrderQueryHeader, ProcessSaleOrderQueryParams, ProcessSaleOrderQueryStock } from "../types";
|
|
1
|
+
import { ProcessSaleOrderQueryDebtor, ProcessSaleOrderQueryExtra, ProcessSaleOrderQueryHeader, ProcessSaleOrderQueryParams, ProcessSaleOrderQueryStock, ProcessSaleOrderWithoutPaymentQueryParams } from "../types";
|
|
2
2
|
export declare function mapProcessSaleOrderQueryParams(params: ProcessSaleOrderQueryParams): string;
|
|
3
|
+
export declare function mapProcessSaleOrderWithoutPaymentQueryParams(params: ProcessSaleOrderWithoutPaymentQueryParams): string;
|
|
4
|
+
export declare function mapProcessSaleOrderBaseQueryParams(params: ProcessSaleOrderWithoutPaymentQueryParams): {
|
|
5
|
+
mode: import("../types").PosQueryMode | undefined;
|
|
6
|
+
audit_no: string;
|
|
7
|
+
export_no: string | undefined;
|
|
8
|
+
header: string;
|
|
9
|
+
extra: string;
|
|
10
|
+
stock: string[];
|
|
11
|
+
};
|
|
3
12
|
export declare function mapProcessSaleOrderQueryHeaders(params: ProcessSaleOrderQueryHeader): string;
|
|
4
13
|
export declare function mapProcessSaleOrderQueryExtra(params: ProcessSaleOrderQueryExtra): string;
|
|
5
14
|
export declare function mapProcessSaleOrderQueryStock(params: ProcessSaleOrderQueryStock): string;
|
|
@@ -2,15 +2,23 @@ import { Utils } from "../../../helpers";
|
|
|
2
2
|
export function mapProcessSaleOrderQueryParams(params) {
|
|
3
3
|
// XML body in JSON format, to be converted to XML string
|
|
4
4
|
const body = {
|
|
5
|
+
...mapProcessSaleOrderBaseQueryParams(params),
|
|
6
|
+
debtor: mapProcessSaleOrderQueryDebtor((params?.debtor ?? [])[0]),
|
|
7
|
+
};
|
|
8
|
+
return Utils.toXml(Utils.deleteEmptyProps(body));
|
|
9
|
+
}
|
|
10
|
+
export function mapProcessSaleOrderWithoutPaymentQueryParams(params) {
|
|
11
|
+
return Utils.toXml(Utils.deleteEmptyProps(mapProcessSaleOrderBaseQueryParams(params)));
|
|
12
|
+
}
|
|
13
|
+
export function mapProcessSaleOrderBaseQueryParams(params) {
|
|
14
|
+
return {
|
|
5
15
|
mode: params?.mode,
|
|
6
16
|
audit_no: params?.auditNo,
|
|
7
17
|
export_no: params?.exportNo,
|
|
8
18
|
header: mapProcessSaleOrderQueryHeaders(params?.header),
|
|
9
19
|
extra: mapProcessSaleOrderQueryExtra(params?.extra),
|
|
10
20
|
stock: params?.stock.map(mapProcessSaleOrderQueryStock),
|
|
11
|
-
debtor: mapProcessSaleOrderQueryDebtor((params?.debtor ?? [])[0]),
|
|
12
21
|
};
|
|
13
|
-
return Utils.toXml(Utils.deleteEmptyProps(body));
|
|
14
22
|
}
|
|
15
23
|
export function mapProcessSaleOrderQueryHeaders(params) {
|
|
16
24
|
// XML body in JSON format, to be converted to XML string
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { ProcessSaleOrderQueryParams } from "./types";
|
|
2
|
+
import { ProcessSaleOrderQueryParams, ProcessSaleOrderWithoutPaymentQueryParams } from "./types";
|
|
3
3
|
export declare class PointOfSaleModule {
|
|
4
4
|
private axiosInstance;
|
|
5
5
|
private readonly SERVICE_URL;
|
|
@@ -22,6 +22,15 @@ export declare class PointOfSaleModule {
|
|
|
22
22
|
* @param {string} sessionId
|
|
23
23
|
*/
|
|
24
24
|
mapOrderPayloadToXml(params: ProcessSaleOrderQueryParams, sessionId: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Function to call the ProcessSalesOrderWithoutPayment endpoint in Harmony Point Of Sale service
|
|
27
|
+
*
|
|
28
|
+
* @async
|
|
29
|
+
* @param {ProcessSaleOrderQueryParams} params
|
|
30
|
+
* @param {string} sessionId
|
|
31
|
+
* @returns {Promise<boolean>}
|
|
32
|
+
*/
|
|
33
|
+
processSalesOrderWithoutPayment(params: ProcessSaleOrderWithoutPaymentQueryParams, sessionId: string): Promise<boolean>;
|
|
25
34
|
/**
|
|
26
35
|
* Function to call the ProcessReturns endpoint in Harmony Point Of Sale service
|
|
27
36
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiHelper, Utils } from "../../helpers";
|
|
2
2
|
import { ServiceAlias } from "../shared";
|
|
3
|
-
import { mapProcessSaleOrderQueryDebtor, mapProcessSaleOrderQueryExtra, mapProcessSaleOrderQueryHeaders, mapProcessSaleOrderQueryParams, mapProcessSaleOrderQueryStock, } from "./mappings/process-sale-order.mapper";
|
|
3
|
+
import { mapProcessSaleOrderQueryDebtor, mapProcessSaleOrderQueryExtra, mapProcessSaleOrderQueryHeaders, mapProcessSaleOrderQueryParams, mapProcessSaleOrderQueryStock, mapProcessSaleOrderWithoutPaymentQueryParams, } from "./mappings/process-sale-order.mapper";
|
|
4
4
|
import { promisify } from "util";
|
|
5
5
|
import { parseString } from "xml2js";
|
|
6
6
|
const parseXml = promisify(parseString);
|
|
@@ -70,6 +70,24 @@ export class PointOfSaleModule {
|
|
|
70
70
|
const parsedJson = await parseXml(fullXml);
|
|
71
71
|
return Utils.objectToXml(parsedJson);
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Function to call the ProcessSalesOrderWithoutPayment endpoint in Harmony Point Of Sale service
|
|
75
|
+
*
|
|
76
|
+
* @async
|
|
77
|
+
* @param {ProcessSaleOrderQueryParams} params
|
|
78
|
+
* @param {string} sessionId
|
|
79
|
+
* @returns {Promise<boolean>}
|
|
80
|
+
*/
|
|
81
|
+
async processSalesOrderWithoutPayment(params, sessionId) {
|
|
82
|
+
try {
|
|
83
|
+
const requestBody = mapProcessSaleOrderWithoutPaymentQueryParams(params);
|
|
84
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, ["ProcessSalesOrderWithoutPayment", "Request"], sessionId, ServiceAlias.POINT_OF_SALE, this.axiosInstance, requestBody);
|
|
85
|
+
return Boolean(response?.result[0] ?? "false");
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
throw await ApiHelper.parseError(error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
73
91
|
/**
|
|
74
92
|
* Function to call the ProcessReturns endpoint in Harmony Point Of Sale service
|
|
75
93
|
*
|
|
@@ -202,4 +202,165 @@ describe("PointOfSaleModule", () => {
|
|
|
202
202
|
expect(Utils.removeEmptySpaces(actualPayload)).toEqual(Utils.removeEmptySpaces(expectedPayload));
|
|
203
203
|
mAxios.post.mockClear();
|
|
204
204
|
});
|
|
205
|
+
test("ProcessSaleOrderWithoutPayment should process the order correctly and return response", async () => {
|
|
206
|
+
const token = "test-token";
|
|
207
|
+
const ns = "S";
|
|
208
|
+
const expectedPayload = `
|
|
209
|
+
<${ns}:Envelope xmlns:${ns}="http://schemas.xmlsoap.org/soap/envelope/" xmlns:${ServiceAlias.POINT_OF_SALE}="http://${ServiceAlias.POINT_OF_SALE}.ws.fbsaust.com.au">
|
|
210
|
+
<${ns}:Header>
|
|
211
|
+
<${ServiceAlias.POINT_OF_SALE}:SessionId>${token}</${ServiceAlias.POINT_OF_SALE}:SessionId>
|
|
212
|
+
</${ns}:Header>
|
|
213
|
+
<${ns}:Body>
|
|
214
|
+
<${ServiceAlias.POINT_OF_SALE}:ProcessSalesOrderWithoutPaymentRequest >
|
|
215
|
+
<mode>U</mode>
|
|
216
|
+
<audit_no>106942</audit_no>
|
|
217
|
+
<header>
|
|
218
|
+
<order_no>W00106943</order_no>
|
|
219
|
+
<customer_order_no>W00106943</customer_order_no>
|
|
220
|
+
<transaction_date>02-06-2015</transaction_date>
|
|
221
|
+
<transaction_time_hour>11</transaction_time_hour>
|
|
222
|
+
<transaction_time_min>52</transaction_time_min>
|
|
223
|
+
<transaction_time_sec>0</transaction_time_sec>
|
|
224
|
+
<shop_debtor>ABC</shop_debtor>
|
|
225
|
+
<diary>0005353</diary>
|
|
226
|
+
<diary_name_1>AMMY</diary_name_1>
|
|
227
|
+
<diary_name_2>WHITE</diary_name_2>
|
|
228
|
+
<warehouse>WEB</warehouse>
|
|
229
|
+
<agent_zone_1>1111</agent_zone_1>
|
|
230
|
+
<terminal_id>online</terminal_id>
|
|
231
|
+
<user>WEB</user>
|
|
232
|
+
<order_lines>0</order_lines>
|
|
233
|
+
<order_deposit_total>119.95</order_deposit_total>
|
|
234
|
+
<order_version>0</order_version>
|
|
235
|
+
<originator_software>WEB</originator_software>
|
|
236
|
+
<account_sale_flag>Y</account_sale_flag>
|
|
237
|
+
</header>
|
|
238
|
+
<extra>
|
|
239
|
+
<delivery_address_1>37</delivery_address_1>
|
|
240
|
+
<delivery_address_2>HOTHAM ST</delivery_address_2>
|
|
241
|
+
<delivery_address_3>ST KILDA EAST</delivery_address_3>
|
|
242
|
+
<delivery_address_4>VIC</delivery_address_4>
|
|
243
|
+
<delivery_postcode>3111</delivery_postcode>
|
|
244
|
+
<delivery_instruction_1>Enter backdoor</delivery_instruction_1>
|
|
245
|
+
<delivery_instruction_2>Then frontdoor</delivery_instruction_2>
|
|
246
|
+
<carrier>APOST</carrier>
|
|
247
|
+
<email>test@example.com</email>
|
|
248
|
+
<telephone_home>0444888885</telephone_home>
|
|
249
|
+
<telephone_mobile>0444888884</telephone_mobile>
|
|
250
|
+
<telephone_work>0444888883</telephone_work>
|
|
251
|
+
<billing_surname>DOE</billing_surname>
|
|
252
|
+
<billing_first_name>JOHN</billing_first_name>
|
|
253
|
+
<billing_address_1>37</billing_address_1>
|
|
254
|
+
<billing_address_2>HOTHAM ST</billing_address_2>
|
|
255
|
+
<billing_address_3>ST KILDA EAST</billing_address_3>
|
|
256
|
+
<billing_address_4>VIC</billing_address_4>
|
|
257
|
+
<billing_postcode>3111</billing_postcode>
|
|
258
|
+
<billing_telephone_home>0444888888</billing_telephone_home>
|
|
259
|
+
<billing_telephone_mobile>0444888887</billing_telephone_mobile>
|
|
260
|
+
<billing_telephone_work>0444888886</billing_telephone_work>
|
|
261
|
+
<customised_info>CUSTOM</customised_info>
|
|
262
|
+
</extra>
|
|
263
|
+
<stock>
|
|
264
|
+
<stock>7281VL.100</stock>
|
|
265
|
+
<stock_description>3/4 SLV CROSS OVER DRESS W/ TUCKS</stock_description>
|
|
266
|
+
<size>S</size>
|
|
267
|
+
<qdp>0</qdp>
|
|
268
|
+
<pdp>2</pdp>
|
|
269
|
+
<invoice_qty>0</invoice_qty>
|
|
270
|
+
<order_qty>1</order_qty>
|
|
271
|
+
<discount_price>119.95</discount_price>
|
|
272
|
+
<line_tax>0</line_tax>
|
|
273
|
+
<discount_rate>30</discount_rate>
|
|
274
|
+
<discount_reason>210</discount_reason>
|
|
275
|
+
<current_rrp_inc>149.95</current_rrp_inc>
|
|
276
|
+
</stock>
|
|
277
|
+
</${ServiceAlias.POINT_OF_SALE}:ProcessSalesOrderWithoutPaymentRequest>
|
|
278
|
+
</${ns}:Body>
|
|
279
|
+
</${ns}:Envelope>
|
|
280
|
+
`;
|
|
281
|
+
const params = {
|
|
282
|
+
mode: PosQueryMode.UPDATE,
|
|
283
|
+
auditNo: "106942",
|
|
284
|
+
header: {
|
|
285
|
+
orderNo: "W00106943",
|
|
286
|
+
customerOrderNo: "W00106943",
|
|
287
|
+
transactionDate: "02-06-2015",
|
|
288
|
+
transactionTimeHour: 11,
|
|
289
|
+
transactionTimeMin: 52,
|
|
290
|
+
transactionTimeSec: 0,
|
|
291
|
+
shopDebtor: "ABC",
|
|
292
|
+
diary: "0005353",
|
|
293
|
+
diaryName1: "AMMY",
|
|
294
|
+
diaryName2: "WHITE",
|
|
295
|
+
warehouse: "WEB",
|
|
296
|
+
agentZone1: 1111,
|
|
297
|
+
terminalId: "online",
|
|
298
|
+
user: "WEB",
|
|
299
|
+
orderLines: 0,
|
|
300
|
+
orderDepositTotal: 119.95,
|
|
301
|
+
orderVersion: 0,
|
|
302
|
+
originatorSoftware: "WEB",
|
|
303
|
+
accountSaleFlag: AccountSaleFlag.YES,
|
|
304
|
+
},
|
|
305
|
+
stock: [
|
|
306
|
+
{
|
|
307
|
+
stock: "7281VL.100",
|
|
308
|
+
stockDescription: "3/4 SLV CROSS OVER DRESS W/ TUCKS",
|
|
309
|
+
size: "S",
|
|
310
|
+
qdp: 0,
|
|
311
|
+
pdp: 2,
|
|
312
|
+
invoiceQty: 0.0,
|
|
313
|
+
orderQty: 1.0,
|
|
314
|
+
discountPrice: 119.95,
|
|
315
|
+
lineTax: 0.0,
|
|
316
|
+
discountRate: 30.0,
|
|
317
|
+
discountReason: "210",
|
|
318
|
+
currentRrpInc: 149.95,
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
extra: {
|
|
322
|
+
deliveryAddress1: "37",
|
|
323
|
+
deliveryAddress2: "HOTHAM ST",
|
|
324
|
+
deliveryAddress3: "ST KILDA EAST",
|
|
325
|
+
deliveryAddress4: "VIC",
|
|
326
|
+
deliveryPostcode: "3111",
|
|
327
|
+
deliveryInstruction1: "Enter backdoor",
|
|
328
|
+
deliveryInstruction2: "Then frontdoor",
|
|
329
|
+
telephoneHome: "0444888885",
|
|
330
|
+
telephoneMobile: "0444888884",
|
|
331
|
+
telephoneWork: "0444888883",
|
|
332
|
+
email: "test@example.com",
|
|
333
|
+
billingAddress1: "37",
|
|
334
|
+
billingAddress2: "HOTHAM ST",
|
|
335
|
+
billingAddress3: "ST KILDA EAST",
|
|
336
|
+
billingAddress4: "VIC",
|
|
337
|
+
billingPostcode: "3111",
|
|
338
|
+
billingFirstname: "JOHN",
|
|
339
|
+
billingSurname: "DOE",
|
|
340
|
+
billingTelephoneHome: "0444888888",
|
|
341
|
+
billingTelephoneMobile: "0444888887",
|
|
342
|
+
billingTelephoneWork: "0444888886",
|
|
343
|
+
carrier: "APOST",
|
|
344
|
+
customisedInfo: "CUSTOM",
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
const mockedResp = `
|
|
348
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
349
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
|
350
|
+
<S:Body><ns2:ProcessSalesOrderWithoutPaymentResponse xmlns:ns2="http://pos.ws.fbsaust.com.au">
|
|
351
|
+
<result>true</result>
|
|
352
|
+
</ns2:ProcessSalesOrderWithoutPaymentResponse></S:Body>
|
|
353
|
+
</S:Envelope>
|
|
354
|
+
`;
|
|
355
|
+
const expectedResult = true;
|
|
356
|
+
mAxios.post.mockResolvedValueOnce({ data: mockedResp });
|
|
357
|
+
const response = await posModule.processSalesOrderWithoutPayment(params, token);
|
|
358
|
+
// Test that expected response is correct
|
|
359
|
+
expect(typeof response).toEqual("boolean");
|
|
360
|
+
expect(response).toEqual(expectedResult);
|
|
361
|
+
const actualPayload = mAxios.post.mock.calls[0][1];
|
|
362
|
+
// Test that actual payload sent in the API matches expected payload
|
|
363
|
+
expect(Utils.removeEmptySpaces(actualPayload)).toEqual(Utils.removeEmptySpaces(expectedPayload));
|
|
364
|
+
mAxios.post.mockClear();
|
|
365
|
+
});
|
|
205
366
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { PosBaseQueryParams, PosQueryDebtor, PosQueryExtra, PosQueryHeader, PosQueryInvoice, PosQueryStock } from ".";
|
|
2
2
|
import { BooleanResponse } from "../../shared";
|
|
3
|
-
export interface ProcessSaleOrderQueryParams extends
|
|
3
|
+
export interface ProcessSaleOrderQueryParams extends ProcessSaleOrderWithoutPaymentQueryParams {
|
|
4
|
+
debtor: ProcessSaleOrderQueryDebtor[];
|
|
5
|
+
}
|
|
6
|
+
export interface ProcessSaleOrderWithoutPaymentQueryParams extends PosBaseQueryParams {
|
|
4
7
|
header: ProcessSaleOrderQueryHeader;
|
|
5
8
|
extra: ProcessSaleOrderQueryExtra;
|
|
6
9
|
stock: ProcessSaleOrderQueryStock[];
|
|
7
|
-
debtor: ProcessSaleOrderQueryDebtor[];
|
|
8
10
|
}
|
|
9
11
|
export interface ProcessSaleOrderQueryHeader extends PosQueryHeader {
|
|
10
12
|
invoiceNo?: string;
|