repzo-sap-absjo 1.0.40 → 1.0.41

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/changelog.md CHANGED
@@ -4,6 +4,18 @@
4
4
 
5
5
  ### Added
6
6
 
7
+ - [RDT-3412/RDT-3415] Update invoice processing to send as sales order to SAP when setting enabled @maramalshen
8
+
9
+ ### Changed
10
+
11
+ ### Fixed
12
+
13
+ ### Removed
14
+
15
+ ## [v1.0.41 (2025-09-01)](https://github.com/Repzo/repzo-sap-absjo.git)
16
+
17
+ ### Added
18
+
7
19
  - [util] in method: getUniqueConcatenatedValues, also add the promotions for items.buy @maramalshen
8
20
  - [actions/***] add 2 keys in integration_meta: sync_to_sap_started & sync_to_sap_succeeded @maramalshen
9
21
  - [commands/product] assign Foreign Name (ITEMDESCF) in SAP to local_name in Repzo @maramalshen
@@ -3,7 +3,25 @@ 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_invoice = async (event, options) => {
6
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
6
+ var _a,
7
+ _b,
8
+ _c,
9
+ _d,
10
+ _e,
11
+ _f,
12
+ _g,
13
+ _h,
14
+ _j,
15
+ _k,
16
+ _l,
17
+ _m,
18
+ _o,
19
+ _p,
20
+ _q,
21
+ _r,
22
+ _s,
23
+ _t,
24
+ _u;
7
25
  const repzo = new Repzo(
8
26
  (_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey,
9
27
  { env: options.env }
@@ -363,7 +381,46 @@ export const create_invoice = async (event, options) => {
363
381
  `Repzo => SAP: Invoice - ${repzo_serial_number}`,
364
382
  sap_invoice
365
383
  );
366
- const result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
384
+ let treating_invoice_as_proforma_for_etax = false;
385
+ if (
386
+ ((_r = body === null || body === void 0 ? void 0 : body.creator) ===
387
+ null || _r === void 0
388
+ ? void 0
389
+ : _r.type) == "rep" &&
390
+ ((_s =
391
+ repzo_rep === null || repzo_rep === void 0
392
+ ? void 0
393
+ : repzo_rep.settings) === null || _s === void 0
394
+ ? void 0
395
+ : _s.treating_invoice_as_proforma_for_etax)
396
+ ) {
397
+ const company = await repzo.safeCrud.create({
398
+ collection: "company",
399
+ filters: { name_space: repzo_invoice.company_namespace },
400
+ });
401
+ if (
402
+ (_u =
403
+ (_t =
404
+ company === null || company === void 0 ? void 0 : company.data) ===
405
+ null || _t === void 0
406
+ ? void 0
407
+ : _t[0]) === null || _u === void 0
408
+ ? void 0
409
+ : _u.allow_treating_invoice_as_proforma_for_etax
410
+ ) {
411
+ treating_invoice_as_proforma_for_etax = true;
412
+ }
413
+ }
414
+ let result;
415
+ if (treating_invoice_as_proforma_for_etax) {
416
+ actionLog.addDetail(
417
+ `Repzo => SAP: Invoice - ${repzo_serial_number} - Treat Invoice as SalesOrder for eTax`,
418
+ sap_invoice
419
+ );
420
+ result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
421
+ } else {
422
+ result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
423
+ }
367
424
  // console.log(result);
368
425
  try {
369
426
  await repzo.updateIntegrationMeta.create(
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.40",
4
+ "version": "1.0.41",
5
5
  "homepage": "",
6
6
  "keywords": [],
7
7
  "author": {
@@ -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.184",
48
+ "repzo": "^1.0.186",
49
49
  "uuid": "^8.3.2"
50
50
  }
51
51
  }
@@ -316,7 +316,30 @@ export const create_invoice = async (event: EVENT, options: Config) => {
316
316
  sap_invoice
317
317
  );
318
318
 
319
- const result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
319
+ let treating_invoice_as_proforma_for_etax: boolean = false;
320
+ if (
321
+ body?.creator?.type == "rep" &&
322
+ repzo_rep?.settings?.treating_invoice_as_proforma_for_etax
323
+ ) {
324
+ const company = await repzo.safeCrud.create({
325
+ collection: "company",
326
+ filters: { name_space: repzo_invoice.company_namespace },
327
+ });
328
+ if (company?.data?.[0]?.allow_treating_invoice_as_proforma_for_etax) {
329
+ treating_invoice_as_proforma_for_etax = true;
330
+ }
331
+ }
332
+
333
+ let result;
334
+ if (treating_invoice_as_proforma_for_etax) {
335
+ actionLog.addDetail(
336
+ `Repzo => SAP: Invoice - ${repzo_serial_number} - Treat Invoice as SalesOrder for eTax`,
337
+ sap_invoice
338
+ );
339
+ result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
340
+ } else {
341
+ result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
342
+ }
320
343
 
321
344
  // console.log(result);
322
345