shareneus 1.7.332 → 1.7.334

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.
@@ -235,6 +235,7 @@ function GetTCodeFromTaxes(item) {
235
235
  return item === null || item === void 0 ? void 0 : item.TCode;
236
236
  }
237
237
  function GetLaborPrintInfo(LaborList, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
238
+ console.log('LaborList', LaborList);
238
239
  LaborList.forEach((Labor) => {
239
240
  Labor.HSN = Labor.SAC;
240
241
  if (tr_utils_1.TrUtils.IsNull(Labor.Qty)) {
@@ -242,9 +243,11 @@ function GetLaborPrintInfo(LaborList, Consolidate, TaxCodes, LineTotal, Decimals
242
243
  }
243
244
  if (Consolidate) {
244
245
  Labor.UnPr = tr_utils_1.TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
246
+ Labor.Pr = tr_utils_1.TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
245
247
  }
246
248
  else {
247
249
  Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
250
+ Labor.Pr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
248
251
  }
249
252
  if (!tr_utils_1.TrUtils.IsEmpty(Labor.Perc)) {
250
253
  Labor.DiscPerc = Labor.Perc;
@@ -55,6 +55,7 @@ class InvoiceTotalsService {
55
55
  }
56
56
  static CalculateLaborValues(opCodesList, IsIndependentTax) {
57
57
  opCodesList = this.ResetLaborValues(opCodesList, IsIndependentTax);
58
+ console.log('opCodesList', opCodesList);
58
59
  // opCodesList = this.GetOperationsDiscountPrice(opCodesList);
59
60
  // opCodesList = this.GetOperationsAfterDiscount(opCodesList,IsIndependentTax);
60
61
  // opCodesList = this.GetOperationsAfterTax(opCodesList, IsIndependentTax);
@@ -80,10 +80,8 @@ function GetItemPriceForPriceList(item, priceList, includeMargin = false, quanti
80
80
  if (includeMargin && (0, util_1.IsNotNull)(element.Cost)) {
81
81
  element.Margin = (0, math_operations_1.GetMarginValue)(element.Price, element.Cost);
82
82
  }
83
- console.log('element', element);
84
83
  }
85
84
  }
86
- console.log('item after price list application', item);
87
85
  return item;
88
86
  }
89
87
  return CalculatePriceBasedOnPriceList(item, priceList, includeMargin, resolvedQty);
@@ -146,10 +144,6 @@ function CalculatePriceBasedOnPriceList(item, priceList, includeMargin, quantity
146
144
  if (priceList.Fixed && (0, util_1.IsNotNull)(priceList.Fixed.Price)) {
147
145
  const fixedPrice = priceList.Fixed.Price;
148
146
  const fixedDisc = priceList.Fixed.Disc || 0;
149
- console.log('Track', item.Track);
150
- console.log('Batches', item.Batches);
151
- console.log('is Array', Array.isArray(item.Batches));
152
- console.log('condition', item.Track === "BN" && Array.isArray(item.Batches));
153
147
  if (item.Track === "TR" || item.Track === "SN") {
154
148
  item.Sale["MRP"] = item.Sale.Price;
155
149
  if ((0, util_1.IsNotNull)(fixedDisc) && fixedDisc > 0) {
@@ -164,7 +158,6 @@ function CalculatePriceBasedOnPriceList(item, priceList, includeMargin, quantity
164
158
  }
165
159
  else if (item.Track === "BN" && Array.isArray(item.Batches)) {
166
160
  for (const batch of item.Batches) {
167
- console.log('element batch before price calculation', batch);
168
161
  batch.MRP = batch.Price;
169
162
  if ((0, util_1.IsNotNull)(fixedDisc) && fixedDisc > 0) {
170
163
  batch.Price = CalcItemFinalSalePrice(fixedPrice, fixedDisc, priceList);
@@ -175,7 +168,6 @@ function CalculatePriceBasedOnPriceList(item, priceList, includeMargin, quantity
175
168
  if (includeMargin && (0, util_1.IsNotNull)(batch.Cost)) {
176
169
  batch.Margin = (0, math_operations_1.GetMarginValue)(batch.Price, batch.Cost);
177
170
  }
178
- console.log('element batch', batch);
179
171
  }
180
172
  }
181
173
  }
@@ -223,7 +215,6 @@ function CalculatePriceBasedOnPriceList(item, priceList, includeMargin, quantity
223
215
  }
224
216
  }
225
217
  }
226
- console.log('item after price list application', item);
227
218
  return item;
228
219
  }
229
220
  function ApplyRounding(price, priceList) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.332",
3
+ "version": "1.7.334",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,525 +9,528 @@ import { TrUtils } from '../../utils/tr-utils';
9
9
  import { InvoiceTotalsService } from './invoice-total.service';
10
10
 
11
11
  export function GetInvoicePrintInfo(OriginalInvoiceData: any, OriginalEntityData: any, image: any,
12
- IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
12
+ IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
13
13
 
14
- let ForInsurance: boolean = !TrUtils.IsNull(OriginalInvoiceData.BillTo) && !TrUtils.IsNull(OriginalInvoiceData.BillTo.Ins_Id);
14
+ let ForInsurance: boolean = !TrUtils.IsNull(OriginalInvoiceData.BillTo) && !TrUtils.IsNull(OriginalInvoiceData.BillTo.Ins_Id);
15
15
 
16
- let InvoicePrintData: any = {};
16
+ let InvoicePrintData: any = {};
17
17
 
18
- let argInvoiceData = TrUtils.Stringify(OriginalInvoiceData);
18
+ let argInvoiceData = TrUtils.Stringify(OriginalInvoiceData);
19
19
 
20
- if (!IncludeGST) {
21
- if (argInvoiceData.Settings.Tax === 'TI') {
22
- argInvoiceData.Settings.Tax = 'NO';
23
- }
20
+ if (!IncludeGST) {
21
+ if (argInvoiceData.Settings.Tax === 'TI') {
22
+ argInvoiceData.Settings.Tax = 'NO';
24
23
  }
24
+ }
25
25
 
26
- InvoicePrintData.IsProforma = IsProforma;
26
+ InvoicePrintData.IsProforma = IsProforma;
27
27
 
28
- InvoicePrintData.Settings = TrUtils.Stringify(argInvoiceData.Settings);
29
- InvoicePrintData.SType = TrUtils.Stringify(argInvoiceData.SType);
28
+ InvoicePrintData.Settings = TrUtils.Stringify(argInvoiceData.Settings);
29
+ InvoicePrintData.SType = TrUtils.Stringify(argInvoiceData.SType);
30
30
 
31
- let SType: any
31
+ let SType: any
32
32
 
33
- if (!TrUtils.IsNull(argInvoiceData.SType)) {
34
- SType = argInvoiceData.SType
35
- }
33
+ if (!TrUtils.IsNull(argInvoiceData.SType)) {
34
+ SType = argInvoiceData.SType
35
+ }
36
36
 
37
- InvoicePrintData = GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance,
38
- SType, argInvoiceData, IsProforma, PartsPrint, LaborPrint);
37
+ InvoicePrintData = GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, ForInsurance,
38
+ SType, argInvoiceData, IsProforma, PartsPrint, LaborPrint);
39
39
 
40
- InvoicePrintData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
40
+ InvoicePrintData.Entity = PrintSharedService.GetFormattedEntityDataForPrint(OriginalEntityData, "Invoice", OriginalInvoiceData);
41
41
 
42
- InvoicePrintData = PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
42
+ InvoicePrintData = PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
43
43
 
44
- InvoicePrintData = GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
44
+ InvoicePrintData = GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData);
45
45
 
46
- let IsTaxable: boolean = (IncludeGST && TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
46
+ let IsTaxable: boolean = (IncludeGST && TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
47
47
 
48
- let finalTotalsData: any = InvoiceTotalsService.GetTotalsValue(argInvoiceData.Ops, argInvoiceData.Items, IsTaxable,
49
- true, argInvoiceData.LDisc, argInvoiceData.LPerc, argInvoiceData.PDisc, argInvoiceData.PPerc,
50
- argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, argInvoiceData.Adjust, InvoicePrintData.Entity.Round, InvoicePrintData.Entity);
48
+ let finalTotalsData: any = InvoiceTotalsService.GetTotalsValue(argInvoiceData.Ops, argInvoiceData.Items, IsTaxable,
49
+ true, argInvoiceData.LDisc, argInvoiceData.LPerc, argInvoiceData.PDisc, argInvoiceData.PPerc,
50
+ argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, argInvoiceData.Adjust, InvoicePrintData.Entity.Round, InvoicePrintData.Entity);
51
51
 
52
- if (ConsolidateGST) {
53
- finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
54
- finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
55
- }
52
+ if (ConsolidateGST) {
53
+ finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
54
+ finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
55
+ }
56
56
 
57
- InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
57
+ InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
58
58
 
59
- InvoicePrintData.Ops = GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
59
+ InvoicePrintData.Ops = GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
60
60
 
61
- InvoicePrintData.Items = GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
61
+ InvoicePrintData.Items = GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
62
62
 
63
- argInvoiceData = ReverseItemsForInvoicePrint(argInvoiceData);
63
+ argInvoiceData = ReverseItemsForInvoicePrint(argInvoiceData);
64
64
 
65
- InvoicePrintData.PrintInfo = PrepareFormatForInvoicePrint(InvoicePrintData, ROTypeEnum.Invoice, argInvoiceData.Sts);
65
+ InvoicePrintData.PrintInfo = PrepareFormatForInvoicePrint(InvoicePrintData, ROTypeEnum.Invoice, argInvoiceData.Sts);
66
66
 
67
- InvoicePrintData = GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
67
+ InvoicePrintData = GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
68
68
 
69
- InvoicePrintData = GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
69
+ InvoicePrintData = GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData);
70
70
 
71
- let PaymentData = GetPaymentsTotal(argInvoiceData.Credits, argInvoiceData.Payments, argInvoiceData.Total, argInvoiceData.Sts, InvoicePrintData.Entity.DecimalsNumber);
72
- // if (argInvoiceData.Settings.DiscLvl !== 'REC') {
73
- // InvoicePrintData.FixedDisc = null;
74
- // }
75
- InvoicePrintData.Due = PaymentData.Due;
76
- InvoicePrintData.Paid = argInvoiceData.Receipt ? argInvoiceData.Total : PaymentData.Paid;
77
- if (!TrUtils.IsNull(PaymentData.Sts)) {
78
- InvoicePrintData.Sts = PaymentData.Sts;
79
- }
80
- InvoicePrintData.Consolidate = ConsolidateGST;
81
- InvoicePrintData.ShowDiscountColumn = false;
82
- if (!ForInsurance && !ConsolidateGST) {
83
- if (PrintSharedService.CheckItemIndexWithDisc(InvoicePrintData) !== -1) {
84
- // InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
85
- InvoicePrintData.ShowDiscountColumn = true;
86
- }
87
- }
88
- if (OriginalInvoiceData.Type === '1') {
89
- InvoicePrintData.From = 'Sales';
71
+ let PaymentData = GetPaymentsTotal(argInvoiceData.Credits, argInvoiceData.Payments, argInvoiceData.Total, argInvoiceData.Sts, InvoicePrintData.Entity.DecimalsNumber);
72
+ // if (argInvoiceData.Settings.DiscLvl !== 'REC') {
73
+ // InvoicePrintData.FixedDisc = null;
74
+ // }
75
+ InvoicePrintData.Due = PaymentData.Due;
76
+ InvoicePrintData.Paid = argInvoiceData.Receipt ? argInvoiceData.Total : PaymentData.Paid;
77
+ if (!TrUtils.IsNull(PaymentData.Sts)) {
78
+ InvoicePrintData.Sts = PaymentData.Sts;
79
+ }
80
+ InvoicePrintData.Consolidate = ConsolidateGST;
81
+ InvoicePrintData.ShowDiscountColumn = false;
82
+ if (!ForInsurance && !ConsolidateGST) {
83
+ if (PrintSharedService.CheckItemIndexWithDisc(InvoicePrintData) !== -1) {
84
+ // InvoicePrintData.ShowDiscountColumn = (InvoicePrintData.Settings.DiscLvl === 'ITM' || InvoicePrintData.Settings.DiscLvl === 'RECITM') ? true : false;
85
+ InvoicePrintData.ShowDiscountColumn = true;
90
86
  }
87
+ }
88
+ if (OriginalInvoiceData.Type === '1') {
89
+ InvoicePrintData.From = 'Sales';
90
+ }
91
91
 
92
- if (OriginalInvoiceData.isCountersale) {
93
- InvoicePrintData.From = 'Countersale';
94
- }
92
+ if (OriginalInvoiceData.isCountersale) {
93
+ InvoicePrintData.From = 'Countersale';
94
+ }
95
95
 
96
- if (TrUtils.IsNull(OriginalInvoiceData.BL)) {
97
- OriginalInvoiceData.BL = {};
98
- }
96
+ if (TrUtils.IsNull(OriginalInvoiceData.BL)) {
97
+ OriginalInvoiceData.BL = {};
98
+ }
99
99
 
100
- InvoicePrintData.BL = TrUtils.Stringify(OriginalInvoiceData.BL);
101
- OriginalInvoiceData.BL.RefNo = OriginalInvoiceData.RefNo;
102
- // console.log('InvoicePrintData', InvoicePrintData);
100
+ InvoicePrintData.BL = TrUtils.Stringify(OriginalInvoiceData.BL);
101
+ OriginalInvoiceData.BL.RefNo = OriginalInvoiceData.RefNo;
102
+ // console.log('InvoicePrintData', InvoicePrintData);
103
103
 
104
- return InvoicePrintData;
105
- }
104
+ return InvoicePrintData;
105
+ }
106
106
 
107
107
  export function GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean,
108
- ForInsurance: boolean, SType: any, OriginalInvoiceData: any, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
108
+ ForInsurance: boolean, SType: any, OriginalInvoiceData: any, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
109
109
 
110
- InvoicePrintData.ForInsurance = ForInsurance;
111
- InvoicePrintData.For = ForInsurance ? PayTypeEnum.Insurance : PayTypeEnum.Customer;
112
- InvoicePrintData.IncludeGST = IncludeGST;
113
- InvoicePrintData.ConsolidateGST = ConsolidateGST;
110
+ InvoicePrintData.ForInsurance = ForInsurance;
111
+ InvoicePrintData.For = ForInsurance ? PayTypeEnum.Insurance : PayTypeEnum.Customer;
112
+ InvoicePrintData.IncludeGST = IncludeGST;
113
+ InvoicePrintData.ConsolidateGST = ConsolidateGST;
114
114
 
115
- InvoicePrintData.ShowAccParts = true;
115
+ InvoicePrintData.ShowAccParts = true;
116
116
 
117
- InvoicePrintData.ShowIGST = (TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
117
+ InvoicePrintData.ShowIGST = (TrUtils.IsNull(SType) || (SType === 'Intra')) ? false : true;
118
118
 
119
- InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
120
- // InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
119
+ InvoicePrintData.ShowTaxColumn = (IncludeGST && !ConsolidateGST) ? true : false;
120
+ // InvoicePrintData.ShowDiscountColumn = (!ForInsurance && !ConsolidateGST) ? true : false;
121
121
 
122
- InvoicePrintData = GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, PartsPrint, LaborPrint);
122
+ InvoicePrintData = GetInvoiceTypeHeading(InvoicePrintData, OriginalInvoiceData, IncludeGST, ConsolidateGST, IsProforma, PartsPrint, LaborPrint);
123
123
 
124
- InvoicePrintData.PrDate = TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
124
+ InvoicePrintData.PrDate = TrUtils.IsNull(OriginalInvoiceData.PrDate) ? '' : MyDate.ConvertUTCDateToReadable(OriginalInvoiceData.PrDate);
125
125
 
126
- return InvoicePrintData;
127
- }
126
+ return InvoicePrintData;
127
+ }
128
128
 
129
129
  export function GetInvoiceTypeHeading(InvoicePrintData: any, OriginalInvoiceData: any, IncludeGST: boolean,
130
- ConsolidateGST: boolean, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
131
- // console.log(IsProforma,PartsPrint,LaborPrint);
132
- if (OriginalInvoiceData.CheckParts) {
133
- InvoicePrintData.HeaderName = "Spares Issue";
134
- } else if (OriginalInvoiceData.isCountersale) {
135
- InvoicePrintData.HeaderName = 'Counter Sale Invoice';
136
- } else if (IsProforma) {
137
- // InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
138
- if (PartsPrint && !LaborPrint) {
139
- InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (PARTS)';
140
- } else if (LaborPrint && !PartsPrint) {
141
- InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (LABOR)';
130
+ ConsolidateGST: boolean, IsProforma: boolean, PartsPrint: boolean, LaborPrint: boolean) {
131
+ // console.log(IsProforma,PartsPrint,LaborPrint);
132
+ if (OriginalInvoiceData.CheckParts) {
133
+ InvoicePrintData.HeaderName = "Spares Issue";
134
+ } else if (OriginalInvoiceData.isCountersale) {
135
+ InvoicePrintData.HeaderName = 'Counter Sale Invoice';
136
+ } else if (IsProforma) {
137
+ // InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
138
+ if (PartsPrint && !LaborPrint) {
139
+ InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (PARTS)';
140
+ } else if (LaborPrint && !PartsPrint) {
141
+ InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE (LABOR)';
142
+ } else {
143
+ InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
144
+ }
145
+ } else {
146
+ if (OriginalInvoiceData.Type === 'Sales') {
147
+ // if (IncludeGST && !ConsolidateGST) {
148
+ // InvoicePrintData.HeaderName = 'Parts Tax Invoice';
149
+ // } else {
150
+ // InvoicePrintData.HeaderName = 'Parts Invoice';
151
+ // }
152
+ InvoicePrintData.PrintType = 'PARTS ORDER';
153
+ if (InvoicePrintData.Settings.Tax === 'BS' || ConsolidateGST) {
154
+ InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
142
155
  } else {
143
- InvoicePrintData.HeaderName = 'PRO-FORMA INVOICE';
156
+ if (InvoicePrintData.Settings.Tax === 'TI') {
157
+ InvoicePrintData.HeaderName = 'PARTS TAX INVOICE';
158
+ } else {
159
+ InvoicePrintData.HeaderName = 'PARTS INVOICE';
160
+ }
144
161
  }
145
162
  } else {
146
- if (OriginalInvoiceData.Type === 'Sales') {
147
- // if (IncludeGST && !ConsolidateGST) {
148
- // InvoicePrintData.HeaderName = 'Parts Tax Invoice';
149
- // } else {
150
- // InvoicePrintData.HeaderName = 'Parts Invoice';
151
- // }
152
- InvoicePrintData.PrintType = 'PARTS ORDER';
153
- if (InvoicePrintData.Settings.Tax === 'BS' || ConsolidateGST) {
154
- InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
163
+ // if (IncludeGST && !ConsolidateGST) {
164
+ // InvoicePrintData.HeaderName = 'Tax Invoice';
165
+ // } else {
166
+ // InvoicePrintData.HeaderName = 'Invoice';
167
+ // }
168
+
169
+ if (InvoicePrintData.Settings.Tax === 'BS') {
170
+ // InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
171
+ if (PartsPrint && !LaborPrint) {
172
+ InvoicePrintData.HeaderName = 'BILL OF SUPPLY (PARTS)';
173
+ } else if (LaborPrint && !PartsPrint) {
174
+ InvoicePrintData.HeaderName = 'BILL OF SUPPLY (LABOR)';
155
175
  } else {
156
- if (InvoicePrintData.Settings.Tax === 'TI') {
157
- InvoicePrintData.HeaderName = 'PARTS TAX INVOICE';
158
- } else {
159
- InvoicePrintData.HeaderName = 'PARTS INVOICE';
160
- }
176
+ InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
161
177
  }
162
178
  } else {
163
- // if (IncludeGST && !ConsolidateGST) {
164
- // InvoicePrintData.HeaderName = 'Tax Invoice';
165
- // } else {
166
- // InvoicePrintData.HeaderName = 'Invoice';
167
- // }
168
-
169
- if (InvoicePrintData.Settings.Tax === 'BS') {
170
- // InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
171
- if (PartsPrint && !LaborPrint) {
172
- InvoicePrintData.HeaderName = 'BILL OF SUPPLY (PARTS)';
173
- } else if (LaborPrint && !PartsPrint) {
174
- InvoicePrintData.HeaderName = 'BILL OF SUPPLY (LABOR)';
179
+ if (InvoicePrintData.Settings.Tax === 'TI') {
180
+ if (OriginalInvoiceData.Receipt) {
181
+ InvoicePrintData.HeaderName = 'TAX SALES RECEIPT';
175
182
  } else {
176
- InvoicePrintData.HeaderName = 'BILL OF SUPPLY';
177
- }
178
- } else {
179
- if (InvoicePrintData.Settings.Tax === 'TI') {
180
- if (OriginalInvoiceData.Receipt) {
181
- InvoicePrintData.HeaderName = 'TAX SALES RECEIPT';
183
+ if (PartsPrint && !LaborPrint) {
184
+ InvoicePrintData.HeaderName = 'TAX INVOICE (PARTS)';
185
+ } else if (LaborPrint && !PartsPrint) {
186
+ InvoicePrintData.HeaderName = 'TAX INVOICE (LABOR)';
182
187
  } else {
183
- if (PartsPrint && !LaborPrint) {
184
- InvoicePrintData.HeaderName = 'TAX INVOICE (PARTS)';
185
- } else if (LaborPrint && !PartsPrint) {
186
- InvoicePrintData.HeaderName = 'TAX INVOICE (LABOR)';
187
- } else {
188
- InvoicePrintData.HeaderName = 'TAX INVOICE';
189
- }
190
-
188
+ InvoicePrintData.HeaderName = 'TAX INVOICE';
191
189
  }
192
190
 
193
- } else {
194
- if (OriginalInvoiceData.Receipt) {
195
- InvoicePrintData.HeaderName = 'SALES RECEIPT';
191
+ }
196
192
 
193
+ } else {
194
+ if (OriginalInvoiceData.Receipt) {
195
+ InvoicePrintData.HeaderName = 'SALES RECEIPT';
196
+
197
+ } else {
198
+ // InvoicePrintData.HeaderName = 'INVOICE';
199
+ if (PartsPrint && !LaborPrint) {
200
+ InvoicePrintData.HeaderName = 'INVOICE (PARTS)';
201
+ } else if (LaborPrint && !PartsPrint) {
202
+ InvoicePrintData.HeaderName = 'INVOICE (LABOR)';
197
203
  } else {
198
- // InvoicePrintData.HeaderName = 'INVOICE';
199
- if (PartsPrint && !LaborPrint) {
200
- InvoicePrintData.HeaderName = 'INVOICE (PARTS)';
201
- } else if (LaborPrint && !PartsPrint) {
202
- InvoicePrintData.HeaderName = 'INVOICE (LABOR)';
203
- } else {
204
- InvoicePrintData.HeaderName = 'INVOICE';
205
- }
204
+ InvoicePrintData.HeaderName = 'INVOICE';
206
205
  }
207
206
  }
208
207
  }
209
208
  }
210
209
  }
211
- return InvoicePrintData;
212
210
  }
211
+ return InvoicePrintData;
212
+ }
213
213
 
214
214
  export function GetInvoiceOtherDetailsForPrint(InvoicePrintData: any, argInvoiceData: any) {
215
- InvoicePrintData.Type = argInvoiceData.isCountersale ? 'SalesReceipt' : argInvoiceData.CheckParts ? 'Work Order' : 'Invoice';
216
- InvoicePrintData._id = argInvoiceData.Code;
217
- InvoicePrintData.ROCode = argInvoiceData.OrdCode;
218
- InvoicePrintData.ROCode = argInvoiceData.OrdCode;
219
- InvoicePrintData.TypeName = argInvoiceData.TypeName;
220
- InvoicePrintData.Sts = argInvoiceData.Sts;
221
- InvoicePrintData.AdmNo = argInvoiceData.AdmNo;
222
- InvoicePrintData.CrDate = MyDate.ConvertUTCDateToReadable(argInvoiceData.CrDate);
223
- return InvoicePrintData;
224
- }
215
+ InvoicePrintData.Type = argInvoiceData.isCountersale ? 'SalesReceipt' : argInvoiceData.CheckParts ? 'Work Order' : 'Invoice';
216
+ InvoicePrintData._id = argInvoiceData.Code;
217
+ InvoicePrintData.ROCode = argInvoiceData.OrdCode;
218
+ InvoicePrintData.ROCode = argInvoiceData.OrdCode;
219
+ InvoicePrintData.TypeName = argInvoiceData.TypeName;
220
+ InvoicePrintData.Sts = argInvoiceData.Sts;
221
+ InvoicePrintData.AdmNo = argInvoiceData.AdmNo;
222
+ InvoicePrintData.CrDate = MyDate.ConvertUTCDateToReadable(argInvoiceData.CrDate);
223
+ return InvoicePrintData;
224
+ }
225
225
 
226
226
  export function GetTaxAmountFromTaxes(item: any, taxCode: string) {
227
- const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
228
- const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
229
- if (matchedTaxes.length !== 0) {
230
- return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
231
- }
232
- return 0;
227
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
228
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
229
+ if (matchedTaxes.length !== 0) {
230
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
233
231
  }
232
+ return 0;
233
+ }
234
234
 
235
235
  export function GetTaxRateFromTaxes(item: any, taxCode: string) {
236
- const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
237
- const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
238
- if (matchedTaxes.length !== 0) {
239
- return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
240
- }
241
- return 0;
236
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
237
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
238
+ if (matchedTaxes.length !== 0) {
239
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
242
240
  }
241
+ return 0;
242
+ }
243
243
 
244
244
  export function GetTCodeFromTaxes(item: any) {
245
- const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
246
- const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
247
- if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
248
- return matchedTax.TaxCodeId;
249
- }
250
- return item?.TCode;
245
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
246
+ const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
247
+ if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
248
+ return matchedTax.TaxCodeId;
251
249
  }
250
+ return item?.TCode;
251
+ }
252
252
 
253
253
  export function GetLaborPrintInfo(LaborList: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
254
- LaborList.forEach((Labor: any) => {
255
- Labor.HSN = Labor.SAC;
256
- if (TrUtils.IsNull(Labor.Qty)) {
257
- Labor.Qty = 1;
258
- }
259
- if (Consolidate) {
260
- Labor.UnPr = TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
261
- } else {
262
- Labor.UnPr = TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
263
- }
264
- if (!TrUtils.IsEmpty(Labor.Perc)) {
265
- Labor.DiscPerc = Labor.Perc;
266
- } else {
267
- Labor.DiscPerc = Labor.Perc;
268
- if (!TrUtils.IsZero(Number(Labor.UnPr))) {
269
- Labor.DiscPerc = Divide(Multiply(100, Labor.Disc), Labor.UnPr);
270
- } else {
271
- Labor.DiscPerc = 0;
272
- }
273
- }
274
- Labor.TCode = GetTCodeFromTaxes(Labor);
275
- Labor.CGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'CGST'), DecimalsNumber);
276
- Labor.SGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'SGST'), DecimalsNumber);
277
- Labor.IGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'IGST'), DecimalsNumber);
278
- Labor.QtyAndUoM = Labor.Qty.toString();
279
- Labor.CGSTPerc = GetTaxRateFromTaxes(Labor, 'CGST');
280
- Labor.SGSTPerc = GetTaxRateFromTaxes(Labor, 'SGST');
281
- Labor.IGSTPerc = GetTaxRateFromTaxes(Labor, 'IGST');
282
- Labor.TaxName = getTaxName(Labor.TCode, TaxCodes);
283
- if (LineTotal === 'AT') {
284
- Labor.LineTotal = TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
254
+ console.log('LaborList', LaborList);
255
+ LaborList.forEach((Labor: any) => {
256
+ Labor.HSN = Labor.SAC;
257
+ if (TrUtils.IsNull(Labor.Qty)) {
258
+ Labor.Qty = 1;
259
+ }
260
+ if (Consolidate) {
261
+ Labor.UnPr = TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
262
+ Labor.Pr = TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
263
+ } else {
264
+ Labor.UnPr = TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
265
+ Labor.Pr = TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
266
+ }
267
+ if (!TrUtils.IsEmpty(Labor.Perc)) {
268
+ Labor.DiscPerc = Labor.Perc;
269
+ } else {
270
+ Labor.DiscPerc = Labor.Perc;
271
+ if (!TrUtils.IsZero(Number(Labor.UnPr))) {
272
+ Labor.DiscPerc = Divide(Multiply(100, Labor.Disc), Labor.UnPr);
285
273
  } else {
286
- Labor.LineTotal = TrUtils.FixPriceValue(Subtract(Labor.Amt, Labor.Disc), DecimalsNumber);
274
+ Labor.DiscPerc = 0;
287
275
  }
288
- });
289
- return LaborList;
290
- }
276
+ }
277
+ Labor.TCode = GetTCodeFromTaxes(Labor);
278
+ Labor.CGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'CGST'), DecimalsNumber);
279
+ Labor.SGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'SGST'), DecimalsNumber);
280
+ Labor.IGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Labor, 'IGST'), DecimalsNumber);
281
+ Labor.QtyAndUoM = Labor.Qty.toString();
282
+ Labor.CGSTPerc = GetTaxRateFromTaxes(Labor, 'CGST');
283
+ Labor.SGSTPerc = GetTaxRateFromTaxes(Labor, 'SGST');
284
+ Labor.IGSTPerc = GetTaxRateFromTaxes(Labor, 'IGST');
285
+ Labor.TaxName = getTaxName(Labor.TCode, TaxCodes);
286
+ if (LineTotal === 'AT') {
287
+ Labor.LineTotal = TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
288
+ } else {
289
+ Labor.LineTotal = TrUtils.FixPriceValue(Subtract(Labor.Amt, Labor.Disc), DecimalsNumber);
290
+ }
291
+ });
292
+ return LaborList;
293
+ }
291
294
 
