shareneus 1.6.68 → 1.6.69

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,12 +4,15 @@ export declare class SalesPrintService {
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, isOtherIndustry: boolean, LineTotal: string, DecimalsNumber: number): any;
7
+ static GetTCodeFromTaxes(item: any): any;
7
8
  static ReverseItemsForInvoicePrint(argInvoiceData: any): any;
8
9
  static PrepareFormatForInvoicePrint(InvoicePrintData: any, ROType: any, InvoiceStatus: any): any[];
9
10
  static GetFormattedProductDataForPrint(OriginalInvoiceData: any, InvoicePrintData: any): any;
10
11
  static GetShipToForSOPrint(OriginalInvoiceData: any, InvoicePrintData: any): any;
11
12
  static GetBillNameForInvoicePrint(OriginalInvoiceData: any, InvoicePrintData: any): any;
12
13
  static GetCustomerDetails(OriginalInvoiceData: any): any;
14
+ static GetTaxAmountFromTaxes(item: any, taxCode: string, fallbackAmount?: any): any;
15
+ static GetTaxRateFromTaxes(item: any, taxCode: string, fallbackRate?: any): any;
13
16
  static GetBillToName(Title: any, Name: string): string;
14
17
  static GetPaymentsTotal(InvoicePayments: any, Total: number, InvoiceStatus: string, DecimalsNumber: number): any;
15
18
  }
@@ -104,19 +104,19 @@ class SalesPrintService {
104
104
  let DiscAmt = 0;
105
105
  Items.forEach((Item) => {
106
106
  if (tr_utils_1.TrUtils.IsNull(Item.Type) || Item.Type === 'Lab') {
107
+ const cgst = this.GetTaxAmountFromTaxes(Item, 'CGST');
108
+ const sgst = this.GetTaxAmountFromTaxes(Item, 'SGST');
109
+ const igst = this.GetTaxAmountFromTaxes(Item, 'IGST');
107
110
  Amt = Amt + tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.UnAmt);
108
111
  DiscAmt = DiscAmt + tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.Disc) + tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.RecDisc);
109
- TaxAmt = TaxAmt + tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.CGST) + tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.SGST)
110
- + tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.IGST);
112
+ TaxAmt = TaxAmt + cgst + sgst + igst;
111
113
  let NetAmt = (0, math_operations_1.Subtract)(Item.UnAmt, Item.Disc, Item.RecDisc);
112
- TotalAmt = TotalAmt + tr_utils_1.TrUtils.SetValueToZeroIfNull(NetAmt) +
113
- tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.CGST) + tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.SGST)
114
- + tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.IGST);
114
+ TotalAmt = TotalAmt + tr_utils_1.TrUtils.SetValueToZeroIfNull(NetAmt) + cgst + sgst + igst;
115
115
  if (Consolidate) {
116
116
  let AfterDiscForEach = (0, math_operations_1.Divide)(Item.AfterItemDisc, Item.Qty);
117
- let CTaxAmtPerItem = (0, math_operations_1.Divide)(Item.CGST, Item.Qty);
118
- let STaxAmtPerItem = (0, math_operations_1.Divide)(Item.SGST, Item.Qty);
119
- let ITaxAmtPerItem = (0, math_operations_1.Divide)(Item.IGST, Item.Qty);
117
+ let CTaxAmtPerItem = (0, math_operations_1.Divide)(cgst, Item.Qty);
118
+ let STaxAmtPerItem = (0, math_operations_1.Divide)(sgst, Item.Qty);
119
+ let ITaxAmtPerItem = (0, math_operations_1.Divide)(igst, Item.Qty);
120
120
  Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, math_operations_1.Add)(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
121
121
  }
