shareneus 1.7.347 → 1.7.349

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.
@@ -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,31 @@ 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);
78
+ Item.AfterPartDisc = (0, math_operations_1.Subtract)(Item.UnAmt, Item.Disc, Item.RecDisc);
74
79
  if (Consolidate) {
75
80
  let AfterPartDisc = (0, math_operations_1.Subtract)(Item.UnAmt, Item.Disc, Item.RecDisc);
76
81
  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);
82
+ let CTaxAmtPerItem = (0, math_operations_1.Divide)(itemCGST, Item.Qty);
83
+ let STaxAmtPerItem = (0, math_operations_1.Divide)(itemSGST, Item.Qty);
84
+ let ITaxAmtPerItem = (0, math_operations_1.Divide)(itemIGST, Item.Qty);
80
85
  Item.UnPr = tr_utils_1.TrUtils.FixedTo((0, math_operations_1.Add)(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
81
86
  }
82
87
  else {
83
88
  Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
84
89
  }
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);
90
+ Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(itemCGST, DecimalsNumber);
91
+ Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(itemSGST, DecimalsNumber);
92
+ Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(itemIGST, DecimalsNumber);
93
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST', shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
94
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST', shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
95
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST', shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
91
96
  // Calculate amount after tax based on tax type
92
97
  if (IsTaxable) {
93
- Item.AfterPartTax = (0, math_operations_1.Add)(Item.AfterPartDisc, Item.CGST, Item.SGST, Item.IGST);
98
+ Item.AfterPartTax = (0, math_operations_1.Add)(Item.AfterPartDisc, itemCGST, itemSGST, itemIGST);
94
99
  }
95
100
  else {
96
101
  Item.AfterPartTax = Item.AfterPartDisc;
@@ -107,6 +112,30 @@ class SalesReceivePrintService {
107
112
  });
108
113
  return Items;
109
114
  }
115
+ static GetTaxAmountFromTaxes(item, taxCode, fallbackAmount = 0) {
116
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
117
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
118
+ if (matchedTaxes.length !== 0) {
119
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
120
+ }
121
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackAmount);
122
+ }
123
+ static GetTaxRateFromTaxes(item, taxCode, fallbackRate = 0) {
124
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
125
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
126
+ if (matchedTaxes.length !== 0) {
127
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
128
+ }
129
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackRate);
130
+ }
131
+ static GetTCodeFromTaxes(item) {
132
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
133
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
134
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
135
+ return matchedTax.TaxCodeId;
136
+ }
137
+ return item === null || item === void 0 ? void 0 : item.TCode;
138
+ }
110
139
  static ReverseItemsForSalesReceivePrint(argSalesReceiveData) {
111
140
  // argSalesReceiveData.Ops = argSalesReceiveData.Ops.reverse();
112
141
  argSalesReceiveData.Items = argSalesReceiveData.Items.reverse();
@@ -1296,6 +1296,21 @@ class SharedPDFService {
1296
1296
  else if (Type === 'SalesOrder') {
1297
1297
  id = 'SO#';
1298
1298
  }
1299
+ else if (Type === 'Sales Return') {
1300
+ id = 'SR#';
1301
+ }
1302
+ else if (Type === 'Sales Receive') {
1303
+ id = 'SRR#';
1304
+ }
1305
+ else if (Type === 'Purchase Return') {
1306
+ id = 'PR#';
1307
+ }
1308
+ else if (Type === 'Purchase Shipment') {
1309
+ id = 'PS#';
1310
+ }
1311
+ else if (Type === 'Purchase Order') {
1312
+ id = 'PO#';
1313
+ }
1299
1314
  else if (Type === 'Sales Estimate') {
1300
1315
  id = 'Estimate#';
1301
1316
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.347",
3
+ "version": "1.7.349",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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,46 +61,51 @@ 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);
80
80
  return SalesReceivePrintData;
81
81
  }
82
82
 
83
- static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, IsTaxable:boolean, DecimalsNumber: number) {
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);
89
+ Item.AfterPartDisc = Subtract(Item.UnAmt, Item.Disc, Item.RecDisc);
85
90
  if (Consolidate) {
86
91
  let AfterPartDisc = Subtract(Item.UnAmt, Item.Disc, Item.RecDisc);
87
92
  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);
93
+ let CTaxAmtPerItem = Divide(itemCGST, Item.Qty);
94
+ let STaxAmtPerItem = Divide(itemSGST, Item.Qty);
95
+ let ITaxAmtPerItem = Divide(itemIGST, Item.Qty);
91
96
  Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