292
295
  export function GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
293
- Items.forEach((Item: any) => {
294
- if (Consolidate) {
295
- let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
296
- let CTaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'CGST'), Item.Qty);
297
- let STaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'SGST'), Item.Qty);
298
- let ITaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'IGST'), Item.Qty);
299
- Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
300
- } else {
301
- Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
302
- }
296
+ Items.forEach((Item: any) => {
297
+ if (Consolidate) {
298
+ let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
299
+ let CTaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'CGST'), Item.Qty);
300
+ let STaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'SGST'), Item.Qty);
301
+ let ITaxAmtPerItem = Divide(GetTaxAmountFromTaxes(Item, 'IGST'), Item.Qty);
302
+ Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
303
+ } else {
304
+ Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
305
+ }
303
306
 
304
- // let Index = Item['Desc'].indexOf('#{');
305
- // if (Index !== -1) {
306
- // Item.Desc1 = Item['Desc'].substring(Item['Desc'].indexOf('#{') + 2,
307
- // Item['Desc'].lastIndexOf('}#'));
308
- // }
309
- // Item.Desc = Item['Desc'].split(' #{')[0];
310
- Item.MRP = TrUtils.FixPriceValue(Item.MRP, DecimalsNumber);
311
- Item.TCode = GetTCodeFromTaxes(Item);
312
- Item.CGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'CGST'), DecimalsNumber);
313
- Item.SGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'SGST'), DecimalsNumber);
314
- Item.IGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'IGST'), DecimalsNumber);
315
- Item.TaxName = getTaxName(Item.TCode, TaxCodes);
316
- if (!TrUtils.IsEmpty(Item.Perc)) {
317
- Item.DiscPerc = Item.Perc;
318
- } else {
319
- Item.DiscPerc = Item.Perc;
320
- if (!TrUtils.IsZero(Number(Item.UnPr))) {
321
- Item.DiscPerc = Divide(Multiply(100, Item.Disc), Item.UnPr);
322
- } else {
323
- Item.DiscPerc = 0;
324
- }
325
- }
326
- Item.CGSTPerc = GetTaxRateFromTaxes(Item, 'CGST');
327
- Item.SGSTPerc = GetTaxRateFromTaxes(Item, 'SGST');
328
- Item.IGSTPerc = GetTaxRateFromTaxes(Item, 'IGST');
329
- if (LineTotal === 'AT') {
330
- Item.LineTotal = TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
331
- } else {
332
- Item.LineTotal = TrUtils.FixPriceValue(Subtract(Item.UnAmt, Item.Disc), DecimalsNumber);
333
- }
334
- if (!TrUtils.IsZero(Item.Qty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
335
- Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
336
- } else {
337
- Item.QtyAndUoM = Item.Qty + '';
338
- }
339
- if (!TrUtils.IsZero(Item.OfQty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
340
- Item.OfQtyAndUoM = Item.OfQty + ' ' + Item.UoM;
307
+ // let Index = Item['Desc'].indexOf('#{');
308
+ // if (Index !== -1) {
309
+ // Item.Desc1 = Item['Desc'].substring(Item['Desc'].indexOf('#{') + 2,
310
+ // Item['Desc'].lastIndexOf('}#'));
311
+ // }
312
+ // Item.Desc = Item['Desc'].split(' #{')[0];
313
+ Item.MRP = TrUtils.FixPriceValue(Item.MRP, DecimalsNumber);
314
+ Item.TCode = GetTCodeFromTaxes(Item);
315
+ Item.CGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'CGST'), DecimalsNumber);
316
+ Item.SGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'SGST'), DecimalsNumber);
317
+ Item.IGSTAmt = TrUtils.FixPriceValue(GetTaxAmountFromTaxes(Item, 'IGST'), DecimalsNumber);
318
+ Item.TaxName = getTaxName(Item.TCode, TaxCodes);
319
+ if (!TrUtils.IsEmpty(Item.Perc)) {
320
+ Item.DiscPerc = Item.Perc;
321
+ } else {
322
+ Item.DiscPerc = Item.Perc;
323
+ if (!TrUtils.IsZero(Number(Item.UnPr))) {
324
+ Item.DiscPerc = Divide(Multiply(100, Item.Disc), Item.UnPr);
341
325
  } else {
342
- Item.OfQtyAndUoM = Item.OfQty + '';
326
+ Item.DiscPerc = 0;
343
327
  }
344
- });
345
- return Items;
346
- }
328
+ }
329
+ Item.CGSTPerc = GetTaxRateFromTaxes(Item, 'CGST');
330
+ Item.SGSTPerc = GetTaxRateFromTaxes(Item, 'SGST');
331
+ Item.IGSTPerc = GetTaxRateFromTaxes(Item, 'IGST');
332
+ if (LineTotal === 'AT') {
333
+ Item.LineTotal = TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
334
+ } else {
335
+ Item.LineTotal = TrUtils.FixPriceValue(Subtract(Item.UnAmt, Item.Disc), DecimalsNumber);
336
+ }
337
+ if (!TrUtils.IsZero(Item.Qty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
338
+ Item.QtyAndUoM = Item.Qty + ' ' + Item.UoM;
339
+ } else {
340
+ Item.QtyAndUoM = Item.Qty + '';
341
+ }
342
+ if (!TrUtils.IsZero(Item.OfQty) && !TrUtils.CheckInvalidSelect(Item.UoM)) {
343
+ Item.OfQtyAndUoM = Item.OfQty + ' ' + Item.UoM;
344
+ } else {
345
+ Item.OfQtyAndUoM = Item.OfQty + '';
346
+ }
347
+ });
348
+ return Items;
349
+ }
347
350
 
