repzo-sap-absjo 1.0.36 → 1.0.37
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/lib/actions/create_invoice.js +2 -2
- package/lib/actions/create_proforma.js +52 -30
- package/lib/actions/create_return_invoice.js +2 -2
- package/lib/actions/create_transfer.js +1 -1
- package/lib/commands/client.js +5 -4
- package/lib/commands/measureunit.js +1 -1
- package/lib/commands/product.js +1 -1
- package/lib/commands/tax.js +1 -1
- package/lib/test/actions/create_invoice.js +1 -1
- package/lib/test/actions/create_payment.js +1 -1
- package/lib/test/actions/create_proforma.js +2 -1
- package/lib/test/actions/create_return_invoice.js +1 -1
- package/lib/test/actions/create_transfer.js +1 -1
- package/lib/test/commands/brand.js +1 -1
- package/lib/test/commands/category.js +1 -1
- package/lib/test/commands/channel.js +1 -1
- package/lib/test/commands/payment_term.js +1 -1
- package/lib/test/commands/price_list.js +1 -1
- package/lib/test/commands/price_list_disabled.js +1 -1
- package/lib/test/commands/warehouse.js +1 -1
- package/lib/util.d.ts +2 -2
- package/package.json +6 -6
- package/src/actions/create_invoice.ts +1 -1
- package/src/actions/create_proforma.ts +18 -4
- package/src/actions/create_return_invoice.ts +1 -1
- package/src/commands/client.ts +4 -3
- package/src/test/actions/create_proforma.ts +1 -0
|
@@ -312,14 +312,14 @@ export const create_invoice = async (event, options) => {
|
|
|
312
312
|
Quantity: item.qty,
|
|
313
313
|
TaxCode: repzo_tax.integration_meta.TaxCode,
|
|
314
314
|
UnitPrice: (item.price * repzo_measureunit.factor) / 1000,
|
|
315
|
-
DiscountPerc: "0",
|
|
315
|
+
DiscountPerc: "0", // ??
|
|
316
316
|
//@ts-ignore
|
|
317
317
|
LineTotal: item.total_before_tax / 1000,
|
|
318
318
|
UomCode: repzo_measureunit.integration_meta.ALTUOMID,
|
|
319
319
|
Brand:
|
|
320
320
|
(_o = repzo_product.integration_meta) === null || _o === void 0
|
|
321
321
|
? void 0
|
|
322
|
-
: _o.BRAND,
|
|
322
|
+
: _o.BRAND, // "B1", // ??
|
|
323
323
|
Department:
|
|
324
324
|
((_p =
|
|
325
325
|
repzo_rep === null || repzo_rep === void 0
|
|
@@ -3,7 +3,7 @@ import { _create, getUniqueConcatenatedValues } from "../util.js";
|
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
import moment from "moment-timezone";
|
|
5
5
|
export const create_proforma = async (event, options) => {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
7
7
|
const repzo = new Repzo(
|
|
8
8
|
(_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey,
|
|
9
9
|
{ env: options.env }
|
|
@@ -62,11 +62,29 @@ export const create_proforma = async (event, options) => {
|
|
|
62
62
|
? void 0
|
|
63
63
|
: repzo_proforma.creator) === null || _e === void 0
|
|
64
64
|
? void 0
|
|
65
|
-
: _e._id
|
|
65
|
+
: _e._id,
|
|
66
|
+
{
|
|
67
|
+
populatedKeys: ["warehouse"],
|
|
68
|
+
}
|
|
66
69
|
);
|
|
67
70
|
if (!repzo_rep)
|
|
68
71
|
throw `Rep with _id: ${repzo_proforma.creator._id} not found in Repzo`;
|
|
69
72
|
}
|
|
73
|
+
let rep_warehouse_code;
|
|
74
|
+
if (
|
|
75
|
+
repzo_rep &&
|
|
76
|
+
(repzo_rep === null || repzo_rep === void 0
|
|
77
|
+
? void 0
|
|
78
|
+
: repzo_rep.assigned_warehouse)
|
|
79
|
+
) {
|
|
80
|
+
rep_warehouse_code =
|
|
81
|
+
(_f =
|
|
82
|
+
repzo_rep === null || repzo_rep === void 0
|
|
83
|
+
? void 0
|
|
84
|
+
: repzo_rep.assigned_warehouse) === null || _f === void 0
|
|
85
|
+
? void 0
|
|
86
|
+
: _f.code;
|
|
87
|
+
}
|
|
70
88
|
// Get Repzo Client
|
|
71
89
|
const repzo_client = await repzo.client.get(
|
|
72
90
|
repzo_proforma === null || repzo_proforma === void 0
|
|
@@ -78,9 +96,9 @@ export const create_proforma = async (event, options) => {
|
|
|
78
96
|
const repzo_tax_ids = {};
|
|
79
97
|
const repzo_measureunit_ids = {};
|
|
80
98
|
const repzo_product_ids = {};
|
|
81
|
-
(
|
|
99
|
+
(_g = repzo_proforma.items) === null || _g === void 0
|
|
82
100
|
? void 0
|
|
83
|
-
:
|
|
101
|
+
: _g.forEach((item) => {
|
|
84
102
|
var _a, _b, _c;
|
|
85
103
|
if (item) {
|
|
86
104
|
repzo_tax_ids[
|
|
@@ -138,12 +156,12 @@ export const create_proforma = async (event, options) => {
|
|
|
138
156
|
{ per_page: 50000 }
|
|
139
157
|
);
|
|
140
158
|
const all_promotions = {};
|
|
141
|
-
(
|
|
159
|
+
(_h =
|
|
142
160
|
repzo_proforma === null || repzo_proforma === void 0
|
|
143
161
|
? void 0
|
|
144
|
-
: repzo_proforma.promotions) === null ||
|
|
162
|
+
: repzo_proforma.promotions) === null || _h === void 0
|
|
145
163
|
? void 0
|
|
146
|
-
:
|
|
164
|
+
: _h.forEach((promo) => {
|
|
147
165
|
if (!promo) return;
|
|
148
166
|
all_promotions[promo._id] = {
|
|
149
167
|
_id: promo._id,
|
|
@@ -156,23 +174,23 @@ export const create_proforma = async (event, options) => {
|
|
|
156
174
|
for (
|
|
157
175
|
let i = 0;
|
|
158
176
|
i <
|
|
159
|
-
((
|
|
177
|
+
((_j =
|
|
160
178
|
repzo_proforma === null || repzo_proforma === void 0
|
|
161
179
|
? void 0
|
|
162
|
-
: repzo_proforma.items) === null ||
|
|
180
|
+
: repzo_proforma.items) === null || _j === void 0
|
|
163
181
|
? void 0
|
|
164
|
-
:
|
|
182
|
+
: _j.length);
|
|
165
183
|
i++
|
|
166
184
|
) {
|
|
167
185
|
const item = repzo_proforma.items[i];
|
|
168
186
|
// Get Repzo Tax
|
|
169
187
|
const repzo_tax =
|
|
170
|
-
(
|
|
188
|
+
(_k =
|
|
171
189
|
repzo_taxes === null || repzo_taxes === void 0
|
|
172
190
|
? void 0
|
|
173
|
-
: repzo_taxes.data) === null ||
|
|
191
|
+
: repzo_taxes.data) === null || _k === void 0
|
|
174
192
|
? void 0
|
|
175
|
-
:
|
|
193
|
+
: _k.find((t) => {
|
|
176
194
|
var _a, _b, _c;
|
|
177
195
|
return (
|
|
178
196
|
((_a = t._id) === null || _a === void 0
|
|
@@ -189,12 +207,12 @@ export const create_proforma = async (event, options) => {
|
|
|
189
207
|
if (!repzo_tax) throw `Tax with _id: ${item.tax._id} not found in Repzo`;
|
|
190
208
|
// Get Repzo UoM
|
|
191
209
|
const repzo_measureunit =
|
|
192
|
-
(
|
|
210
|
+
(_l =
|
|
193
211
|
repzo_measureunits === null || repzo_measureunits === void 0
|
|
194
212
|
? void 0
|
|
195
|
-
: repzo_measureunits.data) === null ||
|
|
213
|
+
: repzo_measureunits.data) === null || _l === void 0
|
|
196
214
|
? void 0
|
|
197
|
-
:
|
|
215
|
+
: _l.find((m) => {
|
|
198
216
|
var _a, _b, _c;
|
|
199
217
|
return (
|
|
200
218
|
((_a = m._id) === null || _a === void 0
|
|
@@ -210,16 +228,16 @@ export const create_proforma = async (event, options) => {
|
|
|
210
228
|
});
|
|
211
229
|
if (!repzo_measureunit)
|
|
212
230
|
throw `Uom with _id: ${
|
|
213
|
-
(
|
|
231
|
+
(_m = item.measureunit) === null || _m === void 0 ? void 0 : _m._id
|
|
214
232
|
} not found in Repzo`;
|
|
215
233
|
// Get Repzo Product
|
|
216
234
|
const repzo_product =
|
|
217
|
-
(
|
|
235
|
+
(_o =
|
|
218
236
|
repzo_products === null || repzo_products === void 0
|
|
219
237
|
? void 0
|
|
220
|
-
: repzo_products.data) === null ||
|
|
238
|
+
: repzo_products.data) === null || _o === void 0
|
|
221
239
|
? void 0
|
|
222
|
-
:
|
|
240
|
+
: _o.find((p) => {
|
|
223
241
|
var _a, _b, _c;
|
|
224
242
|
return (
|
|
225
243
|
((_a = p._id) === null || _a === void 0
|
|
@@ -257,28 +275,28 @@ export const create_proforma = async (event, options) => {
|
|
|
257
275
|
LineTotal: item.total_before_tax / 1000,
|
|
258
276
|
UomCode: repzo_measureunit.integration_meta.ALTUOMID,
|
|
259
277
|
Brand:
|
|
260
|
-
(
|
|
278
|
+
(_p = repzo_product.integration_meta) === null || _p === void 0
|
|
261
279
|
? void 0
|
|
262
|
-
:
|
|
280
|
+
: _p.BRAND,
|
|
263
281
|
Department:
|
|
264
|
-
((
|
|
282
|
+
((_q =
|
|
265
283
|
repzo_rep === null || repzo_rep === void 0
|
|
266
284
|
? void 0
|
|
267
|
-
: repzo_rep.integration_meta) === null ||
|
|
285
|
+
: repzo_rep.integration_meta) === null || _q === void 0
|
|
268
286
|
? void 0
|
|
269
|
-
:
|
|
270
|
-
((
|
|
287
|
+
: _q.DEPARTMENTCODE) ||
|
|
288
|
+
((_r = options.data) === null || _r === void 0
|
|
271
289
|
? void 0
|
|
272
|
-
:
|
|
290
|
+
: _r.DepartmentCode), // "D2"
|
|
273
291
|
});
|
|
274
292
|
}
|
|
275
293
|
const sap_invoice = {
|
|
276
294
|
RefNum: repzo_proforma.serial_number.formatted,
|
|
277
295
|
SalPersCode: repzo_rep
|
|
278
296
|
? repzo_rep.integration_id
|
|
279
|
-
: (
|
|
297
|
+
: (_s = options.data) === null || _s === void 0
|
|
280
298
|
? void 0
|
|
281
|
-
:
|
|
299
|
+
: _s.SalPersCode, // "111",
|
|
282
300
|
DocDate: moment(repzo_proforma.issue_date, "YYYY-MM-DD").format(
|
|
283
301
|
"YYYYMMDD"
|
|
284
302
|
),
|
|
@@ -288,7 +306,11 @@ export const create_proforma = async (event, options) => {
|
|
|
288
306
|
ClientCode: repzo_client.client_code,
|
|
289
307
|
DiscountPerc: "0",
|
|
290
308
|
Note: repzo_proforma.comment,
|
|
291
|
-
|
|
309
|
+
WarehouseCode:
|
|
310
|
+
rep_warehouse_code ||
|
|
311
|
+
((_t = options.data) === null || _t === void 0
|
|
312
|
+
? void 0
|
|
313
|
+
: _t.defaultWarehouseForSalesOrder), // "1",
|
|
292
314
|
LinesDetails: items,
|
|
293
315
|
};
|
|
294
316
|
// console.dir(sap_invoice, { depth: null });
|
|
@@ -253,7 +253,7 @@ export const create_return_invoice = async (event, options) => {
|
|
|
253
253
|
Brand:
|
|
254
254
|
(_o = repzo_product.integration_meta) === null || _o === void 0
|
|
255
255
|
? void 0
|
|
256
|
-
: _o.BRAND,
|
|
256
|
+
: _o.BRAND, // "B1",
|
|
257
257
|
Department:
|
|
258
258
|
((_p =
|
|
259
259
|
repzo_rep === null || repzo_rep === void 0
|
|
@@ -263,7 +263,7 @@ export const create_return_invoice = async (event, options) => {
|
|
|
263
263
|
: _p.DEPARTMENTCODE) ||
|
|
264
264
|
((_q = options.data) === null || _q === void 0
|
|
265
265
|
? void 0
|
|
266
|
-
: _q.DepartmentCode),
|
|
266
|
+
: _q.DepartmentCode), // "D2"
|
|
267
267
|
Return_Reason:
|
|
268
268
|
item_return_reason === null || item_return_reason === void 0
|
|
269
269
|
? void 0
|
|
@@ -171,7 +171,7 @@ export const create_transfer = async (event, options) => {
|
|
|
171
171
|
? repzo_rep.integration_id
|
|
172
172
|
: (_o = options.data) === null || _o === void 0
|
|
173
173
|
? void 0
|
|
174
|
-
: _o.SalesPersonCode,
|
|
174
|
+
: _o.SalesPersonCode, // "111"
|
|
175
175
|
FromWarehouse: body.from.code,
|
|
176
176
|
ToWarehouse: body.to.code,
|
|
177
177
|
RepzoStockTransferLines: variants,
|
package/lib/commands/client.js
CHANGED
|
@@ -219,9 +219,9 @@ export const sync_client = async (commandEvent) => {
|
|
|
219
219
|
comment: sap_client.CLIENTNOTE,
|
|
220
220
|
formatted_address: sap_client.CLIENTADDRESSID,
|
|
221
221
|
tags: tag ? [tag._id] : [],
|
|
222
|
-
credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
// credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
|
|
223
|
+
// ? credit_limit && Math.round(credit_limit * 1000)
|
|
224
|
+
// : 1000000000,
|
|
225
225
|
financials: {
|
|
226
226
|
credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
|
|
227
227
|
? credit_limit && Math.round(credit_limit * 1000)
|
|
@@ -231,9 +231,10 @@ export const sync_client = async (commandEvent) => {
|
|
|
231
231
|
paymentTerm: paymentTerm ? paymentTerm._id : undefined,
|
|
232
232
|
sv_priceList: priceList ? priceList._id : undefined,
|
|
233
233
|
disabled: sap_client.ACTIVE == "Y" ? false : true,
|
|
234
|
-
payment_type: sap_client.PAYMENTTERM ? "credit" : "cash",
|
|
234
|
+
payment_type: sap_client.PAYMENTTERM ? "credit" : "cash", // sap_client.CLIENTGROUP == "Cash Van"
|
|
235
235
|
integrated_client_balance:
|
|
236
236
|
client_credit_consumed && Math.round(client_credit_consumed * 1000),
|
|
237
|
+
company_namespace: [nameSpace],
|
|
237
238
|
};
|
|
238
239
|
if (!repzo_client) {
|
|
239
240
|
// Create
|
|
@@ -207,7 +207,7 @@ export const sync_measureunit = async (commandEvent) => {
|
|
|
207
207
|
const body = {
|
|
208
208
|
parent: repzo_parent_id,
|
|
209
209
|
name: sap_UoM.ALTUOMCODE,
|
|
210
|
-
factor: sap_UoM.repzo_factor || 0,
|
|
210
|
+
factor: sap_UoM.repzo_factor || 0, // ??????
|
|
211
211
|
disabled: false,
|
|
212
212
|
integration_meta: {
|
|
213
213
|
id: `${nameSpace}_${sap_UoM.ITEMCODE}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
|
package/lib/commands/product.js
CHANGED
|
@@ -300,7 +300,7 @@ export const sync_product = async (commandEvent) => {
|
|
|
300
300
|
{
|
|
301
301
|
disabled: false,
|
|
302
302
|
name: sap_product.ITEMCODE,
|
|
303
|
-
price: 0,
|
|
303
|
+
price: 0, // Math.round(sap_product.PRICE * 1000),
|
|
304
304
|
integration_meta: {
|
|
305
305
|
id: `${nameSpace}_${sap_product.ITEMCODE}`,
|
|
306
306
|
ITEMCODE: sap_product.ITEMCODE,
|
package/lib/commands/tax.js
CHANGED
|
@@ -96,7 +96,7 @@ export const sync_tax = async (commandEvent) => {
|
|
|
96
96
|
const body = {
|
|
97
97
|
name: sap_tax.TaxName,
|
|
98
98
|
rate: Number(sap_tax.TaxRate / 100),
|
|
99
|
-
type: "additive",
|
|
99
|
+
type: "additive", // hardcode
|
|
100
100
|
disabled: sap_tax.Inactive === "N" ? false : true,
|
|
101
101
|
integration_meta: {
|
|
102
102
|
id: `${nameSpace}_${sap_tax.TaxCode}`,
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_invoice",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000001",
|
|
9
|
+
action_sync_id: "Actions-0000001", // SYNC_ID
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_payment",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000004",
|
|
9
|
+
action_sync_id: "Actions-0000004", // SYNC_ID
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_proforma",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000003",
|
|
9
|
+
action_sync_id: "Actions-0000003", // SYNC_ID
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -238,6 +238,7 @@ Actions(
|
|
|
238
238
|
'[{sap_id:1,sap_name:"BarcodeIssue",repzo_name:"Barcodeissue",repzo_id:"62b074972b332895edf114fc"},{sap_id:2,sap_name:"Damaged",repzo_name:"Damaged",repzo_id:"62b074ace96258fb745982e4"},{sap_id:3,sap_name:"Nearexpiry",repzo_name:"Nearexpiry",repzo_id:"62b074c0a066173bd1c1ea0d"},{sap_id:4,sap_name:"Wrongprinting",repzo_name:"Wrongprinting",repzo_id:"62b074d79e7f41f306a4cb42"},{sap_id:5,sap_name:"experied",repzo_name:"Experied",repzo_id:"62b074faa066173bd1c1eec0"}]',
|
|
239
239
|
SalPersCode: "111",
|
|
240
240
|
SalesPersonCode: "111",
|
|
241
|
+
defaultWarehouseForSalesOrder: "1",
|
|
241
242
|
},
|
|
242
243
|
}
|
|
243
244
|
);
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_return_invoice",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000002",
|
|
9
|
+
action_sync_id: "Actions-0000002", // SYNC_ID
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_transfer",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000005",
|
|
9
|
+
action_sync_id: "Actions-0000005", // SYNC_ID
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -341,7 +341,7 @@ let commandEvent = {
|
|
|
341
341
|
timezone: "Asia/Amman",
|
|
342
342
|
meta: "",
|
|
343
343
|
env: "staging",
|
|
344
|
-
sync_id: "9811c42a-d26e-41e0-bee5-e75260c04767",
|
|
344
|
+
sync_id: "9811c42a-d26e-41e0-bee5-e75260c04767", // should change
|
|
345
345
|
command: "price_list",
|
|
346
346
|
};
|
|
347
347
|
Commands(commandEvent);
|
|
@@ -353,7 +353,7 @@ let commandEvent = {
|
|
|
353
353
|
timezone: "Asia/Amman",
|
|
354
354
|
meta: "",
|
|
355
355
|
env: "staging",
|
|
356
|
-
sync_id: "a7e620b6-c5a2-44f7-b44b-3599b3ea1b54",
|
|
356
|
+
sync_id: "a7e620b6-c5a2-44f7-b44b-3599b3ea1b54", // should change
|
|
357
357
|
command: "price_list_disabled",
|
|
358
358
|
};
|
|
359
359
|
Commands(commandEvent);
|
package/lib/util.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare const updateAt_query: (
|
|
|
51
51
|
) => string;
|
|
52
52
|
export declare const get_data_from_sap: (
|
|
53
53
|
_path: string,
|
|
54
|
-
default_res: any,
|
|
54
|
+
default_res: any, // if no data was found
|
|
55
55
|
serviceEndPoint: string,
|
|
56
56
|
serviceApiKey: string,
|
|
57
57
|
query?: string
|
|
@@ -88,7 +88,7 @@ export declare const getUniqueConcatenatedValues: (
|
|
|
88
88
|
[promo_id: string]: {
|
|
89
89
|
_id: string;
|
|
90
90
|
name: string;
|
|
91
|
-
ref?: string
|
|
91
|
+
ref?: string;
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
) => string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repzo-sap-absjo",
|
|
3
3
|
"description": "repzo SAP ABS jo integration",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.37",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": {
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"directories": {},
|
|
19
19
|
"engines": {},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"lint": "npx prettier --write .",
|
|
21
|
+
"lint": "npx --yes prettier --write .",
|
|
22
22
|
"build": "tsc && npm run lint",
|
|
23
23
|
"test": "mocha",
|
|
24
|
-
"mac": "npm run build && node ./lib/test/commands/***.js"
|
|
24
|
+
"mac": "npm run build && node ./lib/test/commands/***.js",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
25
26
|
},
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|
|
28
29
|
"url": ""
|
|
29
30
|
},
|
|
30
|
-
"build": "tsc",
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/parser": "^7.16.6",
|
|
33
33
|
"@types/lodash": "^4.14.191",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/uuid": "^8.3.4",
|
|
36
36
|
"mocha": "^9.1.3",
|
|
37
37
|
"prettier": "^2.5.1",
|
|
38
|
-
"typescript": "^
|
|
38
|
+
"typescript": "^5.3.3"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@types/aws-lambda": "^8.10.93",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"jsonwebtoken": "^8.5.1",
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"moment-timezone": "^0.5.34",
|
|
48
|
-
"repzo": "^1.0.
|
|
48
|
+
"repzo": "^1.0.152",
|
|
49
49
|
"uuid": "^8.3.2"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -173,7 +173,7 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
173
173
|
if (item) {
|
|
174
174
|
repzo_tax_ids[item.tax?._id] = true;
|
|
175
175
|
repzo_measureunit_ids[item.measureunit?._id] = true;
|
|
176
|
-
repzo_product_ids[item.variant?.product_id] = true;
|
|
176
|
+
repzo_product_ids[item.variant?.product_id as string] = true;
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
|
|
@@ -78,12 +78,25 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
78
78
|
const repzo_proforma: Service.Proforma.ProformaSchema = body;
|
|
79
79
|
|
|
80
80
|
// Get Repzo Rep
|
|
81
|
-
let repzo_rep;
|
|
81
|
+
let repzo_rep: Service.Rep.Get.Result | undefined;
|
|
82
82
|
if (repzo_proforma.creator.type == "rep") {
|
|
83
|
-
repzo_rep = await repzo.rep.get(repzo_proforma?.creator?._id
|
|
83
|
+
repzo_rep = await repzo.rep.get(repzo_proforma?.creator?._id, {
|
|
84
|
+
populatedKeys: ["warehouse"],
|
|
85
|
+
});
|
|
84
86
|
if (!repzo_rep)
|
|
85
87
|
throw `Rep with _id: ${repzo_proforma.creator._id} not found in Repzo`;
|
|
86
88
|
}
|
|
89
|
+
let rep_warehouse_code:
|
|
90
|
+
| Service.Warehouse.WarehouseSchema["code"]
|
|
91
|
+
| undefined;
|
|
92
|
+
if (repzo_rep && repzo_rep?.assigned_warehouse) {
|
|
93
|
+
rep_warehouse_code = (
|
|
94
|
+
repzo_rep?.assigned_warehouse as Pick<
|
|
95
|
+
Service.Warehouse.WarehouseSchema,
|
|
96
|
+
"_id" | "code"
|
|
97
|
+
>
|
|
98
|
+
)?.code;
|
|
99
|
+
}
|
|
87
100
|
|
|
88
101
|
// Get Repzo Client
|
|
89
102
|
const repzo_client = await repzo.client.get(repzo_proforma?.client_id);
|
|
@@ -98,7 +111,7 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
98
111
|
if (item) {
|
|
99
112
|
repzo_tax_ids[item.tax?._id] = true;
|
|
100
113
|
repzo_measureunit_ids[item.measureunit?._id] = true;
|
|
101
|
-
repzo_product_ids[item.variant?.product_id] = true;
|
|
114
|
+
repzo_product_ids[item.variant?.product_id as string] = true;
|
|
102
115
|
}
|
|
103
116
|
});
|
|
104
117
|
|
|
@@ -223,7 +236,8 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
223
236
|
ClientCode: repzo_client.client_code,
|
|
224
237
|
DiscountPerc: "0",
|
|
225
238
|
Note: repzo_proforma.comment,
|
|
226
|
-
|
|
239
|
+
WarehouseCode:
|
|
240
|
+
rep_warehouse_code || options.data?.defaultWarehouseForSalesOrder, // "1",
|
|
227
241
|
LinesDetails: items,
|
|
228
242
|
};
|
|
229
243
|
|
|
@@ -114,7 +114,7 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
|
|
|
114
114
|
if (item) {
|
|
115
115
|
repzo_tax_ids[item.tax?._id] = true;
|
|
116
116
|
repzo_measureunit_ids[item.measureunit?._id] = true;
|
|
117
|
-
repzo_product_ids[item.variant?.product_id] = true;
|
|
117
|
+
repzo_product_ids[item.variant?.product_id as string] = true;
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
|
package/src/commands/client.ts
CHANGED
|
@@ -204,9 +204,9 @@ export const sync_client = async (commandEvent: CommandEvent) => {
|
|
|
204
204
|
comment: sap_client.CLIENTNOTE,
|
|
205
205
|
formatted_address: sap_client.CLIENTADDRESSID,
|
|
206
206
|
tags: tag ? [tag._id] : [],
|
|
207
|
-
credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
// credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
|
|
208
|
+
// ? credit_limit && Math.round(credit_limit * 1000)
|
|
209
|
+
// : 1000000000,
|
|
210
210
|
financials: {
|
|
211
211
|
credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
|
|
212
212
|
? credit_limit && Math.round(credit_limit * 1000)
|
|
@@ -219,6 +219,7 @@ export const sync_client = async (commandEvent: CommandEvent) => {
|
|
|
219
219
|
payment_type: sap_client.PAYMENTTERM ? "credit" : "cash", // sap_client.CLIENTGROUP == "Cash Van"
|
|
220
220
|
integrated_client_balance:
|
|
221
221
|
client_credit_consumed && Math.round(client_credit_consumed * 1000),
|
|
222
|
+
company_namespace: [nameSpace],
|
|
222
223
|
};
|
|
223
224
|
|
|
224
225
|
if (!repzo_client) {
|
|
@@ -238,6 +238,7 @@ Actions(
|
|
|
238
238
|
'[{sap_id:1,sap_name:"BarcodeIssue",repzo_name:"Barcodeissue",repzo_id:"62b074972b332895edf114fc"},{sap_id:2,sap_name:"Damaged",repzo_name:"Damaged",repzo_id:"62b074ace96258fb745982e4"},{sap_id:3,sap_name:"Nearexpiry",repzo_name:"Nearexpiry",repzo_id:"62b074c0a066173bd1c1ea0d"},{sap_id:4,sap_name:"Wrongprinting",repzo_name:"Wrongprinting",repzo_id:"62b074d79e7f41f306a4cb42"},{sap_id:5,sap_name:"experied",repzo_name:"Experied",repzo_id:"62b074faa066173bd1c1eec0"}]',
|
|
239
239
|
SalPersCode: "111",
|
|
240
240
|
SalesPersonCode: "111",
|
|
241
|
+
defaultWarehouseForSalesOrder: "1",
|
|
241
242
|
},
|
|
242
243
|
}
|
|
243
244
|
);
|