shareneus 1.7.346 → 1.7.348

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.
@@ -66,6 +66,15 @@ class CNPrintService {
66
66
  }
67
67
  static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
68
68
  Items.forEach((Item) => {
69
+ const LinkCodes = Array.isArray(Item === null || Item === void 0 ? void 0 : Item.Link)
70
+ ? Item.Link
71
+ .map((Link) => Link === null || Link === void 0 ? void 0 : Link.Code)
72
+ .filter((Code) => !tr_utils_1.TrUtils.IsEmpty(Code))
73
+ .join(', ')
74
+ : '';
75
+ if (!tr_utils_1.TrUtils.IsEmpty(LinkCodes)) {
76
+ Item.Desc = Item.Desc + ' (' + LinkCodes + ')';
77
+ }
69
78
  Item.TCode = this.GetTCodeFromTaxes(Item);
70
79
  const cgstAmount = this.GetTaxAmountFromTaxes(Item, 'CGST', Item.CGST);
71
80
  const sgstAmount = this.GetTaxAmountFromTaxes(Item, 'SGST', Item.SGST);
@@ -165,6 +165,15 @@ class DebitNotePrintService {
165
165
  }
166
166
  static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
167
167
  Items.forEach((Item) => {
168
+ const LinkCodes = Array.isArray(Item === null || Item === void 0 ? void 0 : Item.Link)
169
+ ? Item.Link
170
+ .map((Link) => Link === null || Link === void 0 ? void 0 : Link.Code)
171
+ .filter((Code) => !tr_utils_1.TrUtils.IsEmpty(Code))
172
+ .join(', ')
173
+ : '';
174
+ if (!tr_utils_1.TrUtils.IsEmpty(LinkCodes)) {
175
+ Item.Desc = Item.Desc + ' (' + LinkCodes + ')';
176
+ }
168
177
  if (Consolidate) {
169
178
  let AfterDiscForEach = (0, math_operations_1.Divide)(Item.AfterPartDisc, Item.Qty);
170
179
  let CTaxAmtPerItem = (0, math_operations_1.Divide)(this.GetTaxAmountFromTaxes(Item, 'CGST'), Item.Qty);
@@ -1,9 +1,12 @@
1
1
  export declare class SalesReceivePrintService {
2
- static GetSalesReceivePrintInfo(OriginalSalesReceiveData: any, OriginalEntityData: any, image: any, IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean): any;
3
- static GetPrintConditionsBasedOnInput(SalesReceivePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean, ForInsurance: boolean, SType: any, OriginalSalesReceiveData: any, IsProforma: boolean): any;
4
- static GetSalesReceiveTypeHeading(SalesReceivePrintData: any, OriginalSalesReceiveData: any, IncludeGST: boolean, ConsolidateGST: boolean, IsProforma: boolean): any;
5
- static GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData: any, OriginalSalesReceiveData: any): any;
2
+ static GetSalesReceivePrintInfo(OriginalSalesReceiveData: any, OriginalEntityData: any, image: any, IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, HeaderName: string): any;
3
+ static GetPrintConditionsBasedOnInput(SalesReceivePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean, ForInsurance: boolean, SType: any, OriginalSalesReceiveData: any, IsProforma: boolean, HeaderName: string): any;
4
+ static GetSalesReceiveTypeHeading(SalesReceivePrintData: any, OriginalSalesReceiveData: any, IncludeGST: boolean, ConsolidateGST: boolean, IsProforma: boolean, HeaderName: string): any;
5
+ static GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData: any, OriginalSalesReceiveData: any, HeaderName: string): any;
6
6
  static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, IsTaxable: boolean, 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 ReverseItemsForSalesReceivePrint(argSalesReceiveData: any): any;
8
11
  static PrepareFormatForSalesReceivePrint(SalesReceivePrintData: any, ROType: any, InvoiceStatus: any): any[];
9
12
  static GetFormattedProductDataForPrint(OriginalSalesReceiveData: any, SalesReceivePrintData: any): any;
@@ -9,7 +9,7 @@ const transaction_calculations_1 = require("../transaction-calculations");
9
9
  const my_date_1 = require("../utils/my-date");
10
10
  const tr_utils_1 = require("../utils/tr-utils");
11
11
  class SalesReceivePrintService {
12
- static GetSalesReceivePrintInfo(OriginalSalesReceiveData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma) {
12
+ static GetSalesReceivePrintInfo(OriginalSalesReceiveData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma, HeaderName) {
13
13
  var _a, _b;
14
14
  let ForInsurance = !tr_utils_1.TrUtils.IsNull(OriginalSalesReceiveData.BillTo.InsId);
15
15
  let SalesReceivePrintData = {};
@@ -22,10 +22,10 @@ class SalesReceivePrintService {
22
22
  SalesReceivePrintData.SType = tr_utils_1.TrUtils.Stringify(argSalesReceiveData.SType);
23
23
  SalesReceivePrintData.Items = tr_utils_1.TrUtils.Stringify(argSalesReceiveData.Items);
24
24
  let SType = tr_utils_1.TrUtils.IsNull(argSalesReceiveData.SType) ? null : argSalesReceiveData.SType;
25
- SalesReceivePrintData = this.GetPrintConditionsBasedOnInput(SalesReceivePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, argSalesReceiveData, IsProforma);
25
+ SalesReceivePrintData = this.GetPrintConditionsBasedOnInput(SalesReceivePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, argSalesReceiveData, IsProforma, HeaderName);
26
26
  SalesReceivePrintData.Entity = shared_print_service_1.PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalSalesReceiveData);
27
27
  SalesReceivePrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(SalesReceivePrintData, OriginalEntityData, image);
28
- SalesReceivePrintData = this.GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, argSalesReceiveData);
28
+ SalesReceivePrintData = this.GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, argSalesReceiveData, HeaderName);
29
29
  let IsTaxable = (IncludeGST && tr_utils_1.TrUtils.isTaxable(argSalesReceiveData.Settings.Tax)) ? true : false;
30
30
  // let finalTotalsData: any = SalesReceiveTotalsService.GetTotalsValue([], argSalesReceiveData.Items, IsTaxable,
31
31
  // true,
@@ -45,7 +45,7 @@ class SalesReceivePrintService {
45
45
  SalesReceivePrintData.Consolidate = ConsolidateGST;
46
46
  return SalesReceivePrintData;
47
47
  }
48
- static GetPrintConditionsBasedOnInput(SalesReceivePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, OriginalSalesReceiveData, IsProforma) {
48
+ static GetPrintConditionsBasedOnInput(SalesReceivePrintData, IncludeGST, ConsolidateGST, ForInsurance, SType, OriginalSalesReceiveData, IsProforma, HeaderName) {
49
49
  SalesReceivePrintData.ForInsurance = ForInsurance;
50
50
  SalesReceivePrintData.For = ForInsurance ? enums_1.PayTypeEnum.Insurance : enums_1.PayTypeEnum.Customer;
51
51
  SalesReceivePrintData.IncludeGST = IncludeGST;
@@ -54,16 +54,16 @@ class SalesReceivePrintService {
54
54
  SalesReceivePrintData.ShowIGST = (tr_utils_1.TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
55
55
  SalesReceivePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
56
56
  // SalesReceivePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
57
- SalesReceivePrintData = this.GetSalesReceiveTypeHeading(SalesReceivePrintData, OriginalSalesReceiveData, IncludeGST, ConsolidateGST, IsProforma);
57
+ SalesReceivePrintData = this.GetSalesReceiveTypeHeading(SalesReceivePrintData, OriginalSalesReceiveData, IncludeGST, ConsolidateGST, IsProforma, HeaderName);
58
58
  SalesReceivePrintData.PrDate = tr_utils_1.TrUtils.IsNull(OriginalSalesReceiveData.PrDate) ? '' : my_date_1.MyDate.ConvertUTCDateToReadable(OriginalSalesReceiveData.PrDate);
59
59
  return SalesReceivePrintData;
60
60
  }
61
- static GetSalesReceiveTypeHeading(SalesReceivePrintData, OriginalSalesReceiveData, IncludeGST, ConsolidateGST, IsProforma) {
62
- SalesReceivePrintData.HeaderName = 'Sales Receive';
61
+ static GetSalesReceiveTypeHeading(SalesReceivePrintData, OriginalSalesReceiveData, IncludeGST, ConsolidateGST, IsProforma, HeaderName) {
62
+ SalesReceivePrintData.HeaderName = HeaderName;
63
63
  return SalesReceivePrintData;
64
64
  }
65
- static GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, OriginalSalesReceiveData) {
66
- SalesReceivePrintData.Type = 'Sales Receive';
65
+ static GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, OriginalSalesReceiveData, HeaderName) {
66
+ SalesReceivePrintData.Type = HeaderName;
67
67
  SalesReceivePrintData._id = OriginalSalesReceiveData.Code;
68
68
  SalesReceivePrintData.Sts = OriginalSalesReceiveData.Sts;
69
69
  SalesReceivePrintData.CrDate = my_date_1.MyDate.ConvertUTCDateToReadable(OriginalSalesReceiveData.CrDate);
@@ -71,26 +71,30 @@ class SalesReceivePrintService {
71
71
  }
72
72
  static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, IsTaxable, DecimalsNumber) {
73
73
  Items.forEach((Item) => {
74
+ const itemCGST = this.GetTaxAmountFromTaxes(Item, 'CGST', Item.CGST);
75
+ const itemSGST = this.GetTaxAmountFromTaxes(Item, 'SGST', Item.SGST);
76
+ const itemIGST = this.GetTaxAmountFromTaxes(Item, 'IGST', Item.IGST);
77
+ Item.TCode = this.GetTCodeFromTaxes(Item);
74
78
  if (Consolidate) {
75
79
  let AfterPartDisc = (0, math_operations_1.Subtract)(Item.UnAmt, Item.Disc, Item.RecDisc);
76
80
  let AfterDiscForEach = (0, math_operations_1.Divide)(AfterPartDisc, Item.Qty);
77
- let CTaxAmtPerItem = (0, math_operations_1.Divide)(Item.CGST, Item.Qty);
78
- let STaxAmtPerItem = (0, math_operations_1.Divide)(Item.SGST, Item.Qty);
79
- let ITaxAmtPerItem = (0, math_operations_1.Divide)(Item.IGST, Item.Qty);
81
+ let CTaxAmtPerItem = (0, math_operations_1.Divide)(itemCGST, Item.Qty);
82
+ let STaxAmtPerItem = (0, math_operations_1.Divide)(itemSGST, Item.Qty);
83
+ let ITaxAmtPerItem = (0, math_operations_1.Divide)(itemIGST, Item.Qty);
80
84
  Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, math_operations_1.Add)(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
81
85
  }
82
86
  else {
83
87
  Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
84
88
  }
85
- Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
86
- Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
87
- Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
88
- Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
89
- Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
90
- Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
89
+ Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(itemCGST, DecimalsNumber);
90
+ Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(itemSGST, DecimalsNumber);
91
+ Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(itemIGST, DecimalsNumber);
92
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST', shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
93
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST', shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
94
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST', shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
91
95
  // Calculate amount after tax based on tax type
92
96
  if (IsTaxable) {
93
- Item.AfterPartTax = (0, math_operations_1.Add)(Item.AfterPartDisc, Item.CGST, Item.SGST, Item.IGST);
97
+ Item.AfterPartTax = (0, math_operations_1.Add)(Item.AfterPartDisc, itemCGST, itemSGST, itemIGST);
94
98
  }
95
99
  else {
96
100
  Item.AfterPartTax = Item.AfterPartDisc;
@@ -107,6 +111,30 @@ class SalesReceivePrintService {
107
111
  });
108
112
  return Items;
109
113
  }
114
+ static GetTaxAmountFromTaxes(item, taxCode, fallbackAmount = 0) {
115
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
116
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
117
+ if (matchedTaxes.length !== 0) {
118
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
119
+ }
120
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackAmount);
121
+ }
122
+ static GetTaxRateFromTaxes(item, taxCode, fallbackRate = 0) {
123
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
124
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
125
+ if (matchedTaxes.length !== 0) {
126
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
127
+ }
128
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackRate);
129
+ }
130
+ static GetTCodeFromTaxes(item) {
131
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
132
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
133
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
134
+ return matchedTax.TaxCodeId;
135
+ }
136
+ return item === null || item === void 0 ? void 0 : item.TCode;
137
+ }
110
138
  static ReverseItemsForSalesReceivePrint(argSalesReceiveData) {
111
139
  // argSalesReceiveData.Ops = argSalesReceiveData.Ops.reverse();
112
140
  argSalesReceiveData.Items = argSalesReceiveData.Items.reverse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.346",
3
+ "version": "1.7.348",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,7 @@ export class CNPrintService {
11
11
 
12
12
  static GetCreditNotePrintInfo(OriginalInvoiceData: any, OriginalEntityData: any, image: any,
13
13
  IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean) {
14
-
14
+
15
15
  let ForInsurance: boolean = !TrUtils.IsNull(OriginalInvoiceData.BillTo.InsId);
16
16
  let InvoicePrintData: any = {};
17
17
  let argInvoiceData = TrUtils.Stringify(OriginalInvoiceData);
@@ -38,7 +38,7 @@ export class CNPrintService {
38
38
  }
39
39
  InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
40
40
  InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes,
41
- OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
41
+ OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
42
42
  argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
43
43
  InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, ROTypeEnum.Invoice, argInvoiceData.Sts);
44
44
  InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
@@ -79,6 +79,15 @@ export class CNPrintService {
79
79
 
80
80
  static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
81
81
  Items.forEach((Item: any) => {
82
+ const LinkCodes = Array.isArray(Item?.Link)
83
+ ? Item.Link
84
+ .map((Link: any) => Link?.Code)
85
+ .filter((Code: any) => !TrUtils.IsEmpty(Code))
86
+ .join(', ')
87
+ : '';
88
+ if (!TrUtils.IsEmpty(LinkCodes)) {
89
+ Item.Desc = Item.Desc + ' (' + LinkCodes + ')';
90
+ }
82
91
  Item.TCode = this.GetTCodeFromTaxes(Item);
83
92
  const cgstAmount = this.GetTaxAmountFromTaxes(Item, 'CGST', Item.CGST);
84
93
  const sgstAmount = this.GetTaxAmountFromTaxes(Item, 'SGST', Item.SGST);
@@ -90,7 +99,7 @@ export class CNPrintService {
90
99
  let STaxAmtPerItem = Divide(sgstAmount, Item.Qty);
91
100
  let ITaxAmtPerItem = Divide(igstAmount, Item.Qty);
92
101
  Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
93
- }else{
102
+ } else {
94
103
  Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
95
104
  }
96
105
  Item.CGSTAmt = TrUtils.FixPriceValue(cgstAmount, DecimalsNumber);
@@ -200,12 +200,21 @@ export class DebitNotePrintService {
200
200
  return InvoicePrintData;
201
201
  }
202
202
 
203
- static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
204
- Items.forEach((Item: any) => {
205
- if (Consolidate) {
206
- let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
207
- let CTaxAmtPerItem = Divide(this.GetTaxAmountFromTaxes(Item, 'CGST'), Item.Qty);
208
- let STaxAmtPerItem = Divide(this.GetTaxAmountFromTaxes(Item, 'SGST'), Item.Qty);
203
+ static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
204
+ Items.forEach((Item: any) => {
205
+ const LinkCodes = Array.isArray(Item?.Link)
206
+ ? Item.Link
207
+ .map((Link: any) => Link?.Code)
208
+ .filter((Code: any) => !TrUtils.IsEmpty(Code))
209
+ .join(', ')
210
+ : '';
211
+ if (!TrUtils.IsEmpty(LinkCodes)) {
212
+ Item.Desc = Item.Desc + ' (' + LinkCodes + ')';
213
+ }
214
+ if (Consolidate) {
215
+ let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
216
+ let CTaxAmtPerItem = Divide(this.GetTaxAmountFromTaxes(Item, 'CGST'), Item.Qty);
217
+ let STaxAmtPerItem = Divide(this.GetTaxAmountFromTaxes(Item, 'SGST'), Item.Qty);
209
218
  let ITaxAmtPerItem = Divide(this.GetTaxAmountFromTaxes(Item, 'IGST'), Item.Qty);
210
219
  Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
211
220
  } else {
@@ -10,7 +10,7 @@ import { TrUtils } from '../utils/tr-utils';
10
10
  export class SalesReceivePrintService {
11
11
 
12
12
  static GetSalesReceivePrintInfo(OriginalSalesReceiveData: any, OriginalEntityData: any, image: any,
13
- IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean) {
13
+ IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, HeaderName: string) {
14
14
 
15
15
  let ForInsurance: boolean = !TrUtils.IsNull(OriginalSalesReceiveData.BillTo.InsId);
16
16
  let SalesReceivePrintData: any = {};
@@ -25,10 +25,10 @@ export class SalesReceivePrintService {
25
25
 
26
26
  let SType: any = TrUtils.IsNull(argSalesReceiveData.SType) ? null : argSalesReceiveData.SType;
27
27
  SalesReceivePrintData = this.GetPrintConditionsBasedOnInput(SalesReceivePrintData, IncludeGST, ConsolidateGST, ForInsurance,
28
- SType, argSalesReceiveData, IsProforma);
28
+ SType, argSalesReceiveData, IsProforma, HeaderName);
29
29
  SalesReceivePrintData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalSalesReceiveData);
30
30
  SalesReceivePrintData = PrintSharedService.GetEntityHeaderStyles(SalesReceivePrintData, OriginalEntityData, image);
31
- SalesReceivePrintData = this.GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, argSalesReceiveData);
31
+ SalesReceivePrintData = this.GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData, argSalesReceiveData, HeaderName);
32
32
  let IsTaxable: boolean = (IncludeGST && TrUtils.isTaxable(argSalesReceiveData.Settings.Tax)) ? true : false;
33
33
  // let finalTotalsData: any = SalesReceiveTotalsService.GetTotalsValue([], argSalesReceiveData.Items, IsTaxable,
34
34
  // true,
@@ -51,7 +51,7 @@ export class SalesReceivePrintService {
51
51
  }
52
52
 
53
53
  static GetPrintConditionsBasedOnInput(SalesReceivePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean,
54
- ForInsurance: boolean, SType: any, OriginalSalesReceiveData: any, IsProforma: boolean) {
54
+ ForInsurance: boolean, SType: any, OriginalSalesReceiveData: any, IsProforma: boolean, HeaderName: string) {
55
55
 
56
56
  SalesReceivePrintData.ForInsurance = ForInsurance;
57
57
  SalesReceivePrintData.For = ForInsurance ? PayTypeEnum.Insurance : PayTypeEnum.Customer;
@@ -61,19 +61,19 @@ export class SalesReceivePrintService {
61
61
  SalesReceivePrintData.ShowIGST = (TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
62
62
  SalesReceivePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
63
63
  // SalesReceivePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
64
- SalesReceivePrintData = this.GetSalesReceiveTypeHeading(SalesReceivePrintData, OriginalSalesReceiveData, IncludeGST, ConsolidateGST, IsProforma);
64
+ SalesReceivePrintData = this.GetSalesReceiveTypeHeading(SalesReceivePrintData, OriginalSalesReceiveData, IncludeGST, ConsolidateGST, IsProforma, HeaderName);
65
65
  SalesReceivePrintData.PrDate = TrUtils.IsNull(OriginalSalesReceiveData.PrDate) ? '' : MyDate.ConvertUTCDateToReadable(OriginalSalesReceiveData.PrDate);
66
66
  return SalesReceivePrintData;
67
67
  }
68
68
 
69
69
  static GetSalesReceiveTypeHeading(SalesReceivePrintData: any, OriginalSalesReceiveData: any, IncludeGST: boolean,
70
- ConsolidateGST: boolean, IsProforma: boolean) {
71
- SalesReceivePrintData.HeaderName = 'Sales Receive';
70
+ ConsolidateGST: boolean, IsProforma: boolean, HeaderName: string) {
71
+ SalesReceivePrintData.HeaderName = HeaderName;
72
72
  return SalesReceivePrintData;
73
73
  }
74
74
 
75
- static GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData: any, OriginalSalesReceiveData: any) {
76
- SalesReceivePrintData.Type = 'Sales Receive';
75
+ static GetSalesReceiveOtherDetailsForPrint(SalesReceivePrintData: any, OriginalSalesReceiveData: any, HeaderName: string) {
76
+ SalesReceivePrintData.Type = HeaderName;
77
77
  SalesReceivePrintData._id = OriginalSalesReceiveData.Code;
78
78
  SalesReceivePrintData.Sts = OriginalSalesReceiveData.Sts;
79
79
  SalesReceivePrintData.CrDate = MyDate.ConvertUTCDateToReadable(OriginalSalesReceiveData.CrDate);
@@ -82,25 +82,29 @@ export class SalesReceivePrintService {
82
82
 
83
83
  static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, IsTaxable:boolean, DecimalsNumber: number) {
84
84
  Items.forEach((Item: any) => {
85
+ const itemCGST = this.GetTaxAmountFromTaxes(Item, 'CGST', Item.CGST);
86
+ const itemSGST = this.GetTaxAmountFromTaxes(Item, 'SGST', Item.SGST);
87
+ const itemIGST = this.GetTaxAmountFromTaxes(Item, 'IGST', Item.IGST);
88
+ Item.TCode = this.GetTCodeFromTaxes(Item);
85
89
  if (Consolidate) {
86
90
  let AfterPartDisc = Subtract(Item.UnAmt, Item.Disc, Item.RecDisc);
87
91
  let AfterDiscForEach = Divide(AfterPartDisc, Item.Qty);
88
- let CTaxAmtPerItem = Divide(Item.CGST, Item.Qty);
89
- let STaxAmtPerItem = Divide(Item.SGST, Item.Qty);
90
- let ITaxAmtPerItem = Divide(Item.IGST, Item.Qty);
92
+ let CTaxAmtPerItem = Divide(itemCGST, Item.Qty);
93
+ let STaxAmtPerItem = Divide(itemSGST, Item.Qty);
94
+ let ITaxAmtPerItem = Divide(itemIGST, Item.Qty);
91
95
  Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
92
96
  } else {
93
97
  Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
94
98
  }
95
- Item.CGSTAmt = TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
96
- Item.SGSTAmt = TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
97
- Item.IGSTAmt = TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
98
- Item.CGSTPerc = PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
99
- Item.SGSTPerc = PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
100
- Item.IGSTPerc = PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
99
+ Item.CGSTAmt = TrUtils.FixPriceValue(itemCGST, DecimalsNumber);
100
+ Item.SGSTAmt = TrUtils.FixPriceValue(itemSGST, DecimalsNumber);
101
+ Item.IGSTAmt = TrUtils.FixPriceValue(itemIGST, DecimalsNumber);
102
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST', PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
103
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST', PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
104
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST', PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
101
105
  // Calculate amount after tax based on tax type
102
106
  if (IsTaxable) {
103
- Item.AfterPartTax = Add(Item.AfterPartDisc, Item.CGST, Item.SGST, Item.IGST);
107
+ Item.AfterPartTax = Add(Item.AfterPartDisc, itemCGST, itemSGST, itemIGST);
104
108
  } else {
105
109
  Item.AfterPartTax = Item.AfterPartDisc;
106
110
  }
@@ -116,6 +120,33 @@ export class SalesReceivePrintService {
116
120
  return Items;
117
121
  }
118
122
 
123
+ static GetTaxAmountFromTaxes(item: any, taxCode: string, fallbackAmount: any = 0) {
124
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
125
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
126
+ if (matchedTaxes.length !== 0) {
127
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
128
+ }
129
+ return TrUtils.SetValueToZeroIfNull(fallbackAmount);
130
+ }
131
+
132
+ static GetTaxRateFromTaxes(item: any, taxCode: string, fallbackRate: any = 0) {
133
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
134
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
135
+ if (matchedTaxes.length !== 0) {
136
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
137
+ }
138
+ return TrUtils.SetValueToZeroIfNull(fallbackRate);
139
+ }
140
+
141
+ static GetTCodeFromTaxes(item: any) {
142
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
143
+ const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
144
+ if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
145
+ return matchedTax.TaxCodeId;
146
+ }
147
+ return item?.TCode;
148
+ }
149
+
119
150
  static ReverseItemsForSalesReceivePrint(argSalesReceiveData: any) {
120
151
  // argSalesReceiveData.Ops = argSalesReceiveData.Ops.reverse();
121
152
  argSalesReceiveData.Items = argSalesReceiveData.Items.reverse();
@@ -239,4 +270,4 @@ export class SalesReceivePrintService {
239
270
  // Data.Paid = TrUtils.FixedTo(PaidTotal);
240
271
  // return Data;
241
272
  // }
242
- }
273
+ }