shareneus 1.6.57 → 1.6.59

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) {
@@ -59,7 +59,7 @@ export declare class ROTotalsService {
59
59
  static GetInsParts(PartsList: any): any[];
60
60
  static GetInsTaxGroupingForPartsByHSN(Parts: any, TaxCodes: any, DecimalsNumber: number): any[];
61
61
  static GetInsTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: number): any[];
62
- static GetGSTValueBasedOnTaxCode(TCode: any, TaxCodes: any): any[];
62
+ static GetGSTValueBasedOnTaxCode(item: any, TaxCodes: any): any[];
63
63
  static GetCombinedTaxPercentage(Parts: any, TaxCodes: any): any;
64
64
  static ResetPartsHSNIfInvalid(Parts: any): any;
65
65
  static ComparePartsByHSN(Parts: any, TaxCodes: any): any[];
@@ -1115,7 +1115,7 @@ class ROTotalsService {
1115
1115
  TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
1116
1116
  TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
1117
1117
  TaxInfo.PartsCount = MatchedPart.length;
1118
- let GSTValues = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
1118
+ let GSTValues = this.GetGSTValueBasedOnTaxCode(MatchedPart[0], TaxCodes);
1119
1119
  TaxInfo.CGST = GSTValues[0];
1120
1120
  TaxInfo.SGST = GSTValues[1];
1121
1121
  TaxInfo.IGST = GSTValues[2];
@@ -1168,7 +1168,7 @@ class ROTotalsService {
1168
1168
  TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
1169
1169
  TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
1170
1170
  TaxInfo.PartsCount = MatchedPart.length;
1171
- let GSTValues = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
1171
+ let GSTValues = this.GetGSTValueBasedOnTaxCode(MatchedPart[0], TaxCodes);
1172
1172
  TaxInfo.CGST = GSTValues[0];
1173
1173
  TaxInfo.SGST = GSTValues[1];
1174
1174
  TaxInfo.IGST = GSTValues[2];
@@ -1178,10 +1178,30 @@ class ROTotalsService {
1178
1178
  });
1179
1179
  return HSNTaxInfo;
1180
1180
  }
1181
- static GetGSTValueBasedOnTaxCode(TCode, TaxCodes) {
1181
+ static GetGSTValueBasedOnTaxCode(item, TaxCodes) {
1182
1182
  let CGST = 0;
1183
1183
  let SGST = 0;
1184
1184
  let IGST = 0;
1185
+ const taxGroupKeys = ['Taxes', 'CTaxes', 'ATaxes', 'ETaxes'];
1186
+ for (const taxGroupKey of taxGroupKeys) {
1187
+ const groupedTaxes = item === null || item === void 0 ? void 0 : item[taxGroupKey];
1188
+ if (!Array.isArray(groupedTaxes) || groupedTaxes.length === 0) {
1189
+ continue;
1190
+ }
1191
+ CGST = groupedTaxes
1192
+ .filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === 'CGST')
1193
+ .reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
1194
+ SGST = groupedTaxes
1195
+ .filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === 'SGST')
1196
+ .reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
1197
+ IGST = groupedTaxes
1198
+ .filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === 'IGST')
1199
+ .reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
1200
+ if (!tr_utils_1.TrUtils.IsZero((0, math_operations_1.Add)(CGST, SGST, IGST))) {
1201
+ return [CGST, SGST, IGST];
1202
+ }
1203
+ }
1204
+ const TCode = item === null || item === void 0 ? void 0 : item.TCode;
1185
1205
  if (tr_utils_1.TrUtils.IsNull(TCode)) {
1186
1206
  return [CGST, SGST, IGST];
1187
1207
  }
@@ -1202,7 +1222,7 @@ class ROTotalsService {
1202
1222
  }
1203
1223
  static GetCombinedTaxPercentage(Parts, TaxCodes) {
1204
1224
  Parts.forEach((Part) => {
1205
- let GSTValues = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
1225
+ let GSTValues = this.GetGSTValueBasedOnTaxCode(Part, TaxCodes);
1206
1226
  let CGST = GSTValues[0];
1207
1227
  let SGST = GSTValues[1];
1208
1228
  let IGST = GSTValues[2];
@@ -1231,11 +1251,11 @@ class ROTotalsService {
1231
1251
  PartFound = true;
1232
1252
  }
1233
1253
  });
1234
- let argGSTValues = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
1254
+ let argGSTValues = this.GetGSTValueBasedOnTaxCode(argPart, TaxCodes);
1235
1255
  let argCGST = argGSTValues[0];
1236
1256
  let argSGST = argGSTValues[1];
1237
1257
  let argIGST = argGSTValues[2];
1238
- let partGSTValues = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
1258
+ let partGSTValues = this.GetGSTValueBasedOnTaxCode(Part, TaxCodes);
1239
1259
  let partCGST = partGSTValues[0];
1240
1260
  let partSGST = partGSTValues[1];
1241
1261
  let partIGST = partGSTValues[2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.57",
3
+ "version": "1.6.59",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",