shareneus 1.6.50 → 1.6.52

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.
@@ -63,7 +63,7 @@ function GetInvoicePdfDataUrl(PDFInvoiceData = {}, PrintConfigData = {}, printCo
63
63
  }
64
64
  function buildPdfDocDefinition(PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
65
65
  const PrintConfig = normalizePrintConfig(PDFInvoiceData, PrintConfigData);
66
- const requestedPageOrientation = (0, pdf_header_footer_section_1.resolvePageOrientation)((PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.PageOrientation) || PrintConfig.Orientation);
66
+ const requestedPageOrientation = (0, pdf_header_footer_section_1.resolvePageOrientation)((PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Orientation) || (PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.PageOrientation));
67
67
  const pageSize = (0, pdf_header_footer_section_1.resolvePageSize)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.PSize, requestedPageOrientation);
68
68
  const basePageMargins = (0, pdf_header_footer_section_1.resolvePageMargins)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.pageMargins);
69
69
  const copyLabels = normalizeCopyLabels(printCopies);
@@ -5,4 +5,7 @@ export declare class PurchaseOrderPrintService {
5
5
  static GetQtyWithUoM(Items: any): any;
6
6
  static ConcatTotalsInfo(PurchaseOrderPDFData: any, DetailedTotalsInfo: any): any;
7
7
  static FixPriceValuesForPrint(PrintData: any, TaxCodes: any, DecimalsNumber: number): any;
8
+ static GetTaxAmountFromTaxes(item: any, taxCode: string, fallbackAmount?: any): any;
9
+ static GetTaxRateFromTaxes(item: any, taxCode: string, fallbackRate?: any): any;
10
+ static GetTCodeFromTaxes(item: any): any;
8
11
  }
@@ -87,13 +87,14 @@ class PurchaseOrderPrintService {
87
87
  Labor.DiscPerc = Labor.Perc;
88
88
  Labor.DiscPerc = (0, aggregation_1.division)((0, aggregation_1.multiply)(100, Labor.Disc), Labor.UnCo);
89
89
  }
90
- Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.CGST, DecimalsNumber);
91
- Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.SGST, DecimalsNumber);
92
- Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Labor.IGST, DecimalsNumber);
90
+ Labor.TCode = this.GetTCodeFromTaxes(Labor);
91
+ Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'CGST', Labor.CGST), DecimalsNumber);
92
+ Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'SGST', Labor.SGST), DecimalsNumber);
93
+ Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'IGST', Labor.IGST), DecimalsNumber);
93
94
  Labor.QtyAndUoM = Labor.Qty.toString();
94
- Labor.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
95
- Labor.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
96
- Labor.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
95
+ Labor.CGSTPerc = this.GetTaxRateFromTaxes(Labor, 'CGST', shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes));
96
+ Labor.SGSTPerc = this.GetTaxRateFromTaxes(Labor, 'SGST', shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes));
97
+ Labor.IGSTPerc = this.GetTaxRateFromTaxes(Labor, 'IGST', shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes));
97
98
  // console.log('hello', TrUtils.Stringify(Labor));
98
99
  // if (LineTotal === 'AT') {
99
100
  // Labor.LineTotal = TrUtils.FixPriceValue(Labor.AfterLaborTax);
@@ -161,15 +162,16 @@ class PurchaseOrderPrintService {
161
162
  Part.UnCo = tr_utils_1.TrUtils.FixPriceValue(Part.UnCo, DecimalsNumber);
162
163
  Part.DiscountedPrice = tr_utils_1.TrUtils.FixPriceValue(Part.DiscountedPrice, DecimalsNumber);
163
164
  Part.AfterTax = tr_utils_1.TrUtils.FixPriceValue(Part.AfterTax, DecimalsNumber);
164
- Part.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Part.CGST, DecimalsNumber);
165
- Part.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Part.IGST, DecimalsNumber);
166
- Part.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Part.SGST, DecimalsNumber);
165
+ Part.TCode = this.GetTCodeFromTaxes(Part);
166
+ Part.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Part, 'CGST', Part.CGST), DecimalsNumber);
167
+ Part.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Part, 'IGST', Part.IGST), DecimalsNumber);
168
+ Part.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Part, 'SGST', Part.SGST), DecimalsNumber);
167
169
  if (!tr_utils_1.TrUtils.CheckInvalidSelect(Part.TCode)) {
168
170
  PrintData.ShowDetailedPartTaxInfo = true;
169
171
  }
