repzo-sap-absjo 1.0.10 → 1.0.12

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 (79) hide show
  1. package/changelog.md +2 -0
  2. package/lib/actions/create_invoice.d.ts +19 -13
  3. package/lib/actions/create_invoice.js +356 -208
  4. package/lib/actions/create_payment.d.ts +4 -1
  5. package/lib/actions/create_payment.js +191 -117
  6. package/lib/actions/create_proforma.d.ts +4 -1
  7. package/lib/actions/create_proforma.js +285 -155
  8. package/lib/actions/create_return_invoice.d.ts +4 -1
  9. package/lib/actions/create_return_invoice.js +312 -169
  10. package/lib/actions/create_transfer.d.ts +4 -1
  11. package/lib/actions/create_transfer.js +223 -136
  12. package/lib/actions/index.js +23 -15
  13. package/lib/commands/adjust_inventory.d.ts +4 -2
  14. package/lib/commands/adjust_inventory.js +290 -160
  15. package/lib/commands/bank.d.ts +4 -2
  16. package/lib/commands/bank.js +279 -157
  17. package/lib/commands/basic.js +66 -47
  18. package/lib/commands/category.d.ts +3 -1
  19. package/lib/commands/category.js +178 -104
  20. package/lib/commands/channel.d.ts +3 -1
  21. package/lib/commands/channel.js +198 -117
  22. package/lib/commands/client.d.ts +34 -32
  23. package/lib/commands/client.js +404 -244
  24. package/lib/commands/client_disabled.d.ts +3 -1
  25. package/lib/commands/client_disabled.js +163 -94
  26. package/lib/commands/index.d.ts +15 -11
  27. package/lib/commands/index.js +60 -60
  28. package/lib/commands/join.js +192 -66
  29. package/lib/commands/measureunit.d.ts +19 -14
  30. package/lib/commands/measureunit.js +289 -191
  31. package/lib/commands/measureunit_family.d.ts +10 -8
  32. package/lib/commands/measureunit_family.js +250 -138
  33. package/lib/commands/payment_term.d.ts +3 -1
  34. package/lib/commands/payment_term.js +202 -123
  35. package/lib/commands/price_list.d.ts +15 -15
  36. package/lib/commands/price_list.js +612 -326
  37. package/lib/commands/product.d.ts +32 -30
  38. package/lib/commands/product.js +426 -243
  39. package/lib/commands/product_disabled.d.ts +3 -1
  40. package/lib/commands/product_disabled.js +164 -94
  41. package/lib/commands/rep.js +221 -141
  42. package/lib/commands/tag.js +174 -109
  43. package/lib/commands/tax.js +177 -112
  44. package/lib/commands/warehouse.d.ts +3 -1
  45. package/lib/commands/warehouse.js +207 -119
  46. package/lib/index.d.ts +21 -12
  47. package/lib/test/actions/create_invoice.js +193 -188
  48. package/lib/test/actions/create_payment.js +112 -107
  49. package/lib/test/actions/create_proforma.js +220 -216
  50. package/lib/test/actions/create_return_invoice.js +205 -200
  51. package/lib/test/actions/create_transfer.js +120 -115
  52. package/lib/test/commands/adjust_inventory.js +90 -90
  53. package/lib/test/commands/bank.js +90 -90
  54. package/lib/test/commands/basic.js +328 -327
  55. package/lib/test/commands/category.js +90 -90
  56. package/lib/test/commands/channel.js +90 -90
  57. package/lib/test/commands/client.js +355 -353
  58. package/lib/test/commands/client_disabled.js +90 -90
  59. package/lib/test/commands/join.js +328 -327
  60. package/lib/test/commands/measureunit.js +90 -90
  61. package/lib/test/commands/measureunit_family.js +90 -90
  62. package/lib/test/commands/payment_term.js +90 -90
  63. package/lib/test/commands/price_list.js +337 -334
  64. package/lib/test/commands/product.js +90 -90
  65. package/lib/test/commands/product_disabled.js +90 -90
  66. package/lib/test/commands/rep.js +346 -344
  67. package/lib/test/commands/tag.js +90 -90
  68. package/lib/test/commands/tax.js +90 -90
  69. package/lib/test/commands/warehouse.js +90 -90
  70. package/lib/types.d.ts +83 -60
  71. package/lib/util.d.ts +70 -19
  72. package/lib/util.js +170 -144
  73. package/package.json +2 -2
  74. package/src/actions/create_invoice.ts +11 -16
  75. package/src/actions/create_payment.ts +11 -16
  76. package/src/actions/create_proforma.ts +19 -24
  77. package/src/actions/create_return_invoice.ts +11 -16
  78. package/src/actions/create_transfer.ts +23 -28
  79. package/src/commands/product.ts +1 -0
