@things-factory/integration-accounting 4.3.743 → 4.3.745

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.api = void 0;
7
7
  const debug_1 = __importDefault(require("debug"));
8
8
  const debug = (0, debug_1.default)('things-factory:integration-accounting:accounting-api-decorator');
9
+ const integration_base_1 = require("@things-factory/integration-base");
9
10
  const NOOP = v => v;
10
11
  const api = (target, property, descriptor) => {
11
12
  const method = descriptor.value;
@@ -20,14 +21,29 @@ const api = (target, property, descriptor) => {
20
21
  var { path, method: httpMethod = 'post', denormalize = NOOP, normalize = NOOP, action = platformAction } = m.apply(this, [request]);
21
22
  var denormalized = await denormalize(request || {}, { accounting });
22
23
  debug('request', denormalized);
23
- var response = await action.apply(this, [
24
- { accounting, method: httpMethod, path, request: denormalized, platformAction }
25
- ]);
26
- debug('response', response);
27
- if (!response.ok) {
28
- throw response;
24
+ const fullPath = `${accounting.platform}${path}`;
25
+ const requestPayload = JSON.stringify(denormalized.payload || denormalized);
26
+ try {
27
+ var response = await action.apply(this, [
28
+ { accounting, method: httpMethod, path, request: denormalized, platformAction }
29
+ ]);
30
+ debug('response', response);
31
+ const responsePayload = typeof response === 'string' ? response : JSON.stringify(response);
32
+ // Log payload if context is available
33
+ if (request === null || request === void 0 ? void 0 : request.context) {
34
+ (0, integration_base_1.createPayloadLog)(`${accounting.platform}-${method.name}`, fullPath, requestPayload, responsePayload, request.context, integration_base_1.PayloadType.EGESTION, accounting.platform);
35
+ }
36
+ return await normalize(response, { accounting });
37
+ }
38
+ catch (error) {
39
+ const errorMessage = (error === null || error === void 0 ? void 0 : error.message) || String(error);
40
+ const errorPayload = typeof errorMessage === 'string' ? errorMessage : JSON.stringify(errorMessage);
41
+ // Log error payload if context is available
42
+ if (request === null || request === void 0 ? void 0 : request.context) {
43
+ (0, integration_base_1.createPayloadLog)(`${accounting.platform}-${method.name}`, fullPath, requestPayload, errorPayload, request.context, integration_base_1.PayloadType.EGESTION, accounting.platform);
44
+ }
45
+ throw error;
29
46
  }
30
- return await normalize(response, { accounting });
31
47
  };
32
48
  return descriptor;
33
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../server/controllers/accounting-api/decorators.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,gEAAgE,CAAC,CAAA;AAIrF,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAEZ,MAAM,GAAG,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAE,UAAwC,EAAO,EAAE;IACrG,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAA;IAE/B,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,UAAmB,EAAE,OAAO;QAC7D,MAAM,aAAa,GAAG,IAAI,CAAA;QAE1B,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAA;QAE7B,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAE1E,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACzB,IAAI,CAAC,CAAC,EAAE;YACN,MAAM,KAAK,CAAC,wBAAwB,QAAQ,sBAAsB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;SACjF;QAED,IAAI,EACF,IAAI,EACJ,MAAM,EAAE,UAAU,GAAG,MAAM,EAC3B,WAAW,GAAG,IAAI,EAClB,SAAS,GAAG,IAAI,EAChB,MAAM,GAAG,cAAc,EACxB,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;QAE5B,IAAI,YAAY,GAAG,MAAM,WAAW,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,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,EACf,8BAAW,CAAC,QAAQ,EACpB,UAAU,CAAC,QAAQ,CACpB,CAAA;aACF;YAED,OAAO,MAAM,SAAS,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;SACjD;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,YAAY,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,MAAM,CAAC,KAAK,CAAC,CAAA;YACpD,MAAM,YAAY,GAAG,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;YAEnG,4CAA4C;YAC5C,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE;gBACpB,IAAA,mCAAgB,EACd,GAAG,UAAU,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,EACvC,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,OAAO,CAAC,OAAO,EACf,8BAAW,CAAC,QAAQ,EACpB,UAAU,CAAC,QAAQ,CACpB,CAAA;aACF;YAED,MAAM,KAAK,CAAA;SACZ;IACH,CAAC,CAAA;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AA1EY,QAAA,GAAG,OA0Ef"}
@@ -15,7 +15,8 @@ function createPurchaseReceive() {
15
15
  return {
16
16
  itemCode: op.product.sku,
17
17
  enterQuantity: op.actualPackQty,
18
- enterCost: op.unitPrice
18
+ enterCost: op.unitPrice,
19
+ refItemId: op.refItemId
19
20
  };
20
21
  });
21
22
  let purchaseReceive = {
@@ -1 +1 @@
1
- {"version":3,"file":"create-purchase-receive.js","sourceRoot":"","sources":["../../../../../server/controllers/xilnex/apis/purchase-order/create-purchase-receive.ts"],"names":[],"mappings":";;;AAAA,SAAgB,qBAAqB;IACnC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,+BAA+B;QACrC,WAAW,CAAC,GAAG,E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EAAE;gBACpD,OAAO,EAAE,EAAE,eAAe,kCAAO,eAAe,KAAE,aAAa,GAAE,EAAE;aACpE,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA1CD,sDA0CC"}
1
+ {"version":3,"file":"create-purchase-receive.js","sourceRoot":"","sources":["../../../../../server/controllers/xilnex/apis/purchase-order/create-purchase-receive.ts"],"names":[],"mappings":";;;AAAA,SAAgB,qBAAqB;IACnC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,+BAA+B;QACrC,WAAW,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE;YAC7B,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,GAAG,CAAA;YAC5C,MAAM,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;YACxC,IAAI,WAAW,GAAQ,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,EAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;YACxF,IAAI,qBAAqB,GAAG,CAAC,CAAA;YAE7B,IAAI,aAAa,GAAQ,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAC9C,qBAAqB,IAAI,EAAE,CAAC,aAAa,CAAA;gBACzC,OAAO;oBACL,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG;oBACxB,aAAa,EAAE,EAAE,CAAC,aAAa;oBAC/B,SAAS,EAAE,EAAE,CAAC,SAAS;oBACvB,SAAS,EAAE,EAAE,CAAC,SAAS;iBACxB,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,IAAI,eAAe,GAAQ;gBACzB,KAAK,EAAE,CAAC;gBACR,WAAW,EAAE,OAAO;gBACpB,aAAa,EAAE,OAAO;gBACtB,cAAc,EAAE,WAAW;gBAC3B,gBAAgB,EAAE,KAAK;gBACvB,MAAM,EAAE,aAAa,CAAC,MAAM,IAAI,IAAI;gBACpC,MAAM,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,KAAI,aAAa;gBAC5C,QAAQ,EAAE,aAAa,CAAC,KAAK;gBAC7B,SAAS,EAAE,aAAa,CAAC,MAAM,IAAI,GAAG;gBACtC,WAAW,EAAE,OAAO;gBACpB,mBAAmB,EAAE,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,eAAe,KAAI,GAAG;aAC3D,CAAA;YAED,OAAO;gBACL,QAAQ,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;gBACpD,OAAO,EAAE,EAAE,eAAe,kCAAO,eAAe,KAAE,aAAa,GAAE,EAAE;aACpE,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA3CD,sDA2CC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-accounting",
3
- "version": "4.3.743",
3
+ "version": "4.3.745",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -26,14 +26,14 @@
26
26
  "dependencies": {
27
27
  "@things-factory/apptool-ui": "^4.3.743",
28
28
  "@things-factory/auth-ui": "^4.3.743",
29
- "@things-factory/biz-base": "^4.3.743",
29
+ "@things-factory/biz-base": "^4.3.745",
30
30
  "@things-factory/code-ui": "^4.3.743",
31
31
  "@things-factory/context-ui": "^4.3.743",
32
32
  "@things-factory/grist-ui": "^4.3.743",
33
33
  "@things-factory/i18n-base": "^4.3.743",
34
34
  "@things-factory/integration-ui": "^4.3.743",
35
35
  "@things-factory/more-ui": "^4.3.743",
36
- "@things-factory/product-base": "^4.3.743",
36
+ "@things-factory/product-base": "^4.3.745",
37
37
  "@things-factory/resource-ui": "^4.3.743",
38
38
  "@things-factory/setting-ui": "^4.3.743",
39
39
  "@things-factory/system-ui": "^4.3.743",
@@ -50,5 +50,5 @@
50
50
  "nock": "^13.0.2",
51
51
  "should": "^13.2.3"
52
52
  },
53
- "gitHead": "992085e02d9d861bc0c9e312f1360a45d18528a4"
53
+ "gitHead": "89c8b3c8c7ac589d4f547a984c1027a6f509671f"
54
54
  }
@@ -2,6 +2,7 @@ import Debug from 'debug'
2
2
  const debug = Debug('things-factory:integration-accounting:accounting-api-decorator')
3
3
 
4
4
  import { Account } from '../../entities'
5
+ import { createPayloadLog, PayloadType } from '@things-factory/integration-base'
5
6
 
6
7
  const NOOP = v => v
7
8
 
@@ -31,16 +32,51 @@ export const api = (target: Object, property: string, descriptor: TypedPropertyD
31
32
  var denormalized = await denormalize(request || {}, { accounting })
32
33
  debug('request', denormalized)
33
34
 
34
- var response = await action.apply(this, [
35
- { accounting, method: httpMethod, path, request: denormalized, platformAction }
36
- ])
35
+ const fullPath = `${accounting.platform}${path}`
36
+ const requestPayload = JSON.stringify(denormalized.payload || denormalized)
37
37
 
38
- debug('response', response)
39
- if (!response.ok) {
40
- throw response
41
- }
38
+ try {
39
+ var response = await action.apply(this, [
40
+ { accounting, method: httpMethod, path, request: denormalized, platformAction }
41
+ ])
42
+
43
+ debug('response', response)
44
+
45
+ const responsePayload = typeof response === 'string' ? response : JSON.stringify(response)
46
+
47
+ // Log payload if context is available
48
+ if (request?.context) {
49
+ createPayloadLog(
50
+ `${accounting.platform}-${method.name}`,
51
+ fullPath,
52
+ requestPayload,
53
+ responsePayload,
54
+ request.context,
55
+ PayloadType.EGESTION,
56
+ accounting.platform
57
+ )
58
+ }
42
59
 
43
- return await normalize(response, { accounting })
60
+ return await normalize(response, { accounting })
61
+ } catch (error) {
62
+ const errorMessage = error?.message || String(error)
63
+ const errorPayload = typeof errorMessage === 'string' ? errorMessage : JSON.stringify(errorMessage)
64
+
65
+ // Log error payload if context is available
66
+ if (request?.context) {
67
+ createPayloadLog(
68
+ `${accounting.platform}-${method.name}`,
69
+ fullPath,
70
+ requestPayload,
71
+ errorPayload,
72
+ request.context,
73
+ PayloadType.EGESTION,
74
+ accounting.platform
75
+ )
76
+ }
77
+
78
+ throw error
79
+ }
44
80
  }
45
81
 
46
82
  return descriptor
@@ -13,7 +13,8 @@ export function createPurchaseReceive() {
13
13
  return {
14
14
  itemCode: op.product.sku,
15
15
  enterQuantity: op.actualPackQty,
16
- enterCost: op.unitPrice
16
+ enterCost: op.unitPrice,
17
+ refItemId: op.refItemId
17
18
  }
18
19
  })
19
20