170
- Part.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
171
- Part.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
172
- Part.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
172
+ Part.CGSTPerc = this.GetTaxRateFromTaxes(Part, 'CGST', shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Part.TCode, TaxCodes));
173
+ Part.SGSTPerc = this.GetTaxRateFromTaxes(Part, 'SGST', shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Part.TCode, TaxCodes));
174
+ Part.IGSTPerc = this.GetTaxRateFromTaxes(Part, 'IGST', shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Part.TCode, TaxCodes));
173
175
  });
174
176
  PrintData.PartsDiscTotal = tr_utils_1.TrUtils.FixPriceValue(PrintData.PartsDiscTotal, DecimalsNumber);
175
177
  PrintData.PartsTotalAfterDisc = tr_utils_1.TrUtils.FixPriceValue(PrintData.PartsTotalAfterDisc, DecimalsNumber);
@@ -183,5 +185,29 @@ class PurchaseOrderPrintService {
183
185
  PrintData.RoundedTotal = tr_utils_1.TrUtils.FixPriceValue(PrintData.RoundedTotal, DecimalsNumber);
184
186
  return PrintData;
185
187
  }
188
+ static GetTaxAmountFromTaxes(item, taxCode, fallbackAmount = 0) {
189
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
190
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
191
+ if (matchedTaxes.length !== 0) {
192
+ return matchedTaxes.reduce((total, tax) => total + Number((tax === null || tax === void 0 ? void 0 : tax.Amt) || 0), 0);
193
+ }
194
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackAmount);
195
+ }
196
+ static GetTaxRateFromTaxes(item, taxCode, fallbackRate = 0) {
197
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
198
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
199
+ if (matchedTaxes.length !== 0) {
200
+ return matchedTaxes.reduce((total, tax) => total + Number((tax === null || tax === void 0 ? void 0 : tax.Rate) || 0), 0);
201
+ }
202
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackRate);
203
+ }
204
+ static GetTCodeFromTaxes(item) {
205
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
206
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
207
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
208
+ return matchedTax.TaxCodeId;
209
+ }
210
+ return item === null || item === void 0 ? void 0 : item.TCode;
211
+ }
186
212
  }
187
213
  exports.PurchaseOrderPrintService = PurchaseOrderPrintService;
@@ -1,4 +1,7 @@
1
1
  export declare class PurchaseOrderTotalsService {
2
+ static GetTaxAmountFromTaxes(item: any, taxCode: string): any;
3
+ static GetTaxRateFromTaxes(item: any, taxCode: string): any;
4
+ static GetTCodeFromTaxes(item: any): any;
2
5
  static GetTotalsValue(opCodesList: any, argPartsList: any, IsTaxable: boolean, DetailedTotalsInfo: boolean, TaxCodes: any, Tax: any, ReturnPartsAlso: boolean, HasNoTax: boolean, GetSubTotal: boolean, Discount: number, DiscInPerc: boolean, Adjust: number, EntitySettings: any): any;
3
6
  static CalculateLaborValues(opCodesList: any, IsIndependentTax: boolean, DecimalsNumber: number): any;
4
7
  static ResetLaborValues(opCodesList: any, IsIndependentTax: boolean, DecimalsNumber: number): any;
@@ -5,6 +5,30 @@ const code_enums_1 = require("../../enums/code-enums");
5
5
  const math_operations_1 = require("../../shared/math-operations");
6
6
  const tr_utils_1 = require("../../utils/tr-utils");
7
7
  class PurchaseOrderTotalsService {
8
+ static GetTaxAmountFromTaxes(item, taxCode) {
9
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
10
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
11
+ if (matchedTaxes.length !== 0) {
12
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
13
+ }
14
+ return 0;
15
+ }
16
+ static GetTaxRateFromTaxes(item, taxCode) {
17
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
18
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
19
+ if (matchedTaxes.length !== 0) {
20
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
21
+ }
22
+ return 0;
23
+ }
24
+ static GetTCodeFromTaxes(item) {
25
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
26
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
27
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
28
+ return matchedTax.TaxCodeId;
29
+ }
30
+ return item === null || item === void 0 ? void 0 : item.TCode;
31
+ }
8
32
  static GetTotalsValue(opCodesList, argPartsList, IsTaxable, DetailedTotalsInfo, TaxCodes, Tax, ReturnPartsAlso, HasNoTax, GetSubTotal, Discount, DiscInPerc, Adjust, EntitySettings) {
9
33
  let PartsList = tr_utils_1.TrUtils.IsNull(argPartsList) ? [] : tr_utils_1.TrUtils.Stringify(argPartsList);
10
34
  // PartsList = this.ResetPartValuesIfInvalid(PartsList);
@@ -65,9 +89,10 @@ class PurchaseOrderTotalsService {
65
89
  Operation.UnCo = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.UnCo);
66
90
  Operation.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.RecDisc);
67
91
  Operation.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.Disc);
