@things-factory/integration-accounting 4.3.123 → 4.3.135
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-server/controllers/accounting-api/index.js +35 -0
- package/dist-server/controllers/accounting-api/index.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/goods-received/create-goods-received-note.js +4 -3
- package/dist-server/controllers/xilnex/apis/goods-received/create-goods-received-note.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/index.js +1 -0
- package/dist-server/controllers/xilnex/apis/index.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/purchase-order/cancel-purchase-order.js +22 -0
- package/dist-server/controllers/xilnex/apis/purchase-order/cancel-purchase-order.js.map +1 -0
- package/dist-server/controllers/xilnex/apis/purchase-order/create-purchase-receive.js +45 -0
- package/dist-server/controllers/xilnex/apis/purchase-order/create-purchase-receive.js.map +1 -0
- package/dist-server/controllers/xilnex/apis/purchase-order/get-purchase-order.js +12 -6
- package/dist-server/controllers/xilnex/apis/purchase-order/get-purchase-order.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/purchase-order/index.js +2 -0
- package/dist-server/controllers/xilnex/apis/purchase-order/index.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/sales-order/create-sales-order.js +13 -0
- package/dist-server/controllers/xilnex/apis/sales-order/create-sales-order.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/sales-return/create-sales-return.js +7 -2
- package/dist-server/controllers/xilnex/apis/sales-return/create-sales-return.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/shipment/create-shipment.js +3 -3
- package/dist-server/controllers/xilnex/apis/shipment/create-shipment.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/stock-request/get-stock-request.js +32 -1
- package/dist-server/controllers/xilnex/apis/stock-request/get-stock-request.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/stocks/create-stock-adjust-record.js +12 -16
- package/dist-server/controllers/xilnex/apis/stocks/create-stock-adjust-record.js.map +1 -1
- package/dist-server/controllers/xilnex/apis/transfer-note/delivery-transfer-note.js +24 -0
- package/dist-server/controllers/xilnex/apis/transfer-note/delivery-transfer-note.js.map +1 -0
- package/dist-server/controllers/xilnex/apis/transfer-note/get-transfer-note.js +49 -0
- package/dist-server/controllers/xilnex/apis/transfer-note/get-transfer-note.js.map +1 -0
- package/dist-server/controllers/xilnex/apis/transfer-note/index.js +2 -0
- package/dist-server/controllers/xilnex/apis/transfer-note/index.js.map +1 -1
- package/dist-server/controllers/xilnex/xilnex.js +26 -1
- package/dist-server/controllers/xilnex/xilnex.js.map +1 -1
- package/package.json +15 -16
- package/server/controllers/accounting-api/index.ts +15 -0
- package/server/controllers/xilnex/apis/goods-received/create-goods-received-note.ts +4 -3
- package/server/controllers/xilnex/apis/index.ts +1 -0
- package/server/controllers/xilnex/apis/purchase-order/cancel-purchase-order.ts +18 -0
- package/server/controllers/xilnex/apis/purchase-order/create-purchase-receive.ts +43 -0
- package/server/controllers/xilnex/apis/purchase-order/get-purchase-order.ts +12 -6
- package/server/controllers/xilnex/apis/purchase-order/index.ts +2 -0
- package/server/controllers/xilnex/apis/sales-order/create-sales-order.ts +14 -0
- package/server/controllers/xilnex/apis/sales-return/create-sales-return.ts +9 -2
- package/server/controllers/xilnex/apis/shipment/create-shipment.ts +3 -3
- package/server/controllers/xilnex/apis/stock-request/get-stock-request.ts +35 -1
- package/server/controllers/xilnex/apis/stocks/create-stock-adjust-record.ts +12 -16
- package/server/controllers/xilnex/apis/transfer-note/delivery-transfer-note.ts +21 -0
- package/server/controllers/xilnex/apis/transfer-note/get-transfer-note.ts +47 -0
- package/server/controllers/xilnex/apis/transfer-note/index.ts +2 -0
- package/server/controllers/xilnex/xilnex.ts +31 -1
- package/LICENSE.md +0 -21
|
@@ -13,7 +13,7 @@ class Xilnex {
|
|
|
13
13
|
this.config = Object.assign({}, config);
|
|
14
14
|
}
|
|
15
15
|
isValidSignature(data, secret, signature) {
|
|
16
|
-
let hmac = crypto_1.default.createHmac('sha256', secret).update(JSON.stringify(data)).digest('hex');
|
|
16
|
+
let hmac = crypto_1.default.createHmac('sha256', secret).update(JSON.stringify(data)).digest('hex').toUpperCase();
|
|
17
17
|
return hmac === signature;
|
|
18
18
|
}
|
|
19
19
|
async get(path, data) {
|
|
@@ -66,6 +66,31 @@ class Xilnex {
|
|
|
66
66
|
throw new Error(`(${response.status}) ${result}`);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
async put(path, data = {}) {
|
|
70
|
+
const { accessToken, appId } = this.config;
|
|
71
|
+
debug('data', data);
|
|
72
|
+
const jsondata = JSON.stringify(data);
|
|
73
|
+
const endpoint = `${ENDPOINT}${path}`;
|
|
74
|
+
debug('endpoint', endpoint);
|
|
75
|
+
const response = await (0, node_fetch_1.default)(endpoint, {
|
|
76
|
+
method: 'put',
|
|
77
|
+
headers: {
|
|
78
|
+
'Content-Type': 'application/json',
|
|
79
|
+
token: accessToken,
|
|
80
|
+
appid: appId,
|
|
81
|
+
auth: '5'
|
|
82
|
+
},
|
|
83
|
+
body: jsondata
|
|
84
|
+
});
|
|
85
|
+
if (response.ok) {
|
|
86
|
+
const result = await response.json();
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const result = await response.text();
|
|
91
|
+
throw new Error(`(${response.status}) ${result}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
69
94
|
}
|
|
70
95
|
exports.Xilnex = Xilnex;
|
|
71
96
|
//# sourceMappingURL=xilnex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xilnex.js","sourceRoot":"","sources":["../../../server/controllers/xilnex/xilnex.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,4DAA8B;AAE9B,MAAM,QAAQ,GAAG,iCAAiC,CAAA;AAClD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,8CAA8C,CAAC,CAAA;AAQ9E,MAAa,MAAM;IAGjB,YAAY,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A;YACpC,MAAM,IAAI,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC,CAAA;SAClD;IACH,CAAC;CACF;AAvGD,wBAuGC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-accounting",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.135",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
7
|
-
"license": "MIT",
|
|
8
7
|
"author": "heartyoh",
|
|
9
8
|
"description": "Module to manage integration with accounting service.",
|
|
10
9
|
"publishConfig": {
|
|
@@ -25,19 +24,19 @@
|
|
|
25
24
|
"test": "DEBUG=things-factory:* NODE_ENV=development npx mocha -r ts-node/register ./test/**/*spec.ts"
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@things-factory/apptool-ui": "^4.3.
|
|
29
|
-
"@things-factory/auth-ui": "^4.3.
|
|
30
|
-
"@things-factory/biz-base": "^4.3.
|
|
31
|
-
"@things-factory/code-ui": "^4.3.
|
|
32
|
-
"@things-factory/context-ui": "^4.3.
|
|
33
|
-
"@things-factory/grist-ui": "^4.3.
|
|
34
|
-
"@things-factory/i18n-base": "^4.3.
|
|
35
|
-
"@things-factory/integration-ui": "^4.3.
|
|
36
|
-
"@things-factory/more-ui": "^4.3.
|
|
37
|
-
"@things-factory/product-base": "^4.3.
|
|
38
|
-
"@things-factory/resource-ui": "^4.3.
|
|
39
|
-
"@things-factory/setting-ui": "^4.3.
|
|
40
|
-
"@things-factory/system-ui": "^4.3.
|
|
27
|
+
"@things-factory/apptool-ui": "^4.3.131",
|
|
28
|
+
"@things-factory/auth-ui": "^4.3.131",
|
|
29
|
+
"@things-factory/biz-base": "^4.3.131",
|
|
30
|
+
"@things-factory/code-ui": "^4.3.131",
|
|
31
|
+
"@things-factory/context-ui": "^4.3.131",
|
|
32
|
+
"@things-factory/grist-ui": "^4.3.131",
|
|
33
|
+
"@things-factory/i18n-base": "^4.3.131",
|
|
34
|
+
"@things-factory/integration-ui": "^4.3.131",
|
|
35
|
+
"@things-factory/more-ui": "^4.3.131",
|
|
36
|
+
"@things-factory/product-base": "^4.3.131",
|
|
37
|
+
"@things-factory/resource-ui": "^4.3.131",
|
|
38
|
+
"@things-factory/setting-ui": "^4.3.131",
|
|
39
|
+
"@things-factory/system-ui": "^4.3.131",
|
|
41
40
|
"debug": "^4.1.1",
|
|
42
41
|
"node-fetch": "^2.6.0"
|
|
43
42
|
},
|
|
@@ -51,5 +50,5 @@
|
|
|
51
50
|
"nock": "^13.0.2",
|
|
52
51
|
"should": "^13.2.3"
|
|
53
52
|
},
|
|
54
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "55b877e97abb4350a0fa9dceb051c54fd496dcf0"
|
|
55
54
|
}
|
|
@@ -73,6 +73,12 @@ export class AccountingAPI {
|
|
|
73
73
|
@api
|
|
74
74
|
static createGoodsReceivedNote(accounting, req): any {}
|
|
75
75
|
|
|
76
|
+
@api
|
|
77
|
+
static createPurchaseReceive(accounting, req): any {}
|
|
78
|
+
|
|
79
|
+
@api
|
|
80
|
+
static cancelPurchaseOrder(accounting, req): any {}
|
|
81
|
+
|
|
76
82
|
@api
|
|
77
83
|
static createTransferNote(accounting, req): any {}
|
|
78
84
|
|
|
@@ -88,12 +94,21 @@ export class AccountingAPI {
|
|
|
88
94
|
@api
|
|
89
95
|
static createShipment(accounting, req): any {}
|
|
90
96
|
|
|
97
|
+
@api
|
|
98
|
+
static createStockAdjustRecord(accounting, req): any {}
|
|
99
|
+
|
|
100
|
+
@api
|
|
101
|
+
static deliveryTransferNote(accounting, req): any {}
|
|
102
|
+
|
|
91
103
|
@api
|
|
92
104
|
static getPurchaseOrder(accounting, req): any {}
|
|
93
105
|
|
|
94
106
|
@api
|
|
95
107
|
static getStockRequest(accounting, req): any {}
|
|
96
108
|
|
|
109
|
+
@api
|
|
110
|
+
static getTransferNote(accounting, req): any {}
|
|
111
|
+
|
|
97
112
|
@api
|
|
98
113
|
static getSale(accounting, req): any {}
|
|
99
114
|
}
|
|
@@ -6,11 +6,12 @@ export function createGoodsReceivedNote() {
|
|
|
6
6
|
const { arrivalNotice, orderProducts } = req
|
|
7
7
|
let accountInfo: any = accounting?.accountInfo ? JSON.parse(accounting.accountInfo) : {}
|
|
8
8
|
let totalReceivedQuantity = 0
|
|
9
|
+
const curDate: string = new Date().toISOString()
|
|
9
10
|
|
|
10
11
|
let receivedItems: any = orderProducts.map(op => {
|
|
11
12
|
totalReceivedQuantity += op.actualPackQty
|
|
12
13
|
return {
|
|
13
|
-
|
|
14
|
+
itemCode: op.product.sku,
|
|
14
15
|
quantityReceived: op.actualPackQty,
|
|
15
16
|
discountPercentage: 0,
|
|
16
17
|
uniqueId: '',
|
|
@@ -22,7 +23,7 @@ export function createGoodsReceivedNote() {
|
|
|
22
23
|
})
|
|
23
24
|
|
|
24
25
|
let grn: any = {
|
|
25
|
-
receivingDate:
|
|
26
|
+
receivingDate: curDate,
|
|
26
27
|
receiveType: 'Receive',
|
|
27
28
|
receivedStatus: 'Completed',
|
|
28
29
|
remark: arrivalNotice.remark || 'NA',
|
|
@@ -30,7 +31,7 @@ export function createGoodsReceivedNote() {
|
|
|
30
31
|
totalReceivedQuantity: totalReceivedQuantity,
|
|
31
32
|
poNumber: arrivalNotice.refNo,
|
|
32
33
|
invoiceNo: '-',
|
|
33
|
-
invoiceDate:
|
|
34
|
+
invoiceDate: curDate
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
return { payload: { goodsReceive: { ...grn, receivedItems } } }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function cancelPurchaseOrder() {
|
|
2
|
+
return {
|
|
3
|
+
method: 'put',
|
|
4
|
+
path: '/PurchaseOrder/{orderId}/Cancel',
|
|
5
|
+
denormalize(req, { accounting }) {
|
|
6
|
+
const { purchaseOrder } = req
|
|
7
|
+
let accountInfo: any = accounting?.accountInfo ? JSON.parse(accounting.accountInfo) : {}
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
resource: { orderId: parseInt(purchaseOrder.refNo) },
|
|
11
|
+
payload: { purchaseOrder: { cancelOutlet: accountInfo?.outlet || 'MAIN BRANCH', cancelRemark: '-' } }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
normalize(res) {
|
|
15
|
+
return res
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export function createPurchaseReceive() {
|
|
2
|
+
return {
|
|
3
|
+
method: 'post',
|
|
4
|
+
path: '/PurchaseOrder/{orderId}/GRNs',
|
|
5
|
+
denormalize(req, { accounting }) {
|
|
6
|
+
const { arrivalNotice, orderProducts } = req
|
|
7
|
+
const curDate = new Date().toISOString()
|
|
8
|
+
let accountInfo: any = accounting?.accountInfo ? JSON.parse(accounting.accountInfo) : {}
|
|
9
|
+
let totalReceivedQuantity = 0
|
|
10
|
+
|
|
11
|
+
let receivedItems: any = orderProducts.map(op => {
|
|
12
|
+
totalReceivedQuantity += op.actualPackQty
|
|
13
|
+
return {
|
|
14
|
+
itemCode: op.product.sku,
|
|
15
|
+
enterQuantity: op.actualPackQty,
|
|
16
|
+
enterCost: op.unitPrice
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
let purchaseReceive: any = {
|
|
21
|
+
terms: 0,
|
|
22
|
+
postingDate: curDate,
|
|
23
|
+
receiveDate: curDate,
|
|
24
|
+
receivingDate: curDate,
|
|
25
|
+
receivedStatus: 'Completed',
|
|
26
|
+
isUpdateItemCost: false,
|
|
27
|
+
remark: arrivalNotice.remark || 'NA',
|
|
28
|
+
outlet: accountInfo?.outlet || 'MAIN BRANCH',
|
|
29
|
+
poNumber: arrivalNotice.refNo,
|
|
30
|
+
invoiceNo: arrivalNotice.refNo2 || '-',
|
|
31
|
+
invoiceDate: curDate
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
resource: { orderId: parseInt(arrivalNotice.refNo) },
|
|
36
|
+
payload: { purchaseReceive: { ...purchaseReceive, receivedItems } }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
normalize(res) {
|
|
40
|
+
return res
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -12,24 +12,30 @@ export function getPurchaseOrder() {
|
|
|
12
12
|
let poItems: any = purchaseOrder.poItems
|
|
13
13
|
|
|
14
14
|
let orderInfo: any = {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
orderId: purchaseOrder.id,
|
|
16
|
+
fromOutlet: purchaseOrder.submitterOutlet,
|
|
17
|
+
toOutlet: purchaseOrder.producerOutlet,
|
|
17
18
|
etaDate: new Date().toISOString().slice(0, 10),
|
|
18
19
|
ownTransport: true,
|
|
19
20
|
importCargo: false,
|
|
20
21
|
container: false,
|
|
21
|
-
remark: purchaseOrder.remarks
|
|
22
|
+
remark: purchaseOrder.remarks,
|
|
23
|
+
currency: purchaseOrder.currencyCode
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
let orderItems: any = poItems.map(poItem => {
|
|
25
27
|
return {
|
|
28
|
+
refItemId: poItem.id,
|
|
26
29
|
product: {
|
|
27
|
-
|
|
30
|
+
refCode: poItem.itemId,
|
|
31
|
+
sku: poItem.itemCode
|
|
28
32
|
},
|
|
29
33
|
batchId: poItem?.batchNo ? poItem.batchNo : '-',
|
|
30
|
-
|
|
34
|
+
confirmedQty: poItem.enterQuantity,
|
|
35
|
+
unitCost: poItem.enterCost,
|
|
31
36
|
palletQty: null,
|
|
32
|
-
manufactureDate: ''
|
|
37
|
+
manufactureDate: '',
|
|
38
|
+
taxAmount: poItem.taxAmount
|
|
33
39
|
}
|
|
34
40
|
})
|
|
35
41
|
|
|
@@ -10,6 +10,18 @@ export function createSalesOrder() {
|
|
|
10
10
|
client.clientPlatform == releaseGood.platformCode && client.clientCountry == releaseGood.platformCountry
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
+
let discountAmt = releaseGood?.discountAmount
|
|
14
|
+
? parseFloat(releaseGood.discountAmount.toString().replace('-', ''))
|
|
15
|
+
: 0
|
|
16
|
+
let promotionAmt = releaseGood?.promotionAmount || 0
|
|
17
|
+
let taxAmt = releaseGood?.taxAmount || 0
|
|
18
|
+
let shippingFee = releaseGood?.shippingFee || 0
|
|
19
|
+
let paidAmt = releaseGood?.paidAmount || 0
|
|
20
|
+
let totalAmount = paidAmt + shippingFee + taxAmt + promotionAmt + discountAmt
|
|
21
|
+
let discountPercentage = (discountAmt / totalAmount) * 100
|
|
22
|
+
let taxPercentage = (taxAmt / totalAmount) * 100
|
|
23
|
+
taxPercentage = Math.round(taxPercentage * 100) / 100
|
|
24
|
+
|
|
13
25
|
let salesOrder: any = {
|
|
14
26
|
dateTime: new Date(),
|
|
15
27
|
clientId: matchedClient[0]?.clientId || '',
|
|
@@ -32,6 +44,7 @@ export function createSalesOrder() {
|
|
|
32
44
|
confirmOutlet: accountInfo?.outlet || 'MAIN BRANCH',
|
|
33
45
|
remark: releaseGood.remark,
|
|
34
46
|
type: 'InvoiceSales',
|
|
47
|
+
taxPercentage,
|
|
35
48
|
collections: [
|
|
36
49
|
{
|
|
37
50
|
amount: releaseGood?.paidAmount || 0,
|
|
@@ -46,6 +59,7 @@ export function createSalesOrder() {
|
|
|
46
59
|
itemCode: op?.product?.sku,
|
|
47
60
|
enterPrice: op?.sellingPrice / op?.releaseQty,
|
|
48
61
|
quantity: op?.releaseQty
|
|
62
|
+
// discountPercentage
|
|
49
63
|
}
|
|
50
64
|
})
|
|
51
65
|
}
|
|
@@ -5,20 +5,27 @@ export function createSalesReturn() {
|
|
|
5
5
|
denormalize(req, { accounting }) {
|
|
6
6
|
const { releaseGood, orderProducts } = req
|
|
7
7
|
let accountInfo: any = accounting?.accountInfo ? JSON.parse(accounting.accountInfo) : {}
|
|
8
|
+
const matchedClient: any = accountInfo.clients.filter(
|
|
9
|
+
client =>
|
|
10
|
+
client.clientPlatform == releaseGood.platformCode && client.clientCountry == releaseGood.platformCountry
|
|
11
|
+
)
|
|
8
12
|
let sale: any = {
|
|
9
13
|
id: releaseGood?.refNo3,
|
|
10
14
|
dateTime: releaseGood.updatedAt,
|
|
11
15
|
term: 0,
|
|
12
16
|
status: 'CONFIRMED',
|
|
13
17
|
outlet: accountInfo?.outlet || 'MAIN BRANCH',
|
|
14
|
-
|
|
18
|
+
client: {
|
|
19
|
+
id: matchedClient[0]?.clientId
|
|
20
|
+
},
|
|
21
|
+
salesPerson: matchedClient[0]?.clientName,
|
|
15
22
|
recipientContact: releaseGood?.phone1,
|
|
16
23
|
recipientName: releaseGood?.attentionTo,
|
|
17
24
|
items: orderProducts.map(op => {
|
|
18
25
|
return {
|
|
19
26
|
id: op?.refItemId,
|
|
20
27
|
unitPrice: op?.sellingPrice,
|
|
21
|
-
quantity: -op?.
|
|
28
|
+
quantity: -op?.releaseQty,
|
|
22
29
|
deliveryQuantity: 0,
|
|
23
30
|
discountAmount: 0,
|
|
24
31
|
remark: op?.remark,
|
|
@@ -8,15 +8,15 @@ export function createShipment() {
|
|
|
8
8
|
|
|
9
9
|
let shipmentItems: any = orderProducts.map(op => {
|
|
10
10
|
return {
|
|
11
|
-
|
|
11
|
+
documentItemId: op.refItemId,
|
|
12
12
|
shippingQuantity: op.releaseQty
|
|
13
13
|
}
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
let shipment: any = {
|
|
17
17
|
shippingOutlet: accountInfo?.outlet || 'MAIN BRANCH',
|
|
18
|
-
documentId: releaseGood.
|
|
19
|
-
shippingDateTime: new Date()
|
|
18
|
+
documentId: Number(releaseGood.collectionOrderNo),
|
|
19
|
+
shippingDateTime: new Date().toISOString()
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return { payload: { shipment: { ...shipment, shipmentItems } } }
|
|
@@ -9,7 +9,41 @@ export function getStockRequest() {
|
|
|
9
9
|
normalize(res) {
|
|
10
10
|
const { data } = res
|
|
11
11
|
let stockRequest: any = data.stockRequest
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
let orderInfo: any = {
|
|
14
|
+
orderId: stockRequest.id,
|
|
15
|
+
issueDate: stockRequest.issueDate,
|
|
16
|
+
etaDate: stockRequest.ETADate,
|
|
17
|
+
fromLocation: stockRequest.fromLocation,
|
|
18
|
+
toLocation: stockRequest.toLocation,
|
|
19
|
+
issueBy: stockRequest.issueBy,
|
|
20
|
+
status: stockRequest.status,
|
|
21
|
+
cancelledBy: stockRequest.cancelledBy,
|
|
22
|
+
cancelledRemark: stockRequest.cancelledRemark,
|
|
23
|
+
cancelledDate: stockRequest.cancelledDate,
|
|
24
|
+
ownTransport: true,
|
|
25
|
+
importCargo: false,
|
|
26
|
+
container: false,
|
|
27
|
+
remark: stockRequest.remark
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let orderItems: any = stockRequest.requestItems.map(ri => {
|
|
31
|
+
return {
|
|
32
|
+
orderItemId: ri.id,
|
|
33
|
+
product: {
|
|
34
|
+
refCode: ri.itemId,
|
|
35
|
+
sku: ri.itemCode
|
|
36
|
+
},
|
|
37
|
+
fromLocation: ri.fromLocation,
|
|
38
|
+
toLocation: ri.toLocation,
|
|
39
|
+
requestQty: ri.requestQuantity,
|
|
40
|
+
confirmedQty: ri.confirmedQuantity,
|
|
41
|
+
unitCost: ri.enterCost,
|
|
42
|
+
sellingPrice: ri.totalCost
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
return { orderInfo, orderItems }
|
|
13
47
|
}
|
|
14
48
|
}
|
|
15
49
|
}
|
|
@@ -2,33 +2,29 @@ export function createStockAdjustRecord() {
|
|
|
2
2
|
return {
|
|
3
3
|
method: 'post',
|
|
4
4
|
path: '/stocks/stockadjustment',
|
|
5
|
-
denormalize(req) {
|
|
5
|
+
denormalize(req, { accounting }) {
|
|
6
6
|
const { xilnexInv } = req
|
|
7
|
+
let accountInfo: any = accounting?.accountInfo ? JSON.parse(accounting.accountInfo) : {}
|
|
7
8
|
|
|
8
|
-
let adjustQuantity: number = xilnexInv.changedQty - xilnexInv.originalQty
|
|
9
9
|
let stocksTakeTitle: any = {
|
|
10
10
|
recordItems: [],
|
|
11
11
|
adjustItems: [
|
|
12
12
|
{
|
|
13
13
|
adjustQuantity: xilnexInv.adjustQuantity,
|
|
14
|
-
|
|
14
|
+
adjustAvailable: xilnexInv.adjustQuantity,
|
|
15
|
+
adjustType: xilnexInv.adjustQuantity >= 0 ? 'AdjustUp' : 'AdjustDown',
|
|
15
16
|
remark: '',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
stockAdjustType: 'Normal',
|
|
20
|
-
uom: xilnexInv?.uom ? xilnexInv.uom : xilnexInv.productDetail.uom,
|
|
21
|
-
uomQuantity: xilnexInv?.packingSize ? xilnexInv.packingSize : xilnexInv.productDetail.packingSize,
|
|
22
|
-
batchNo: xilnexInv?.batchId ? xilnexInv.batchId : null,
|
|
23
|
-
batchExpiryDate: xilnexInv?.expirationDate ? xilnexInv.expirationDate : null,
|
|
24
|
-
dateTime: xilnexInv.createdAt
|
|
17
|
+
itemCode: xilnexInv.sku,
|
|
18
|
+
stockAdjustType: xilnexInv.stockTakeType,
|
|
19
|
+
dateTime: xilnexInv.dateTime
|
|
25
20
|
}
|
|
26
21
|
],
|
|
22
|
+
outlet: accountInfo.outlet,
|
|
27
23
|
description: 'Stock Adjustment',
|
|
28
|
-
dateTime: xilnexInv.
|
|
24
|
+
dateTime: xilnexInv.dateTime,
|
|
29
25
|
remarks: '',
|
|
30
|
-
stockTakeType:
|
|
31
|
-
status: '
|
|
26
|
+
stockTakeType: xilnexInv.stockTakeType,
|
|
27
|
+
status: 'SAVED'
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
return {
|
|
@@ -36,7 +32,7 @@ export function createStockAdjustRecord() {
|
|
|
36
32
|
}
|
|
37
33
|
},
|
|
38
34
|
normalize(res) {
|
|
39
|
-
return res
|
|
35
|
+
return res.data.stocksTakeTitle
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function deliveryTransferNote() {
|
|
2
|
+
return {
|
|
3
|
+
method: 'post',
|
|
4
|
+
path: '/TransferNote/{orderId}/shipments',
|
|
5
|
+
denormalize(req) {
|
|
6
|
+
const { arrivalNotice, orderProducts } = req
|
|
7
|
+
|
|
8
|
+
let transferItems: any = orderProducts.map(op => {
|
|
9
|
+
return {
|
|
10
|
+
id: op.refItemId,
|
|
11
|
+
shippingQuantity: op.releaseQty
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
return { resource: { orderId: parseInt(arrivalNotice.refNo) }, payload: { transferNote: { transferItems } } }
|
|
16
|
+
},
|
|
17
|
+
normalize(res) {
|
|
18
|
+
return res
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function getTransferNote() {
|
|
2
|
+
return {
|
|
3
|
+
method: 'get',
|
|
4
|
+
path: '/TransferNote/{orderId}',
|
|
5
|
+
denormalize(req) {
|
|
6
|
+
const { orderId } = req
|
|
7
|
+
return { resource: { orderId: parseInt(orderId) } }
|
|
8
|
+
},
|
|
9
|
+
normalize(res) {
|
|
10
|
+
const { data } = res
|
|
11
|
+
let transferNote: any = data.transferNote
|
|
12
|
+
let transferItems: any = transferNote.transferItems
|
|
13
|
+
|
|
14
|
+
let orderInfo: any = {
|
|
15
|
+
orderId: transferNote.id,
|
|
16
|
+
transferDate: transferNote.transferDate,
|
|
17
|
+
etaDate: transferNote.etaDate,
|
|
18
|
+
fromLocation: transferNote.transferFrom,
|
|
19
|
+
toLocation: transferNote.transferTo,
|
|
20
|
+
issueBy: transferNote.transferBy,
|
|
21
|
+
status: transferNote.status,
|
|
22
|
+
cancelledDate: transferNote.cancelDate,
|
|
23
|
+
ownTransport: true,
|
|
24
|
+
importCargo: false,
|
|
25
|
+
container: false,
|
|
26
|
+
remark: transferNote.remarks
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let orderItems: any = transferItems.map(ri => {
|
|
30
|
+
return {
|
|
31
|
+
orderItemId: ri.id,
|
|
32
|
+
product: {
|
|
33
|
+
sku: ri.itemCode
|
|
34
|
+
},
|
|
35
|
+
fromLocation: ri.fromOutlet,
|
|
36
|
+
toLocation: ri.toOutlet,
|
|
37
|
+
requestQty: ri.transferQty,
|
|
38
|
+
confirmedQty: ri.transferQty,
|
|
39
|
+
unitCost: ri.unitPrice,
|
|
40
|
+
sellingPrice: ri.enterCost
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return { orderInfo, orderItems }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -20,7 +20,7 @@ export class Xilnex {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
isValidSignature(data, secret, signature) {
|
|
23
|
-
let hmac = crypto.createHmac('sha256', secret).update(JSON.stringify(data)).digest('hex')
|
|
23
|
+
let hmac = crypto.createHmac('sha256', secret).update(JSON.stringify(data)).digest('hex').toUpperCase()
|
|
24
24
|
|
|
25
25
|
return hmac === signature
|
|
26
26
|
}
|
|
@@ -83,4 +83,34 @@ export class Xilnex {
|
|
|
83
83
|
throw new Error(`(${response.status}) ${result}`)
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
async put(path: string, data: any = {}) {
|
|
88
|
+
const { accessToken, appId } = this.config
|
|
89
|
+
|
|
90
|
+
debug('data', data)
|
|
91
|
+
|
|
92
|
+
const jsondata = JSON.stringify(data)
|
|
93
|
+
|
|
94
|
+
const endpoint = `${ENDPOINT}${path}`
|
|
95
|
+
debug('endpoint', endpoint)
|
|
96
|
+
|
|
97
|
+
const response = await fetch(endpoint, {
|
|
98
|
+
method: 'put',
|
|
99
|
+
headers: {
|
|
100
|
+
'Content-Type': 'application/json',
|
|
101
|
+
token: accessToken,
|
|
102
|
+
appid: appId,
|
|
103
|
+
auth: '5'
|
|
104
|
+
},
|
|
105
|
+
body: jsondata
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
if (response.ok) {
|
|
109
|
+
const result = await response.json()
|
|
110
|
+
return result
|
|
111
|
+
} else {
|
|
112
|
+
const result = await response.text()
|
|
113
|
+
throw new Error(`(${response.status}) ${result}`)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
86
116
|
}
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Hatiolab
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|