348
351
  export function getTaxName(TCode: any, TaxCodes: any) {
349
- let Index: any = TaxCodes.findIndex((TaxCode: any) => {
350
- return Number(TCode) === TaxCode._id;
351
- });
352
- return (Index !== -1) ? TaxCodes[Index].Name : '';
353
- }
352
+ let Index: any = TaxCodes.findIndex((TaxCode: any) => {
353
+ return Number(TCode) === TaxCode._id;
354
+ });
355
+ return (Index !== -1) ? TaxCodes[Index].Name : '';
356
+ }
354
357
 
355
358
  export function ReverseItemsForInvoicePrint(argInvoiceData: any) {
356
- argInvoiceData.Ops = argInvoiceData.Ops;
357
- argInvoiceData.Items = argInvoiceData.Items;
358
- return argInvoiceData;
359
- }
359
+ argInvoiceData.Ops = argInvoiceData.Ops;
360
+ argInvoiceData.Items = argInvoiceData.Items;
361
+ return argInvoiceData;
362
+ }
360
363
 
361
364
  export function PrepareFormatForInvoicePrint(InvoicePrintData: any, ROType: any, InvoiceStatus: any) {
362
- let PrintInfo: any[] = [];
365
+ let PrintInfo: any[] = [];
363
366
 
364
- let ROLaborParts: any = {};
367
+ let ROLaborParts: any = {};
365
368
 
366
- ROLaborParts.Ops = InvoicePrintData.Ops;
369
+ ROLaborParts.Ops = InvoicePrintData.Ops;
367
370
 
368
- ROLaborParts.Items = InvoicePrintData.Items;
371
+ ROLaborParts.Items = InvoicePrintData.Items;
369
372
 
370
- ROLaborParts.Sts = InvoiceStatus;
371
- ROLaborParts.Type = ROType;
373
+ ROLaborParts.Sts = InvoiceStatus;
374
+ ROLaborParts.Type = ROType;
372
375
 
373
- PrintInfo.push(ROLaborParts);
374
- return PrintInfo;
375
- }
376
+ PrintInfo.push(ROLaborParts);
377
+ return PrintInfo;
378
+ }
376
379
 
