shareneus 1.6.49 → 1.6.51

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);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.49",
3
+ "version": "1.6.51",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",