92
97
  } else {
93
98
  Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
94
99
  }
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);
101
- // Calculate amount after tax based on tax type
100
+ Item.CGSTAmt = TrUtils.FixPriceValue(itemCGST, DecimalsNumber);
101
+ Item.SGSTAmt = TrUtils.FixPriceValue(itemSGST, DecimalsNumber);
102
+ Item.IGSTAmt = TrUtils.FixPriceValue(itemIGST, DecimalsNumber);
103
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST', PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
104
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST', PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
105
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST', PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes));
106
+ // Calculate amount after tax based on tax type
102
107
  if (IsTaxable) {
103
- Item.AfterPartTax = Add(Item.AfterPartDisc, Item.CGST, Item.SGST, Item.IGST);
108
+ Item.AfterPartTax = Add(Item.AfterPartDisc, itemCGST, itemSGST, itemIGST);
104
109
  } else {
105
110
  Item.AfterPartTax = Item.AfterPartDisc;
106
111
  }
@@ -116,6 +121,33 @@ export class SalesReceivePrintService {
116
121
  return Items;
117
122
  }
118
123
 
124
+ static GetTaxAmountFromTaxes(item: any, taxCode: string, fallbackAmount: any = 0) {
125
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
126
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
127
+ if (matchedTaxes.length !== 0) {
128
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
129
+ }
130
+ return TrUtils.SetValueToZeroIfNull(fallbackAmount);
131
+ }
132
+
133
+ static GetTaxRateFromTaxes(item: any, taxCode: string, fallbackRate: any = 0) {
134
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
135
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
136
+ if (matchedTaxes.length !== 0) {
137
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
138
+ }
139
+ return TrUtils.SetValueToZeroIfNull(fallbackRate);
140
+ }
141
+
142
+ static GetTCodeFromTaxes(item: any) {
143
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
144
+ const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
145
+ if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
146
+ return matchedTax.TaxCodeId;
147
+ }
148
+ return item?.TCode;
149
+ }
150
+
119
151
  static ReverseItemsForSalesReceivePrint(argSalesReceiveData: any) {
120
152
  // argSalesReceiveData.Ops = argSalesReceiveData.Ops.reverse();
121
153
  argSalesReceiveData.Items = argSalesReceiveData.Items.reverse();
@@ -239,4 +271,4 @@ export class SalesReceivePrintService {
239
271
  // Data.Paid = TrUtils.FixedTo(PaidTotal);
240
272
  // return Data;
241
273
  // }
242
- }
274
+ }
@@ -1325,7 +1325,7 @@ export class SharedPDFService {
1325
1325
  static GetCustomerGSTIN(Customer: any) {
1326
1326
  const customerTaxId = TrUtils.IsEmpty(Customer?.TaxId?.Value) ? Customer?.GSTIN : Customer.TaxId.Value;
1327
1327
  if (!TrUtils.IsEmpty(customerTaxId)) {
1328
- let GSTIN = { columns: [{ text: Customer?.TaxId?.Label ||'GSTIN :', width: 33, style: 'hed' }, { text: customerTaxId, marginTop: 1.5 }] };
1328
+ let GSTIN = { columns: [{ text: Customer?.TaxId?.Label || 'GSTIN :', width: 33, style: 'hed' }, { text: customerTaxId, marginTop: 1.5 }] };
1329
1329
  return GSTIN;
1330
1330
  } else {
1331
1331
  return this.emptyObject();
@@ -1385,6 +1385,16 @@ export class SharedPDFService {
1385
1385
  id = 'WO#';
1386
1386
  } else if (Type === 'SalesOrder') {
1387
1387
  id = 'SO#';
1388
+ } else if (Type === 'Sales Return') {
1389
+ id = 'SR#';
1390
+ } else if (Type === 'Sales Receive') {
1391
+ id = 'SRR#';
1392
+ } else if (Type === 'Purchase Return') {
1393
+ id = 'PR#';
1394
+ } else if (Type === 'Purchase Shipment') {
1395
+ id = 'PS#';
1396
+ } else if (Type === 'Purchase Order') {
1397
+ id = 'PO#';
1388
1398
  } else if (Type === 'Sales Estimate') {
1389
1399
  id = 'Estimate#';
1390
1400
  } else if (Type === 'Debit Notes') {