377
380
  export function GetFormattedProductDataForPrint(argInvoiceData: any, InvoicePrintData: any) {
378
- if (!TrUtils.IsNull(argInvoiceData.Prod)) {
379
- InvoicePrintData.Product = argInvoiceData.Prod;
380
- if (TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
381
- InvoicePrintData.Product.VIN = '';
382
- }
383
- if (TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
384
- InvoicePrintData.Product.RegNo = '';
385
- }
386
- if (TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
387
- InvoicePrintData.Product.EngNo = '';
388
- }
389
- InvoicePrintData.MIn = argInvoiceData.Prod.MIn;
390
- InvoicePrintData.MOut = argInvoiceData.Prod.MOut;
381
+ if (!TrUtils.IsNull(argInvoiceData.Prod)) {
382
+ InvoicePrintData.Product = argInvoiceData.Prod;
383
+ if (TrUtils.IsNull(InvoicePrintData.Product.VIN)) {
384
+ InvoicePrintData.Product.VIN = '';
385
+ }
386
+ if (TrUtils.IsNull(InvoicePrintData.Product.RegNo)) {
387
+ InvoicePrintData.Product.RegNo = '';
391
388
  }
392
- return InvoicePrintData;
389
+ if (TrUtils.IsNull(InvoicePrintData.Product.EngNo)) {
390
+ InvoicePrintData.Product.EngNo = '';
391
+ }
392
+ InvoicePrintData.MIn = argInvoiceData.Prod.MIn;
393
+ InvoicePrintData.MOut = argInvoiceData.Prod.MOut;
393
394
  }
395
+ return InvoicePrintData;
396
+ }
394
397
 
395
398
  export function GetBillNameForInvoicePrint(argInvoiceData: any, InvoicePrintData: any) {
396
- let Customer: any = {};
397
- if (!TrUtils.IsNull(argInvoiceData.BillTo)) {
398
- Customer.Name = argInvoiceData.BillTo.Name;
399
- if (!TrUtils.IsNull(argInvoiceData.BillTo.Sltn)) {
400
- Customer.Name = argInvoiceData.BillTo.Sltn + ' ' + Customer.Name;
399
+ let Customer: any = {};
400
+ if (!TrUtils.IsNull(argInvoiceData.BillTo)) {
401
+ Customer.Name = argInvoiceData.BillTo.Name;
402
+ if (!TrUtils.IsNull(argInvoiceData.BillTo.Sltn)) {
403
+ Customer.Name = argInvoiceData.BillTo.Sltn + ' ' + Customer.Name;
404
+ }
405
+ Customer.Code = argInvoiceData.Cust?.Code;
406
+ Customer.Adrs = [];
407
+ Customer.Cons = [];
408
+ if (!TrUtils.IsNull(argInvoiceData.BillTo.Adrs)) {
409
+ Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A1);
410
+ if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.A2)) {
411
+ Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A2);
401
412
  }
402
- Customer.Code = argInvoiceData.Cust?.Code;
403
- Customer.Adrs = [];
404
- Customer.Cons = [];
405
- if (!TrUtils.IsNull(argInvoiceData.BillTo.Adrs)) {
406
- Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A1);
407
- if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.A2)) {
408
- Customer.Adrs.push(argInvoiceData.BillTo.Adrs.A2);
413
+ if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Ct)) {
414
+ let city: any = argInvoiceData.BillTo.Adrs.Ct;
415
+ if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Pin)) {
416
+ city = city + ', ' + argInvoiceData.BillTo.Adrs.StCode + '-' + argInvoiceData.BillTo.Adrs.Pin;
409
417
  }
