shareneus 1.7.323 → 1.7.325

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,5 +1,10 @@
1
1
  export declare class DebitNotePrintService {
2
2
  static GetDebitNotePrintInfo(OriginalInvoiceData: any, OriginalEntityData: any, image: any, IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean, IsCustBillTo: boolean): any;
3
+ static GetLaborPrintInfo(LaborList: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number): any;
4
+ static getTaxName(TCode: any, TaxCodes: any): any;
5
+ static GetTaxAmountFromTaxes(item: any, taxCode: string): any;
6
+ static GetTaxRateFromTaxes(item: any, taxCode: string): any;
7
+ static GetTCodeFromTaxes(item: any): any;
3
8
  static GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean, SType: any, OriginalInvoiceData: any, IsProforma: boolean, IsBillTo: boolean): any;
4
9
  static GetInvoiceTypeHeading(InvoicePrintData: any, OriginalInvoiceData: any, IncludeGST: boolean, ConsolidateGST: boolean, IsProforma: boolean, IsBillTo: boolean): any;
5
10
  static GetInvoiceOtherDetailsForPrint(InvoicePrintData: any, OriginalInvoiceData: any, IsCustBillTo: boolean): any;
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DebitNotePrintService = void 0;
4
4
  const shared_print_service_1 = require("../../shared/shared-print.service");
5
- const debit_note_totals_service_1 = require("./debit-note-totals.service");
6
5
  const code_enums_1 = require("../../enums/code-enums");
7
6
  const tr_utils_1 = require("../../utils/tr-utils");
8
7
  const enums_1 = require("../../enums/enums");
9
8
  const my_date_1 = require("../../utils/my-date");
10
9
  const math_operations_1 = require("../../shared/math-operations");
10
+ const invoice_total_service_1 = require("../invoice/invoice-total.service");
11
11
  class DebitNotePrintService {
12
12
  static GetDebitNotePrintInfo(OriginalInvoiceData, OriginalEntityData, image, IncludeGST, ConsolidateGST, TaxCodes, IsProforma, IsCustBillTo) {
13
- var _a, _b, _c, _d;
13
+ var _a, _b, _c, _d, _e, _f;
14
14
  let InvoicePrintData = {};
15
15
  let argInvoiceData = tr_utils_1.TrUtils.Stringify(OriginalInvoiceData);
16
16
  if (!IncludeGST) {
@@ -25,13 +25,14 @@ class DebitNotePrintService {
25
25
  InvoicePrintData = shared_print_service_1.PrintSharedService.GetEntityHeaderStyles(InvoicePrintData, OriginalEntityData, image);
26
26
  InvoicePrintData = this.GetInvoiceOtherDetailsForPrint(InvoicePrintData, argInvoiceData, IsCustBillTo);
27
27
  let IsTaxable = (IncludeGST && tr_utils_1.TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
28
- let finalTotalsData = debit_note_totals_service_1.DebitNoteTotalsService.GetTotalsValue(argInvoiceData.Items, IsTaxable, true, argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, InvoicePrintData.Entity);
28
+ let finalTotalsData = invoice_total_service_1.InvoiceTotalsService.GetTotalsValue(argInvoiceData.Services, argInvoiceData.Items, IsTaxable, true, null, '', null, '', argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, argInvoiceData.Adjust, true, InvoicePrintData.Entity);
29
29
  if (ConsolidateGST) {
30
30
  finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
31
31
  finalTotalsData.CustPartsTotalBeforeDisc = finalTotalsData.CustPartAfterTax;
32
32
  }
33
33
  InvoicePrintData = tr_utils_1.TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
34
- InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, (_b = (_a = OriginalEntityData.Entity.Settings) === null || _a === void 0 ? void 0 : _a.Acc) === null || _b === void 0 ? void 0 : _b.LTot, (_c = InvoicePrintData.Entity) === null || _c === void 0 ? void 0 : _c.DecimalsNumber);
34
+ InvoicePrintData.Ops = this.GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, (_b = (_a = OriginalEntityData.Entity.Settings) === null || _a === void 0 ? void 0 : _a.Acc) === null || _b === void 0 ? void 0 : _b.LTot, InvoicePrintData.Entity.DecimalsNumber);
35
+ InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, (_d = (_c = OriginalEntityData.Entity.Settings) === null || _c === void 0 ? void 0 : _c.Acc) === null || _d === void 0 ? void 0 : _d.LTot, (_e = InvoicePrintData.Entity) === null || _e === void 0 ? void 0 : _e.DecimalsNumber);
35
36
  argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
36
37
  InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, code_enums_1.ROTypeEnum.Invoice, argInvoiceData.Sts);
37
38
  InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
@@ -39,7 +40,7 @@ class DebitNotePrintService {
39
40
  if (tr_utils_1.TrUtils.IsNull(argInvoiceData.Payments)) {
40
41
  argInvoiceData.Payments = [];
41
42
  }
42
- let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts, (_d = InvoicePrintData.Entity) === null || _d === void 0 ? void 0 : _d.DecimalsNumber);
43
+ let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts, (_f = InvoicePrintData.Entity) === null || _f === void 0 ? void 0 : _f.DecimalsNumber);
43
44
  InvoicePrintData.Due = PaymentData.Due;