122
122
  else {
@@ -125,12 +125,13 @@ class SalesPrintService {
125
125
  if (isOtherIndustry && tr_utils_1.TrUtils.IsNull(Item.Type) && !tr_utils_1.TrUtils.IsNull(Item.Model) && !tr_utils_1.TrUtils.IsNull(Item.TR)) {
126
126
  Item.Desc = Item.Desc + '( ' + Item.Model + ', ' + Item.TR + ' TR )';
127
127
  }
128
- Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
129
- Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
130
- Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
131
- Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
132
- Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
133
- Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
128
+ Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(cgst, DecimalsNumber);
129
+ Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(sgst, DecimalsNumber);
130
+ Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(igst, DecimalsNumber);
131
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST');
132
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST');
133
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST');
134
+ Item.TCode = this.GetTCodeFromTaxes(Item);
134
135
  if (LineTotal === 'AT') {
135
136
  Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterItemTax, DecimalsNumber);
136
137
  }
@@ -162,6 +163,14 @@ class SalesPrintService {
162
163
  });
163
164
  return Items;
164
165
  }
166
+ static GetTCodeFromTaxes(item) {
167
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
168
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
169
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
170
+ return matchedTax.TaxCodeId;
171
+ }
172
+ return item === null || item === void 0 ? void 0 : item.TCode;
173
+ }
165
174
  static ReverseItemsForInvoicePrint(argInvoiceData) {
166
175
  // argInvoiceData.Ops = argInvoiceData.Ops.reverse();
167
176
  argInvoiceData.Items = argInvoiceData.Items.reverse();
@@ -279,6 +288,22 @@ class SalesPrintService {
279
288
  Customer.ConPh = OriginalInvoiceData.Cust.ConPhone;
280
289
  return Customer;
281
290
  }
291
+ static GetTaxAmountFromTaxes(item, taxCode, fallbackAmount = 0) {
292
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
293
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
294
+ if (matchedTaxes.length !== 0) {
295
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
296
+ }
297
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackAmount);
298
+ }
299
+ static GetTaxRateFromTaxes(item, taxCode, fallbackRate = 0) {
300
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
301
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
302
+ if (matchedTaxes.length !== 0) {
303
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
304
+ }
305
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackRate);
306
+ }
282
307
  static GetBillToName(Title, Name) {
283
308
  return tr_utils_1.TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
284
309
  }
@@ -3,6 +3,7 @@ export declare class SalesTotalsService {
3
3
  static CalculateLaborItemValues(ItemsList: any, IsIndependentTax: boolean): any;
4
4
  static ResetLaborItemValues(ItemsList: any, IsIndependentTax: boolean): any;
5
5
  static ResetLaborItemValueIfInvalid(Item: any): any;
6
+ static GetTCodeFromTaxes(item: any): any;
6
7
  static GetFinalRODataForSave(ItemsList: any, IsIndependentTax: boolean, PDisc: string, PPerc: string, Disc: any, Perc: string, DetailedInfo: boolean, Settings: any, isRoundable: boolean, DecimalsNumber: number): any;
7
8
  static SetMainDiscountValues(PPerc: string, PDisc: any, Disc: any, Perc: string, finalTotalsData: any, DetailedInfo: boolean): any;
8
9
  static GetFinalCustomerTotalsData(finalTotalsData: any, ItemsList: any, IsIndependentTax: boolean, DetailedInfo: boolean, isRoundable: boolean, DecimalsNumber: number): any;
@@ -51,8 +51,17 @@ class SalesTotalsService {
51
51
  Item.CGST = this.GetTaxAmountFromTaxes(Item, 'CGST');
52
52
  Item.SGST = this.GetTaxAmountFromTaxes(Item, 'SGST');
53
53
  Item.IGST = this.GetTaxAmountFromTaxes(Item, 'IGST');
54
+ Item.TCode = this.GetTCodeFromTaxes(Item);
54
55
  return Item;
55
56
  }
57
+ static GetTCodeFromTaxes(item) {
58
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
59
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
60
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
61
+ return matchedTax.TaxCodeId;
62
+ }
63
+ return item === null || item === void 0 ? void 0 : item.TCode;
64
+ }
56
65
  static GetFinalRODataForSave(ItemsList, IsIndependentTax, PDisc, PPerc, Disc, Perc, DetailedInfo, Settings, isRoundable, DecimalsNumber) {
57
66
  let finalTotalsData = {};
58
67
  finalTotalsData = this.SetMainDiscountValues(PPerc, PDisc, Disc, Perc, finalTotalsData, DetailedInfo);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.68",
3
+ "version": "1.6.69",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",