410
- if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Ct)) {
411
- let city: any = argInvoiceData.BillTo.Adrs.Ct;
412
- if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Adrs.Pin)) {
413
- city = city + ', ' + argInvoiceData.BillTo.Adrs.StCode + '-' + argInvoiceData.BillTo.Adrs.Pin;
414
- }
415
- Customer.Adrs.push(city);
416
- }
417
- }
418
- Customer.TaxId = argInvoiceData.BillTo.TaxId;
419
- Customer.GSTIN = argInvoiceData.BillTo.TaxId?.Value;
420
- if (!TrUtils.IsNull(argInvoiceData.BillTo.DLNo)) {
421
- Customer.DLNo = argInvoiceData.BillTo.DLNo;
422
- }
423
-
424
- if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Ph)) {
425
- Customer.Cons = [
426
- {
427
- Type: 'M',
428
- No: argInvoiceData.BillTo.Ph
429
- }
430
- ];
431
- }
432
- InvoicePrintData.Customer = Customer;
433
- InvoicePrintData.Name = argInvoiceData.Name;
434
-
435
- if (!TrUtils.IsNull(argInvoiceData.BillTo.Ins_Id)) {
436
- InvoicePrintData.Cust = GetCustomerDetails(argInvoiceData);
418
+ Customer.Adrs.push(city);
437
419
  }