@@ -1,71 +1,197 @@
1
1
  import Repzo from "repzo";
2
2
  export const join = async (commandEvent) => {
3
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
4
- const repzo = new Repzo((_a = commandEvent.app.formData) === null || _a === void 0 ? void 0 : _a.repzoApiKey, {
5
- env: commandEvent.env,
6
- });
7
- const commandLog = new Repzo.CommandLog(repzo, commandEvent.app, commandEvent.command);
8
- try {
9
- // console.log("join");
10
- await commandLog.load(commandEvent.sync_id);
11
- await commandLog.addDetail("Repzo SAP: Join").commit();
12
- const body = {
13
- data: [
14
- // invoice
15
- {
16
- app: "repzo-sap-absjo",
17
- app_id: (_b = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _b === void 0 ? void 0 : _b._id,
18
- action: "create_invoice",
19
- event: "invoiceItems.create",
20
- join: ((_e = (_d = (_c = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _c === void 0 ? void 0 : _c.formData) === null || _d === void 0 ? void 0 : _d.invoices) === null || _e === void 0 ? void 0 : _e.createInvoiceHook) || false,
21
- },
22
- // return_invoice
23
- {
24
- app: "repzo-sap-absjo",
25
- app_id: (_f = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _f === void 0 ? void 0 : _f._id,
26
- action: "create_return_invoice",
27
- event: "returnItems.create",
28
- join: ((_j = (_h = (_g = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _g === void 0 ? void 0 : _g.formData) === null || _h === void 0 ? void 0 : _h.invoices) === null || _j === void 0 ? void 0 : _j.createReturnInvoiceHook) ||
29
- false,
30
- },
31
- // payment
32
- {
33
- app: "repzo-sap-absjo",
34
- app_id: (_k = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _k === void 0 ? void 0 : _k._id,
35
- action: "create_payment",
36
- event: "payment.create",
37
- join: ((_o = (_m = (_l = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _l === void 0 ? void 0 : _l.formData) === null || _m === void 0 ? void 0 : _m.payments) === null || _o === void 0 ? void 0 : _o.createPaymentHook) || false,
38
- },
39
- // proforma
40
- {
41
- app: "repzo-sap-absjo",
42
- app_id: (_p = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _p === void 0 ? void 0 : _p._id,
43
- action: "create_proforma",
44
- event: "salesorder.approve",
45
- join: ((_s = (_r = (_q = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _q === void 0 ? void 0 : _q.formData) === null || _r === void 0 ? void 0 : _r.proformas) === null || _s === void 0 ? void 0 : _s.createApprovedProformaHook) || false,
46
- },
47
- // transfer
48
- {
49
- app: "repzo-sap-absjo",
50
- app_id: (_t = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _t === void 0 ? void 0 : _t._id,
51
- action: "create_transfer",
52
- event: "transfer.approve",
53
- join: ((_w = (_v = (_u = commandEvent === null || commandEvent === void 0 ? void 0 : commandEvent.app) === null || _u === void 0 ? void 0 : _u.formData) === null || _v === void 0 ? void 0 : _v.transfers) === null || _w === void 0 ? void 0 : _w.createApprovedTransferHook) || false,
54
- },
55
- ],
56
- };
57
- const result = await repzo.joinActionsWebHook.update(null, body);
58
- // console.log(result);
59
- if ((result === null || result === void 0 ? void 0 : result.status) == "failure") {
60
- await commandLog.setStatus("fail", result.error).setBody(result).commit();
61
- return;
62
- }
63
- await commandLog.setStatus("success").setBody(result).commit();
3
+ var _a,
4
+ _b,
5
+ _c,
6
+ _d,
7
+ _e,
8
+ _f,
9
+ _g,
10
+ _h,
11
+ _j,
12
+ _k,
13
+ _l,
14
+ _m,
15
+ _o,
16
+ _p,
17
+ _q,
18
+ _r,
19
+ _s,
20
+ _t,
21
+ _u,
22
+ _v,
23
+ _w,
24
+ _x;
25
+ const repzo = new Repzo(
26
+ (_a = commandEvent.app.formData) === null || _a === void 0
27
+ ? void 0
28
+ : _a.repzoApiKey,
29
+ {
30
+ env: commandEvent.env,
64
31
  }
65
- catch (e) {
66
- //@ts-ignore
67
- console.error(((_x = e === null || e === void 0 ? void 0 : e.response) === null || _x === void 0 ? void 0 : _x.data) || e);
68
- await commandLog.setStatus("fail", e).commit();
69
- throw e;
32
+ );
33
+ const commandLog = new Repzo.CommandLog(
34
+ repzo,
35
+ commandEvent.app,
36
+ commandEvent.command
37
+ );
38
+ try {
39
+ // console.log("join");
40
+ await commandLog.load(commandEvent.sync_id);
41
+ await commandLog.addDetail("Repzo SAP: Join").commit();
42
+ const body = {
43
+ data: [
44
+ // invoice
45
+ {
46
+ app: "repzo-sap-absjo",
47
+ app_id:
48
+ (_b =
49
+ commandEvent === null || commandEvent === void 0
50
+ ? void 0
51
+ : commandEvent.app) === null || _b === void 0
52
+ ? void 0
53
+ : _b._id,
54
+ action: "create_invoice",
55
+ event: "invoiceItems.create",
56
+ join:
57
+ ((_e =
58
+ (_d =
59
+ (_c =
60
+ commandEvent === null || commandEvent === void 0
61
+ ? void 0
62
+ : commandEvent.app) === null || _c === void 0
63
+ ? void 0
64
+ : _c.formData) === null || _d === void 0
65
+ ? void 0
66
+ : _d.invoices) === null || _e === void 0
67
+ ? void 0
68
+ : _e.createInvoiceHook) || false,
69
+ },
70
+ // return_invoice
71
+ {
72
+ app: "repzo-sap-absjo",
73
+ app_id:
74
+ (_f =
75
+ commandEvent === null || commandEvent === void 0
76
+ ? void 0
77
+ : commandEvent.app) === null || _f === void 0
78
+ ? void 0
79
+ : _f._id,
80
+ action: "create_return_invoice",
81
+ event: "returnItems.create",
82
+ join:
83
+ ((_j =
84
+ (_h =
85
+ (_g =
86
+ commandEvent === null || commandEvent === void 0
87
+ ? void 0
88
+ : commandEvent.app) === null || _g === void 0
89
+ ? void 0
90
+ : _g.formData) === null || _h === void 0
91
+ ? void 0
92
+ : _h.invoices) === null || _j === void 0
93
+ ? void 0
94
+ : _j.createReturnInvoiceHook) || false,
95
+ },
96
+ // payment
97
+ {
98
+ app: "repzo-sap-absjo",
99
+ app_id:
100
+ (_k =
101
+ commandEvent === null || commandEvent === void 0
102
+ ? void 0
103
+ : commandEvent.app) === null || _k === void 0
104
+ ? void 0
105
+ : _k._id,
106
+ action: "create_payment",
107
+ event: "payment.create",
108
+ join:
109
+ ((_o =
110
+ (_m =
111
+ (_l =
112
+ commandEvent === null || commandEvent === void 0
113
+ ? void 0
114
+ : commandEvent.app) === null || _l === void 0
115
+ ? void 0
116
+ : _l.formData) === null || _m === void 0
117
+ ? void 0
118
+ : _m.payments) === null || _o === void 0
119
+ ? void 0
120
+ : _o.createPaymentHook) || false,
121
+ },
122
+ // proforma
123
+ {
124
+ app: "repzo-sap-absjo",
125
+ app_id:
126
+ (_p =
127
+ commandEvent === null || commandEvent === void 0
128
+ ? void 0
129
+ : commandEvent.app) === null || _p === void 0
130
+ ? void 0
131
+ : _p._id,
132
+ action: "create_proforma",
133
+ event: "salesorder.approve",
134
+ join:
135
+ ((_s =
136
+ (_r =
137
+ (_q =
138
+ commandEvent === null || commandEvent === void 0
139
+ ? void 0
140
+ : commandEvent.app) === null || _q === void 0
141
+ ? void 0
142
+ : _q.formData) === null || _r === void 0
143
+ ? void 0
144
+ : _r.proformas) === null || _s === void 0
145
+ ? void 0
146
+ : _s.createApprovedProformaHook) || false,
147
+ },
148
+ // transfer
149
+ {
150
+ app: "repzo-sap-absjo",
151
+ app_id:
152
+ (_t =
153
+ commandEvent === null || commandEvent === void 0
154
+ ? void 0
155
+ : commandEvent.app) === null || _t === void 0
156
+ ? void 0
157
+ : _t._id,
158
+ action: "create_transfer",
159
+ event: "transfer.approve",
160
+ join:
161
+ ((_w =
162
+ (_v =
163
+ (_u =
164
+ commandEvent === null || commandEvent === void 0
165
+ ? void 0
166
+ : commandEvent.app) === null || _u === void 0
167
+ ? void 0
168
+ : _u.formData) === null || _v === void 0
169
+ ? void 0
170
+ : _v.transfers) === null || _w === void 0
171
+ ? void 0
172
+ : _w.createApprovedTransferHook) || false,
173
+ },
174
+ ],
175
+ };
176
+ const result = await repzo.joinActionsWebHook.update(null, body);
177
+ // console.log(result);
178
+ if (
179
+ (result === null || result === void 0 ? void 0 : result.status) ==
180
+ "failure"
181
+ ) {
182
+ await commandLog.setStatus("fail", result.error).setBody(result).commit();
183
+ return;
70
184
  }
185
+ await commandLog.setStatus("success").setBody(result).commit();
186
+ } catch (e) {
187
+ //@ts-ignore
188
+ console.error(
189
+ ((_x = e === null || e === void 0 ? void 0 : e.response) === null ||
190
+ _x === void 0
191
+ ? void 0
192
+ : _x.data) || e
193
+ );
194
+ await commandLog.setStatus("fail", e).commit();
195
+ throw e;
196
+ }
71
197
  };
@@ -1,18 +1,23 @@
1
1
  import { CommandEvent, Result } from "../types";
2
2
  export interface SAPUoM {
3
- ITEMCODE: string;
4
- UOMGROUPENTRY: number;
5
- UOMGROUPCODE: string;
6
- UOMGROUPNAME: string;
7
- BASEUOMID: number;
8
- BASEUOMCODE: string;
9
- BASEQTY: number;
10
- ALTUOMID: number;
11
- ALTUOMCODE: string;
12
- ALTQTY: number;
13
- repzo_factor?: number;
3
+ ITEMCODE: string;
4
+ UOMGROUPENTRY: number;
5
+ UOMGROUPCODE: string;
6
+ UOMGROUPNAME: string;
7
+ BASEUOMID: number;
8
+ BASEUOMCODE: string;
9
+ BASEQTY: number;
10
+ ALTUOMID: number;
11
+ ALTUOMCODE: string;
12
+ ALTQTY: number;
13
+ repzo_factor?: number;
14
14
  }
15
- export declare const sync_measureunit: (commandEvent: CommandEvent) => Promise<Result>;
16
- export declare const get_sap_UoMs: (serviceEndPoint: string, query?: {
15
+ export declare const sync_measureunit: (
16
+ commandEvent: CommandEvent
17
+ ) => Promise<Result>;
18
+ export declare const get_sap_UoMs: (
19
+ serviceEndPoint: string,
20
+ query?: {
17
21
  updateAt?: string;
18
- }) => Promise<SAPUoM[]>;
22
+ }
23
+ ) => Promise<SAPUoM[]>;