44
45
  InvoicePrintData.Paid = PaymentData.Paid;
45
46
  if (!tr_utils_1.TrUtils.IsNull(PaymentData.Sts)) {
@@ -51,6 +52,78 @@ class DebitNotePrintService {
51
52
  }
52
53
  return InvoicePrintData;
53
54
  }
55
+ static GetLaborPrintInfo(LaborList, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
56
+ LaborList.forEach((Labor) => {
57
+ Labor.HSN = Labor.SAC;
58
+ if (tr_utils_1.TrUtils.IsNull(Labor.Qty)) {
59
+ Labor.Qty = 1;
60
+ }
61
+ if (Consolidate) {
62
+ Labor.UnPr = tr_utils_1.TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
63
+ }
64
+ else {
65
+ Labor.UnPr = tr_utils_1.TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
66
+ }
67
+ if (!tr_utils_1.TrUtils.IsEmpty(Labor.Perc)) {
68
+ Labor.DiscPerc = Labor.Perc;
69
+ }
70
+ else {
71
+ Labor.DiscPerc = Labor.Perc;
72
+ if (!tr_utils_1.TrUtils.IsZero(Number(Labor.UnPr))) {
73
+ Labor.DiscPerc = (0, math_operations_1.Divide)((0, math_operations_1.Multiply)(100, Labor.Disc), Labor.UnPr);
74
+ }
75
+ else {
76
+ Labor.DiscPerc = 0;
77
+ }
78
+ }
79
+ Labor.TCode = this.GetTCodeFromTaxes(Labor);
80
+ Labor.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'CGST'), DecimalsNumber);
81
+ Labor.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'SGST'), DecimalsNumber);
82
+ Labor.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'IGST'), DecimalsNumber);
83
+ Labor.QtyAndUoM = Labor.Qty.toString();
84
+ Labor.CGSTPerc = this.GetTaxRateFromTaxes(Labor, 'CGST');
85
+ Labor.SGSTPerc = this.GetTaxRateFromTaxes(Labor, 'SGST');
86
+ Labor.IGSTPerc = this.GetTaxRateFromTaxes(Labor, 'IGST');
87
+ Labor.TaxName = this.getTaxName(Labor.TCode, TaxCodes);
88
+ if (LineTotal === 'AT') {
89
+ Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
90
+ }
91
+ else {
92
+ Labor.LineTotal = tr_utils_1.TrUtils.FixPriceValue((0, math_operations_1.Subtract)(Labor.Amt, Labor.Disc), DecimalsNumber);
93
+ }
94
+ });
95
+ return LaborList;
96
+ }
97
+ static getTaxName(TCode, TaxCodes) {
98
+ let Index = TaxCodes.findIndex((TaxCode) => {
99
+ return Number(TCode) === TaxCode._id;
100
+ });
101
+ return (Index !== -1) ? TaxCodes[Index].Name : '';
102
+ }
103
+ static GetTaxAmountFromTaxes(item, taxCode) {
104
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
105
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
106
+ if (matchedTaxes.length !== 0) {
107
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
108
+ }
109
+ return 0;
110
+ }
111
+ static GetTaxRateFromTaxes(item, taxCode) {
112
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
113
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
114
+ if (matchedTaxes.length !== 0) {
115
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
116
+ }
117
+ return 0;
118
+ }
119
+ static GetTCodeFromTaxes(item) {
120
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
121
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
122
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
123
+ return matchedTax.TaxCodeId;
124
+ }
125
+ return item === null || item === void 0 ? void 0 : item.TCode;
126
+ }
54
127
  static GetPrintConditionsBasedOnInput(InvoicePrintData, IncludeGST, ConsolidateGST, SType, OriginalInvoiceData, IsProforma, IsBillTo) {
55
128
  InvoicePrintData.For = enums_1.PayTypeEnum.Customer;
56
129
  InvoicePrintData.IncludeGST = IncludeGST;
@@ -102,12 +175,21 @@ class DebitNotePrintService {
102
175
  else {
103
176
  Item.UnPr = tr_utils_1.TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
104
177
  }
105
- Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
106
- Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
107
- Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
108
- Item.CGSTPerc = shared_print_service_1.PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
109
- Item.SGSTPerc = shared_print_service_1.PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
110
- Item.IGSTPerc = shared_print_service_1.PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
178
+ Item.TCode = this.GetTCodeFromTaxes(Item);
179
+ Item.CGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'CGST'), DecimalsNumber);
180
+ Item.SGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'SGST'), DecimalsNumber);
181
+ Item.IGSTAmt = tr_utils_1.TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'IGST'), DecimalsNumber);
182
+ Item.QtyAndUoM = Item.Qty.toString();
183
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST');
184
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST');
185
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST');
186
+ Item.TaxName = this.getTaxName(Item.TCode, TaxCodes);
187
+ // Item.CGSTAmt = TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
188
+ // Item.SGSTAmt = TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
189
+ // Item.IGSTAmt = TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
190
+ // Item.CGSTPerc = PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
191
+ // Item.SGSTPerc = PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
192
+ // Item.IGSTPerc = PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
111
193
  if (LineTotal === 'AT') {
112
194
  Item.LineTotal = tr_utils_1.TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
113
195
  }