438
- } else if (!TrUtils.IsNull(argInvoiceData.Cust)) {
439
- Customer.Name = argInvoiceData.Cust.Name;
440
- Customer.Code = argInvoiceData.Cust.Code;
441
- Customer.Adrs = [];
442
- Customer.Cons = [];
443
- InvoicePrintData.Customer = Customer;
420
+ }
421
+ Customer.TaxId = argInvoiceData.BillTo.TaxId;
422
+ Customer.GSTIN = argInvoiceData.BillTo.TaxId?.Value;
423
+ if (!TrUtils.IsNull(argInvoiceData.BillTo.DLNo)) {
424
+ Customer.DLNo = argInvoiceData.BillTo.DLNo;
444
425
  }
445
426
 
427
+ if (!TrUtils.IsEmpty(argInvoiceData.BillTo.Ph)) {
428
+ Customer.Cons = [
429
+ {
430
+ Type: 'M',
431
+ No: argInvoiceData.BillTo.Ph
432
+ }
433
+ ];
434
+ }
435
+ InvoicePrintData.Customer = Customer;
436
+ InvoicePrintData.Name = argInvoiceData.Name;
446
437
 
447
- if (!TrUtils.IsNull(argInvoiceData.ShipTo)) {
448
- let location: any = {};
449
- location.Adrs = PrintSharedService.GetAddress(argInvoiceData.ShipTo.Adrs);
450
- let Name: any;
451
- if (TrUtils.IsNull(argInvoiceData.ShipTo.Name)) {
452
- Name = argInvoiceData.ShipTo.ConName;
453
- } else {
454
- Name = argInvoiceData.ShipTo.Name;
455
- }
456
- if (TrUtils.IsNull(Name)) {
457
- Name = '';
458
- }
459
- location.Name = Name;
460
- if (!TrUtils.IsNull(argInvoiceData.ShipTo.ConPh)) {
461
- location.Cons = [
462
- {
463
- Type: 'M',
464
- No: argInvoiceData.ShipTo.ConPh
465
- }
466
- ];
467
- }
468
-
469
- InvoicePrintData.Location = location;
438
+ if (!TrUtils.IsNull(argInvoiceData.BillTo.Ins_Id)) {
439
+ InvoicePrintData.Cust = GetCustomerDetails(argInvoiceData);
470
440
  }
471
- return InvoicePrintData;
441
+ } else if (!TrUtils.IsNull(argInvoiceData.Cust)) {
442
+ Customer.Name = argInvoiceData.Cust.Name;
443
+ Customer.Code = argInvoiceData.Cust.Code;
444
+ Customer.Adrs = [];
445
+ Customer.Cons = [];
446
+ InvoicePrintData.Customer = Customer;
472
447
  }