68
- Operation.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.CGST);
69
- Operation.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.SGST);
70
- Operation.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.IGST);
92
+ Operation.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'CGST') || Operation.CGST);
93
+ Operation.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'SGST') || Operation.SGST);
94
+ Operation.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'IGST') || Operation.IGST);
95
+ Operation.TCode = this.GetTCodeFromTaxes(Operation);
71
96
  return Operation;
72
97
  }
73
98
  static CheckPartStatusAndReturn(PartsList) {
@@ -83,9 +108,10 @@ class PurchaseOrderTotalsService {
83
108
  }
84
109
  Part.UnCo = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.UnCo);
85
110
  Part.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.Disc);
86
- Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.SGST);
87
- Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.IGST);
88
- Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CGST);
111
+ Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'SGST') || Part.SGST);
112
+ Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'IGST') || Part.IGST);
113
+ Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'CGST') || Part.CGST);
114
+ Part.TCode = this.GetTCodeFromTaxes(Part);
89
115
  // }
90
116
  return Part;
91
117
  }
@@ -241,9 +267,9 @@ class PurchaseOrderTotalsService {
241
267
  finalTotalsData.PartSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[1]);
242
268
  finalTotalsData.PartIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[2]);
243
269
  let ServiceTaxAmt = this.GetServicesGSTTaxTotal(LaborList);
244
- finalTotalsData.ServieCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[0]);
245
- finalTotalsData.ServieSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[1]);
246
- finalTotalsData.ServieIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[2]);
270
+ finalTotalsData.ServieCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[0]);
271
+ finalTotalsData.ServieSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[1]);
272
+ finalTotalsData.ServieIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[2]);
247
273
  finalTotalsData.PartAfterTax = (0, math_operations_1.Add)(finalTotalsData.PartsTotalAfterDisc, finalTotalsData.TaxTotal);
248
274
  finalTotalsData.ServiceAfterTax = (0, math_operations_1.Add)(finalTotalsData.ServiceTotalAfterDisc, finalTotalsData.ServiceTaxTotal);
249
275
  finalTotalsData.IsTaxable = IsTaxable;
@@ -434,13 +460,10 @@ class PurchaseOrderTotalsService {
434
460
  if (tr_utils_1.TrUtils.IsNull(Part.HSN)) {
435
461
  Part.HSN = '';
436
462
  }
437
- let TaxInfo = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
438
- Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
439
- Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
440
- Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
441
- // Part.CGSTAmt = this.GetCGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
442
- // Part.SGSTAmt = this.GetSGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
443
- // Part.IGSTAmt = this.GetIGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
463
+ Part.TCode = this.GetTCodeFromTaxes(Part);
464
+ Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'CGST'));
465
+ Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'SGST'));
466
+ Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'IGST'));
444
467
  Part.CombinedTaxPercentage = (0, math_operations_1.Add)(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
445
468
  });
446
469
  return Items;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.50",
3
+ "version": "1.6.52",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",