@@ -121,12 +203,14 @@ class DebitNotePrintService {
121
203
  return Items;
122
204
  }
123
205
  static ReverseItemsForInvoicePrint(argInvoiceData) {
124
- argInvoiceData.Items = argInvoiceData.Items.reverse();
206
+ argInvoiceData.Services = argInvoiceData.Services;
207
+ argInvoiceData.Items = argInvoiceData.Items;
125
208
  return argInvoiceData;
126
209
  }
127
210
  static PrepareFormatForInvoicePrint(InvoicePrintData, ROType, InvoiceStatus) {
128
211
  let PrintInfo = [];
129
212
  let ROLaborParts = {};
213
+ ROLaborParts.Services = InvoicePrintData.Services;
130
214
  ROLaborParts.Items = InvoicePrintData.Items;
131
215
  ROLaborParts.Sts = InvoiceStatus;
132
216
  ROLaborParts.Type = ROType;
@@ -2,5 +2,6 @@ export declare function GetInvoicePDF(invoiceData: any, entityData: any, headerC
2
2
  export declare function GetSalesOrderPDF(salesOrderData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
3
3
  export declare function GetDeliveryChallanPDF(deliveryChallanData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
4
4
  export declare function GetCreditNotePDF(creditNoteData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
5
+ export declare function GetDebitNotePDF(debitNoteData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], options?: any): any;
5
6
  export declare function GetSalesReceiptPDF(salesReceiptData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any, numberofCopies?: string[], withPass?: boolean, options?: any): any;
6
7
  export declare function GetBillPDF(billData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image?: any): any;
@@ -4,6 +4,7 @@ exports.GetInvoicePDF = GetInvoicePDF;
4
4
  exports.GetSalesOrderPDF = GetSalesOrderPDF;
5
5
  exports.GetDeliveryChallanPDF = GetDeliveryChallanPDF;
6
6
  exports.GetCreditNotePDF = GetCreditNotePDF;
7
+ exports.GetDebitNotePDF = GetDebitNotePDF;
7
8
  exports.GetSalesReceiptPDF = GetSalesReceiptPDF;
8
9
  exports.GetBillPDF = GetBillPDF;
9
10
  const purchase_order_print_service_1 = require("../purchases/purchase-order/purchase-order-print.service");
@@ -20,6 +21,7 @@ const credit_note_pdf_service_1 = require("../accounting/credit-note/credit-note
20
21
  const inv_print_service_1 = require("../accounting/invoice/inv-print.service");
21
22
  const invoice_pdf_service_1 = require("../accounting/invoice/invoice-pdf/invoice-pdf.service");
22
23
  const unified_invoice_pdf_service_1 = require("../accounting/invoice/unified-invoice-pdf.service");
24
+ const debit_note_print_service_1 = require("../accounting/debit-note/debit-note-print.service");
23
25
  function GetInvoicePDF(invoiceData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], withPass = false, options = null) {
24
26
  var _a;
25
27
  if (!options) {
@@ -133,6 +135,32 @@ function GetCreditNotePDF(creditNoteData, entityData, headerConfig, printConfig,
133
135
  }
134
136
  return cnPrint;
135
137
  }
138
+ function GetDebitNotePDF(debitNoteData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], options = null) {
139
+ var _a;
140
+ if (!options) {
141
+ options = {
142
+ ShowGST: (((_a = debitNoteData === null || debitNoteData === void 0 ? void 0 : debitNoteData.Settings) === null || _a === void 0 ? void 0 : _a.Tax) === 'TI') ? true : false,
143
+ ConsolidateGST: false,
144
+ Size: 'full',
145
+ MoreDiscDetails: false,
146
+ Orientation: 'portrait'
147
+ };
148
+ }
149
+ const printConfigData = tr_utils_1.TrUtils.ConcatObjects(tr_utils_1.TrUtils.Stringify(headerConfig), tr_utils_1.TrUtils.Stringify(printConfig));
150
+ const debitNotePrintData = debit_note_print_service_1.DebitNotePrintService.GetDebitNotePrintInfo(debitNoteData, entityData, image, true, false, taxCodes, false, true);
151
+ let dnPrint;
152
+ if (options.ConsolidateGST) {
153
+ dnPrint = debit_note_print_service_1.DebitNotePrintService.GetDebitNotePrintInfo(debitNotePrintData, entityData, image, true, true, taxCodes, false, true);
154
+ }
155
+ else {
156
+ debitNotePrintData.Round = tr_utils_1.TrUtils.FixedTo(debitNoteData.Round);
157
+ debitNotePrintData.Total = tr_utils_1.TrUtils.FixedTo(debitNoteData.Total);
158
+ debitNotePrintData.SubToal = tr_utils_1.TrUtils.FixedTo(debitNoteData.SubToal);
159
+ debitNotePrintData.TaxTotal = tr_utils_1.TrUtils.FixedTo(debitNoteData.TaxTotal);
160
+ dnPrint = (0, invoice_pdf_service_1.CreateInvoicePDFService)(debitNotePrintData, printConfigData, numberofCopies);
161
+ }
162
+ return dnPrint;
163
+ }
136
164
  function GetSalesReceiptPDF(salesReceiptData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], withPass = false, options = null) {
137
165
  var _a;
138
166
  if (!options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.323",
3
+ "version": "1.7.325",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -6,7 +6,8 @@ import { ROTypeEnum } from '../../enums/code-enums';
6
6
  import { TrUtils } from '../../utils/tr-utils';
7
7
  import { InvoiceStatusEnum, PayTypeEnum } from '../../enums/enums';
8
8
  import { MyDate } from '../../utils/my-date';
9
- import { Add, Divide, Subtract } from '../../shared/math-operations';
9
+ import { Add, Divide, Multiply, Subtract } from '../../shared/math-operations';
10
+ import { InvoiceTotalsService } from '../invoice/invoice-total.service';
10
11
 
11
12
  export class DebitNotePrintService {
12
13
 
@@ -38,8 +39,8 @@ export class DebitNotePrintService {
38
39
 
39
40
  let IsTaxable: boolean = (IncludeGST && TrUtils.isTaxable(argInvoiceData.Settings.Tax)) ? true : false;
40
41
 
41
- let finalTotalsData: any = DebitNoteTotalsService.GetTotalsValue(argInvoiceData.Items, IsTaxable,
42
- true, argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, InvoicePrintData.Entity);
42
+ let finalTotalsData: any = InvoiceTotalsService.GetTotalsValue(argInvoiceData.Services, argInvoiceData.Items, IsTaxable,
43
+ true, null, '', null, '', argInvoiceData.Disc, argInvoiceData.Perc, TaxCodes, true, argInvoiceData.Settings, argInvoiceData.Adjust, true, InvoicePrintData.Entity);
43
44
 
44
45
  if (ConsolidateGST) {
45
46
  finalTotalsData.CustLaborTotalBeforeDisc = finalTotalsData.CustLaborAfterTax;
@@ -47,8 +48,8 @@ export class DebitNotePrintService {
47
48
  }
48
49
 
49
50
  InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
50
-
51
- InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes,OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity?.DecimalsNumber);
51
+ InvoicePrintData.Ops = this.GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
52
+ InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity?.DecimalsNumber);
52
53
 
53
54
  argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
54
55
 
@@ -57,8 +58,8 @@ export class DebitNotePrintService {
57
58
  InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
58
59
 
59
60
  InvoicePrintData = this.GetBillNameForInvoicePrint(argInvoiceData, InvoicePrintData, IsCustBillTo);
60
- if(TrUtils.IsNull(argInvoiceData.Payments)){
61
- argInvoiceData.Payments=[];
61
+ if (TrUtils.IsNull(argInvoiceData.Payments)) {
62
+ argInvoiceData.Payments = [];
62
63
  }
63
64
 
64
65
  let PaymentData = this.GetPaymentsTotal(argInvoiceData.Payments, InvoicePrintData.Total, argInvoiceData.Sts, InvoicePrintData.Entity?.DecimalsNumber);
@@ -74,6 +75,83 @@ export class DebitNotePrintService {
74
75
  return InvoicePrintData;
75
76
  }
76
77
 
78
+
79
+
80
+
81
+ static GetLaborPrintInfo(LaborList: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
82
+ LaborList.forEach((Labor: any) => {
83
+ Labor.HSN = Labor.SAC;
84
+ if (TrUtils.IsNull(Labor.Qty)) {
85
+ Labor.Qty = 1;
86
+ }
87
+ if (Consolidate) {
88
+ Labor.UnPr = TrUtils.FixedTo(Labor.AfterLaborTax, DecimalsNumber);
89
+ } else {
90
+ Labor.UnPr = TrUtils.FixPriceValue(Labor.Pr, DecimalsNumber);
91
+ }
92
+ if (!TrUtils.IsEmpty(Labor.Perc)) {
93
+ Labor.DiscPerc = Labor.Perc;
94
+ } else {
95
+ Labor.DiscPerc = Labor.Perc;
96
+ if (!TrUtils.IsZero(Number(Labor.UnPr))) {
97
+ Labor.DiscPerc = Divide(Multiply(100, Labor.Disc), Labor.UnPr);
98
+ } else {
99
+ Labor.DiscPerc = 0;
100
+ }
101
+ }
102
+ Labor.TCode = this.GetTCodeFromTaxes(Labor);
103
+ Labor.CGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'CGST'), DecimalsNumber);
104
+ Labor.SGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'SGST'), DecimalsNumber);
105
+ Labor.IGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Labor, 'IGST'), DecimalsNumber);
106
+ Labor.QtyAndUoM = Labor.Qty.toString();
107
+ Labor.CGSTPerc = this.GetTaxRateFromTaxes(Labor, 'CGST');
108
+ Labor.SGSTPerc = this.GetTaxRateFromTaxes(Labor, 'SGST');
109
+ Labor.IGSTPerc = this.GetTaxRateFromTaxes(Labor, 'IGST');
110
+ Labor.TaxName = this.getTaxName(Labor.TCode, TaxCodes);
111
+ if (LineTotal === 'AT') {
112
+ Labor.LineTotal = TrUtils.FixPriceValue(Labor.AfterLaborTax, DecimalsNumber);
113
+ } else {
114
+ Labor.LineTotal = TrUtils.FixPriceValue(Subtract(Labor.Amt, Labor.Disc), DecimalsNumber);
115
+ }
116
+ });
117
+ return LaborList;
118
+ }
119
+
120
+ static getTaxName(TCode: any, TaxCodes: any) {
121
+ let Index: any = TaxCodes.findIndex((TaxCode: any) => {
122
+ return Number(TCode) === TaxCode._id;
123
+ });
124
+ return (Index !== -1) ? TaxCodes[Index].Name : '';
125
+ }
126
+
127
+ static GetTaxAmountFromTaxes(item: any, taxCode: string) {
128
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
129
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
130
+ if (matchedTaxes.length !== 0) {
131
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Amt), 0);
132
+ }
133
+ return 0;
134
+ }
135
+
136
+
137
+ static GetTaxRateFromTaxes(item: any, taxCode: string) {
138
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
139
+ const matchedTaxes = taxes.filter((tax: any) => tax?.Code === taxCode);
140
+ if (matchedTaxes.length !== 0) {
141
+ return matchedTaxes.reduce((total: number, tax: any) => Add(total, tax?.Rate), 0);
142
+ }
143
+ return 0;
144
+ }
145
+
146
+ static GetTCodeFromTaxes(item: any) {
147
+ const taxes = Array.isArray(item?.Taxes) ? item.Taxes : [];
148
+ const matchedTax = taxes.find((tax: any) => !TrUtils.IsNull(tax?.TaxCodeId));
149
+ if (!TrUtils.IsNull(matchedTax?.TaxCodeId)) {
150
+ return matchedTax.TaxCodeId;
151
+ }
152
+ return item?.TCode;
153
+ }
154
+
77
155
  static GetPrintConditionsBasedOnInput(InvoicePrintData: any, IncludeGST: boolean, ConsolidateGST: boolean,
78
156
  SType: any, OriginalInvoiceData: any, IsProforma: boolean, IsBillTo: boolean) {
79
157
  InvoicePrintData.For = PayTypeEnum.Customer;
@@ -122,23 +200,32 @@ export class DebitNotePrintService {
122
200
  return InvoicePrintData;
123
201
  }
124
202
 
125
- static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal:string, DecimalsNumber: number) {
203
+ static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
126
204
  Items.forEach((Item: any) => {
127
205
  if (Consolidate) {
128
206
  let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
129
- let CTaxAmtPerItem = Divide(Item.CGST , Item.Qty);
130
- let STaxAmtPerItem = Divide(Item.SGST , Item.Qty);
131
- let ITaxAmtPerItem = Divide(Item.IGST , Item.Qty);
132
- Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach , CTaxAmtPerItem , STaxAmtPerItem , ITaxAmtPerItem), DecimalsNumber);
133
- }else{
207
+ let CTaxAmtPerItem = Divide(Item.CGST, Item.Qty);
208
+ let STaxAmtPerItem = Divide(Item.SGST, Item.Qty);
209
+ let ITaxAmtPerItem = Divide(Item.IGST, Item.Qty);
210
+ Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
211
+ } else {
134
212
  Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
135
213
  }
136
- Item.CGSTAmt = TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
137
- Item.SGSTAmt = TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
138
- Item.IGSTAmt = TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
139
- Item.CGSTPerc = PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
140
- Item.SGSTPerc = PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
141
- Item.IGSTPerc = PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
214
+ Item.TCode = this.GetTCodeFromTaxes(Item);
215
+ Item.CGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'CGST'), DecimalsNumber);
216
+ Item.SGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'SGST'), DecimalsNumber);
217
+ Item.IGSTAmt = TrUtils.FixPriceValue(this.GetTaxAmountFromTaxes(Item, 'IGST'), DecimalsNumber);
218
+ Item.QtyAndUoM = Item.Qty.toString();
219
+ Item.CGSTPerc = this.GetTaxRateFromTaxes(Item, 'CGST');
220
+ Item.SGSTPerc = this.GetTaxRateFromTaxes(Item, 'SGST');
221
+ Item.IGSTPerc = this.GetTaxRateFromTaxes(Item, 'IGST');
222
+ Item.TaxName = this.getTaxName(Item.TCode, TaxCodes);
223
+ // Item.CGSTAmt = TrUtils.FixPriceValue(Item.CGST, DecimalsNumber);
224
+ // Item.SGSTAmt = TrUtils.FixPriceValue(Item.SGST, DecimalsNumber);
225
+ // Item.IGSTAmt = TrUtils.FixPriceValue(Item.IGST, DecimalsNumber);
226
+ // Item.CGSTPerc = PrintSharedService.GetCGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
227
+ // Item.SGSTPerc = PrintSharedService.GetSGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
228
+ // Item.IGSTPerc = PrintSharedService.GetIGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
142
229
  if (LineTotal === 'AT') {
143
230
  Item.LineTotal = TrUtils.FixPriceValue(Item.AfterPartTax, DecimalsNumber);
144
231
  } else {
@@ -152,7 +239,8 @@ export class DebitNotePrintService {
152
239
  }
153
240
 
154
241
  static ReverseItemsForInvoicePrint(argInvoiceData: any) {
155
- argInvoiceData.Items = argInvoiceData.Items.reverse();
242
+ argInvoiceData.Services = argInvoiceData.Services;
243
+ argInvoiceData.Items = argInvoiceData.Items;
156
244
  return argInvoiceData;
157
245
  }
158
246
 
@@ -160,7 +248,7 @@ export class DebitNotePrintService {
160
248
  let PrintInfo: any[] = [];
161
249
 
162
250
  let ROLaborParts: any = {};
163
-
251
+ ROLaborParts.Services = InvoicePrintData.Services;
164
252
  ROLaborParts.Items = InvoicePrintData.Items;
165
253
 
166
254
  ROLaborParts.Sts = InvoiceStatus;
@@ -14,6 +14,7 @@ import { CreditNotePdfService } from "../accounting/credit-note/credit-note-pdf.
14
14
  import { GetInvoicePrintInfo } from "../accounting/invoice/inv-print.service";
15
15
  import { CreateInvoicePDFService } from "../accounting/invoice/invoice-pdf/invoice-pdf.service";
16
16
  import { GetInvoicePrint } from "../accounting/invoice/unified-invoice-pdf.service";
17
+ import { DebitNotePrintService } from "../accounting/debit-note/debit-note-print.service";
17
18
 
18
19
  export function GetInvoicePDF(invoiceData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], withPass: boolean = false, options: any = null) {
19
20
  if (!options) {
@@ -146,6 +147,37 @@ export function GetCreditNotePDF(creditNoteData: any, entityData: any, headerCon
146
147
  return cnPrint;
147
148
  }
148
149
 
150
+ export function GetDebitNotePDF(debitNoteData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], options: any = null) {
151
+ if (!options) {
152
+ options = {
153
+ ShowGST: (debitNoteData?.Settings?.Tax === 'TI') ? true : false,
154
+ ConsolidateGST: false,
155
+ Size: 'full',
156
+ MoreDiscDetails: false,
157
+ Orientation: 'portrait'
158
+ };
159
+ }
160
+ const printConfigData: any = TrUtils.ConcatObjects(
161
+ TrUtils.Stringify(headerConfig),
162
+ TrUtils.Stringify(printConfig)
163
+ );
164
+ const debitNotePrintData: any = DebitNotePrintService.GetDebitNotePrintInfo(debitNoteData, entityData, image,
165
+ true, false, taxCodes, false, true);
166
+ let dnPrint: any;
167
+ if (options.ConsolidateGST) {
168
+ dnPrint = DebitNotePrintService.GetDebitNotePrintInfo(debitNotePrintData,entityData, image,true, true, taxCodes, false, true);
169
+ } else {
170
+ debitNotePrintData.Round = TrUtils.FixedTo(debitNoteData.Round);
171
+ debitNotePrintData.Total = TrUtils.FixedTo(debitNoteData.Total);
172
+ debitNotePrintData.SubToal = TrUtils.FixedTo(debitNoteData.SubToal);
173
+ debitNotePrintData.TaxTotal = TrUtils.FixedTo(debitNoteData.TaxTotal);
174
+ dnPrint = CreateInvoicePDFService(debitNotePrintData, printConfigData, numberofCopies);
175
+
176
+ }
177
+
178
+ return dnPrint;
179
+ }
180
+
149
181
 
150
182
  export function GetSalesReceiptPDF(salesReceiptData: any, entityData: any, headerConfig: any, printConfig: any, taxCodes: any, image: any = null, numberofCopies: string[] = ['Original'], withPass: boolean = false, options: any = null) {
151
183
  if (!options) {