473
448
 
474
- export function GetCustomerDetails(argInvoiceData: any) {
475
- let Customer: any = {};
476
- Customer.Name = GetBillToName(argInvoiceData.Cust.Title, argInvoiceData.Cust.Name);
477
- Customer.Cons = [];
478
- if (!TrUtils.IsEmpty(argInvoiceData.Cust.Ph)) {
479
- Customer.Cons = [
449
+
450
+ if (!TrUtils.IsNull(argInvoiceData.ShipTo)) {
451
+ let location: any = {};
452
+ location.Adrs = PrintSharedService.GetAddress(argInvoiceData.ShipTo.Adrs);
453
+ let Name: any;
454
+ if (TrUtils.IsNull(argInvoiceData.ShipTo.Name)) {
455
+ Name = argInvoiceData.ShipTo.ConName;
456
+ } else {
457
+ Name = argInvoiceData.ShipTo.Name;
458
+ }
459
+ if (TrUtils.IsNull(Name)) {
460
+ Name = '';
461
+ }
462
+ location.Name = Name;
463
+ if (!TrUtils.IsNull(argInvoiceData.ShipTo.ConPh)) {
464
+ location.Cons = [
480
465
  {
481
466
  Type: 'M',
482
- No: argInvoiceData.Cust.Ph
467
+ No: argInvoiceData.ShipTo.ConPh
483
468
  }
484
469
  ];
485
470
  }
486
- Customer.GSTIN = argInvoiceData.Cust.GSTIN;
487
- Customer.Adrs = [];
488
- if (!TrUtils.IsNull(argInvoiceData.Cust.Adrs)) {
489
- Customer.Adrs.push(argInvoiceData.Cust.Adrs.A1);
490
- if (!TrUtils.IsEmpty(argInvoiceData.Cust.Adrs.A2)) {
491
- Customer.Adrs.push(argInvoiceData.Cust.Adrs.A2);
471
+
472
+ InvoicePrintData.Location = location;
473
+ }
474
+ return InvoicePrintData;
475
+ }
476
+
477
+ export function GetCustomerDetails(argInvoiceData: any) {
478
+ let Customer: any = {};
479
+ Customer.Name = GetBillToName(argInvoiceData.Cust.Title, argInvoiceData.Cust.Name);
480
+ Customer.Cons = [];
481
+ if (!TrUtils.IsEmpty(argInvoiceData.Cust.Ph)) {
482
+ Customer.Cons = [
483
+ {
484
+ Type: 'M',
485
+ No: argInvoiceData.Cust.Ph
492
486
  }
493
- Customer.Adrs.push(argInvoiceData.Cust.Adrs.Ct);
487
+ ];
488
+ }
489
+ Customer.GSTIN = argInvoiceData.Cust.GSTIN;
490
+ Customer.Adrs = [];
491
+ if (!TrUtils.IsNull(argInvoiceData.Cust.Adrs)) {
492
+ Customer.Adrs.push(argInvoiceData.Cust.Adrs.A1);
493
+ if (!TrUtils.IsEmpty(argInvoiceData.Cust.Adrs.A2)) {
494
+ Customer.Adrs.push(argInvoiceData.Cust.Adrs.A2);
494
495
  }
495
- Customer.ConName = argInvoiceData.Cust.ConName;
496
- Customer.ConPh = argInvoiceData.Cust.ConPhone;
497
- return Customer;
496
+ Customer.Adrs.push(argInvoiceData.Cust.Adrs.Ct);
498
497
  }
498
+ Customer.ConName = argInvoiceData.Cust.ConName;
499
+ Customer.ConPh = argInvoiceData.Cust.ConPhone;
500
+ return Customer;
501
+ }
499
502
 
500
503
  export function GetBillToName(Title: any, Name: string) {
501
- return TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
502
- }
504
+ return TrUtils.IsEmpty(Title) ? Name : Title + ' ' + Name;
505
+ }
503
506
 
504
507
  export function GetPaymentsTotal(Credits: any, InvoicePayments: any, Total: number, InvoiceStatus: string, DecimalsNumber: number) {
505
- var i = 0;
506
- let Data: any = {};
507
- let PaidTotal: any = 0;
508
- if (TrUtils.IsNull(InvoicePayments)) {
509
- InvoicePayments = [];
510
- }
511
- if (TrUtils.IsNull(Credits)) {
512
- Credits = [];
513
- }
514
- for (i = 0; i < InvoicePayments.length; i++) {
515
- PaidTotal += InvoicePayments[i].Paid;
516
- }
517
- for (i = 0; i < Credits.length; i++) {
518
- PaidTotal += Credits[i].Amt;
519
- }
520
- if (InvoiceStatus === InvoiceStatusEnum.Closed) {
521
- Data.Due = 0;
522
- } else {
523
- Data.Due = TrUtils.FixedTo(Subtract(Total, PaidTotal), DecimalsNumber);
524
- }
525
- if (Data.Due < 0) {
526
- Data.Due = 0;
527
- }
528
- if (Data.Due === 0) {
529
- Data.Sts = InvoiceStatusEnum.Closed;
530
- }
531
- Data.Paid = TrUtils.FixedTo(PaidTotal, DecimalsNumber);
532
- return Data;
508
+ var i = 0;
509
+ let Data: any = {};
510
+ let PaidTotal: any = 0;
511
+ if (TrUtils.IsNull(InvoicePayments)) {
512
+ InvoicePayments = [];
513
+ }
514
+ if (TrUtils.IsNull(Credits)) {
515
+ Credits = [];
516
+ }
517
+ for (i = 0; i < InvoicePayments.length; i++) {
518
+ PaidTotal += InvoicePayments[i].Paid;
519
+ }
520
+ for (i = 0; i < Credits.length; i++) {
521
+ PaidTotal += Credits[i].Amt;
522
+ }
523
+ if (InvoiceStatus === InvoiceStatusEnum.Closed) {
524
+ Data.Due = 0;
525
+ } else {
526
+ Data.Due = TrUtils.FixedTo(Subtract(Total, PaidTotal), DecimalsNumber);
527
+ }
528
+ if (Data.Due < 0) {
529
+ Data.Due = 0;
530
+ }
531
+ if (Data.Due === 0) {
532
+ Data.Sts = InvoiceStatusEnum.Closed;
533
533
  }
534
+ Data.Paid = TrUtils.FixedTo(PaidTotal, DecimalsNumber);
535
+ return Data;
536
+ }
@@ -71,7 +71,7 @@ export class InvoiceTotalsService {
71
71
 
72
72
  static CalculateLaborValues(opCodesList: any, IsIndependentTax: boolean) {
73
73
  opCodesList = this.ResetLaborValues(opCodesList, IsIndependentTax);
74
-
74
+ console.log('opCodesList', opCodesList);
75
75
  // opCodesList = this.GetOperationsDiscountPrice(opCodesList);
76
76
 
77
77
  // opCodesList = this.GetOperationsAfterDiscount(opCodesList,IsIndependentTax);
@@ -91,10 +91,9 @@ export function GetItemPriceForPriceList(
91
91
  if (includeMargin && IsNotNull(element.Cost)) {
92
92
  element.Margin = GetMarginValue(element.Price, element.Cost);
93
93
  }
94
- console.log('element', element);
95
94
  }
96
95
  }
97
- console.log('item after price list application', item);
96
+
98
97
  return item;
99
98
  }
100
99
 
@@ -179,10 +178,7 @@ function CalculatePriceBasedOnPriceList(
179
178
  if (priceList.Fixed && IsNotNull(priceList.Fixed.Price)) {
180
179
  const fixedPrice = priceList.Fixed.Price;
181
180
  const fixedDisc = priceList.Fixed.Disc || 0;
182
- console.log('Track', item.Track);
183
- console.log('Batches', item.Batches);
184
- console.log('is Array', Array.isArray(item.Batches));
185
- console.log('condition', item.Track === "BN" && Array.isArray(item.Batches));
181
+
186
182
  if (item.Track === "TR" || item.Track === "SN") {
187
183
  item.Sale["MRP"] = item.Sale.Price;
188
184
  if (IsNotNull(fixedDisc) && fixedDisc > 0) {
@@ -196,7 +192,6 @@ console.log('condition', item.Track === "BN" && Array.isArray(item.Batches));
196
192
  }
197
193
  } else if (item.Track === "BN" && Array.isArray(item.Batches)) {
198
194
  for (const batch of item.Batches) {
199
- console.log('element batch before price calculation', batch);
200
195
  batch.MRP = batch.Price;
201
196
  if (IsNotNull(fixedDisc) && fixedDisc > 0) {
202
197
  batch.Price = CalcItemFinalSalePrice(fixedPrice, fixedDisc, priceList);
@@ -206,7 +201,6 @@ console.log('condition', item.Track === "BN" && Array.isArray(item.Batches));
206
201
  if (includeMargin && IsNotNull(batch.Cost)) {
207
202
  batch.Margin = GetMarginValue(batch.Price, batch.Cost);
208
203
  }
209
- console.log('element batch', batch);
210
204
  }
211
205
  }
212
206
  }
@@ -255,7 +249,7 @@ console.log('condition', item.Track === "BN" && Array.isArray(item.Batches));
255
249
  }
256
250
  }
257
251
  }
258
- console.log('item after price list application', item);
252
+
259
253
  return item;
260
254
  }
261
255