shareneus 1.6.57 → 1.6.58

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.
@@ -4,6 +4,9 @@ export declare class CNPrintService {
4
4
  static GetInvoiceTypeHeading(InvoicePrintData: any, OriginalInvoiceData: any, IncludeGST: boolean, ConsolidateGST: boolean, IsProforma: boolean): any;
5
5
  static GetInvoiceOtherDetailsForPrint(InvoicePrintData: any, OriginalInvoiceData: any): any;
6
6
  static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number): any;
7
+ static GetTaxAmountFromTaxes(item: any, taxCode: string, fallbackAmount?: any): any;
8
+ static GetTaxRateFromTaxes(item: any, taxCode: string, fallbackRate?: any): any;
9
+ static GetTCodeFromTaxes(item: any): any;
7
10
  static ReverseItemsForInvoicePrint(argInvoiceData: any): any;
8
11
  static PrepareFormatForInvoicePrint(InvoicePrintData: any, ROType: any, InvoiceStatus: any): any[];
9
12
  static GetFormattedProductDataForPrint(OriginalInvoiceData: any, InvoicePrintData: any): any;
@@ -66,22 +66,26 @@ class CNPrintService {
66
66
  }
67
67
  static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
68
68
  Items.forEach((Item) => {
69
+ Item.TCode = this.GetTCodeFromTaxes(Item);
70
+ const cgstAmount = this.GetTaxAmountFromTaxes(Item, 'CGST', Item.CGST);
71
+ const sgstAmount = this.GetTaxAmountFromTaxes(Item, 'SGST', Item.SGST);
72
+ const igstAmount = this.GetTaxAmountFromTaxes(Item, 'IGST', Item.IGST);
69
73
  if (Consolidate) {
70
74
  let AfterDiscForEach = (0, math_operations_1.Divide)(Item.AfterPartDisc, Item.Qty);
71
- let CTaxAmtPerItem = (0, math_operations_1.Divide)(Item.CGST, Item.Qty);
72
- let STaxAmtPerItem = (0, math_operations_1.Divide)(Item.SGST, Item.Qty);
73
- let ITaxAmtPerItem = (0, math_operations_1.Divide)(Item.IGST, Item.Qty);
75
+ let CTaxAmtPerItem = (0, math_operations_1.Divide)(cgstAmount, Item.Qty);
76
+ let STaxAmtPerItem = (0, math_operations_1.Divide)(sgstAmount, Item.Qty);
77
+ let ITaxAmtPerItem = (0, math_operations_1.Divide)(igstAmount, Item.Qty);
74
78
  Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, math_operations_1.Add)(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
75
79
  }
76
80
  else {
77
81
  Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
78
82
  }
79
- Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
80
- Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
81
- Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
82
- Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
83
- Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
84
- Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
83
+ Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(cgstAmount, DecimalsNumber);
84
+ Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(sgstAmount, DecimalsNumber);
85
+ Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(igstAmount, DecimalsNumber);
86
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST', shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
87
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST', shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
88
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST', shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
85
89
  if (LineTotal === 'AT') {
86
90
  Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
87
91
  }
@@ -94,6 +98,30 @@ class CNPrintService {
94
98
  });
95
99
  return Items;
96
100
  }
101
+ static GetTaxAmountFromTaxes(item, taxCode, fallbackAmount = 0) {
102
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
103
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
104
+ if (matchedTaxes.length !== 0) {
105
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
106
+ }
107
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackAmount);
108
+ }
109
+ static GetTaxRateFromTaxes(item, taxCode, fallbackRate = 0) {
110
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
111
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
112
+ if (matchedTaxes.length !== 0) {
113
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
114
+ }
115
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackRate);
116
+ }
117
+ static GetTCodeFromTaxes(item) {
118
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
119
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
120
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
121
+ return matchedTax.TaxCodeId;
122
+ }
123
+ return item === null || item === void 0 ? void 0 : item.TCode;
124
+ }
97
125
  static ReverseItemsForInvoicePrint(argInvoiceData) {
98
126
  // argInvoiceData.Ops = argInvoiceData.Ops.reverse();
99
127
  argInvoiceData.Items = argInvoiceData.Items.reverse();
@@ -1,3 +1,4 @@
1
1
  export declare function GetInvoicePDF(invoiceData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], withPass?: boolean, options?: any): any;
2
+ export declare function GetCreditNotePDF(creditNoteData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
2
3
  export declare function GetSalesReceiptPDF(salesReceiptData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], withPass?: boolean, options?: any): any;
3
4
  export declare function GetBillPDF(billData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any): any;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetInvoicePDF = GetInvoicePDF;
4
+ exports.GetCreditNotePDF = GetCreditNotePDF;
4
5
  exports.GetSalesReceiptPDF = GetSalesReceiptPDF;
5
6
  exports.GetBillPDF = GetBillPDF;
6
7
  const purchase_order_print_service_1 = require("../../purchases/purchase-order/purchase-order-print.service");
@@ -8,6 +9,8 @@ const math_operations_1 = require("../../shared/math-operations");
8
9
  const tr_utils_1 = require("../../utils/tr-utils");
9
10
  const pos_receipt_pdf_1 = require("../counter-sales/pos-receipt-pdf");
10
11
  const sales_receipt_print_service_1 = require("../counter-sales/sales-receipt-print.service");
12
+ const cn_print_service_1 = require("../credit-note/cn-print.service");
13
+ const credit_note_pdf_service_1 = require("../credit-note/credit-note-pdf.service");
11
14
  const inv_print_service_1 = require("./inv-print.service");
12
15
  const invoice_pdf_service_1 = require("./invoice-pdf/invoice-pdf.service");
13
16
  const unified_invoice_pdf_service_1 = require("./unified-invoice-pdf.service");
@@ -42,6 +45,28 @@ function GetInvoicePDF(invoiceData, entityData, headerConfig, printConfig, taxCo
42
45
  }
43
46
  return invPrint;
44
47
  }
48
+ function GetCreditNotePDF(creditNoteData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], options = null) {
49
+ var _a;
50
+ if (!options) {
51
+ options = {
52
+ ShowGST: (((_a = creditNoteData === null || creditNoteData === void 0 ? void 0 : creditNoteData.Settings) === null || _a === void 0 ? void 0 : _a.Tax) === 'TI') ? true : false,
53
+ ConsolidateGST: false,
54
+ Size: 'full',
55
+ MoreDiscDetails: false,
56
+ Orientation: 'portrait'
57
+ };
58
+ }
59
+ const printConfigData = tr_utils_1.TrUtils.ConcatObjects(tr_utils_1.TrUtils.Stringify(headerConfig), tr_utils_1.TrUtils.Stringify(printConfig));
60
+ const creditNotePrintData = cn_print_service_1.CNPrintService.GetCreditNotePrintInfo(creditNoteData, entityData, image, options.ShowGST, options.ConsolidateGST, taxCodes, false);
61
+ let cnPrint;
62
+ if (options.ConsolidateGST || !options.ShowGST) {
63
+ cnPrint = credit_note_pdf_service_1.CreditNotePdfService.GetInvoicePrint(creditNotePrintData, null, false);
64
+ }
65
+ else {
66
+ cnPrint = (0, invoice_pdf_service_1.CreateInvoicePDFService)(creditNotePrintData, printConfigData, numberofCopies);
67
+ }
68
+ return cnPrint;
69
+ }
45
70
  function GetSalesReceiptPDF(salesReceiptData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], withPass = false, options = null) {
46
71
  var _a;
47
72
  if (!options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.57",
3
+ "version": "1.6.58",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",