shareneus 1.7.345 → 1.7.347
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.
- package/dist/accounting/credit-note/cn-print.service.js +9 -0
- package/dist/accounting/debit-note/debit-note-print.service.js +9 -0
- package/dist/shared/transactions-pdf.service.js +0 -2
- package/dist/transaction-calculations/total-calculation.d.ts +1 -0
- package/dist/transaction-calculations/total-calculation.js +36 -1
- package/package.json +1 -1
- package/src/accounting/credit-note/cn-print.service.ts +12 -3
- package/src/accounting/debit-note/debit-note-print.service.ts +15 -6
- package/src/shared/transactions-pdf.service.ts +0 -2
- package/src/transaction-calculations/total-calculation.ts +43 -1
|
@@ -66,6 +66,15 @@ class CNPrintService {
|
|
|
66
66
|
}
|
|
67
67
|
static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
|
|
68
68
|
Items.forEach((Item) => {
|
|
69
|
+
const LinkCodes = Array.isArray(Item === null || Item === void 0 ? void 0 : Item.Link)
|
|
70
|
+
? Item.Link
|
|
71
|
+
.map((Link) => Link === null || Link === void 0 ? void 0 : Link.Code)
|
|
72
|
+
.filter((Code) => !tr_utils_1.TrUtils.IsEmpty(Code))
|
|
73
|
+
.join(', ')
|
|
74
|
+
: '';
|
|
75
|
+
if (!tr_utils_1.TrUtils.IsEmpty(LinkCodes)) {
|
|
76
|
+
Item.Desc = Item.Desc + ' (' + LinkCodes + ')';
|
|
77
|
+
}
|
|
69
78
|
Item.TCode = this.GetTCodeFromTaxes(Item);
|
|
70
79
|
const cgstAmount = this.GetTaxAmountFromTaxes(Item, 'CGST', Item.CGST);
|
|
71
80
|
const sgstAmount = this.GetTaxAmountFromTaxes(Item, 'SGST', Item.SGST);
|
|
@@ -165,6 +165,15 @@ class DebitNotePrintService {
|
|
|
165
165
|
}
|
|
166
166
|
static GetItemsPrintInfo(Items, Consolidate, TaxCodes, LineTotal, DecimalsNumber) {
|
|
167
167
|
Items.forEach((Item) => {
|
|
168
|
+
const LinkCodes = Array.isArray(Item === null || Item === void 0 ? void 0 : Item.Link)
|
|
169
|
+
? Item.Link
|
|
170
|
+
.map((Link) => Link === null || Link === void 0 ? void 0 : Link.Code)
|
|
171
|
+
.filter((Code) => !tr_utils_1.TrUtils.IsEmpty(Code))
|
|
172
|
+
.join(', ')
|
|
173
|
+
: '';
|
|
174
|
+
if (!tr_utils_1.TrUtils.IsEmpty(LinkCodes)) {
|
|
175
|
+
Item.Desc = Item.Desc + ' (' + LinkCodes + ')';
|
|
176
|
+
}
|
|
168
177
|
if (Consolidate) {
|
|
169
178
|
let AfterDiscForEach = (0, math_operations_1.Divide)(Item.AfterPartDisc, Item.Qty);
|
|
170
179
|
let CTaxAmtPerItem = (0, math_operations_1.Divide)(this.GetTaxAmountFromTaxes(Item, 'CGST'), Item.Qty);
|
|
@@ -44,14 +44,12 @@ function GetInvoicePDF(invoiceData, entityData, headerConfig, printConfig, taxCo
|
|
|
44
44
|
invPrint = (0, unified_invoice_pdf_service_1.GetInvoicePrint)(invoicePrintData, numberofCopies, withPass, options.Size, options.MoreDiscDetails, options.Orientation);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
console.log("options", options);
|
|
48
47
|
if (options.PartInvoice && options.LaborInvoice) {
|
|
49
48
|
invoicePrintData.Round = tr_utils_1.TrUtils.FixedTo(invoiceData.Round);
|
|
50
49
|
invoicePrintData.Total = tr_utils_1.TrUtils.FixedTo(invoiceData.Total);
|
|
51
50
|
invoicePrintData.SubToal = tr_utils_1.TrUtils.FixedTo(invoiceData.SubToal);
|
|
52
51
|
invoicePrintData.TaxTotal = tr_utils_1.TrUtils.FixedTo(invoiceData.TaxTotal);
|
|
53
52
|
}
|
|
54
|
-
console.log("invoicePrintData", invoicePrintData);
|
|
55
53
|
delete invoicePrintData.SIndTotal;
|
|
56
54
|
invPrint = (0, invoice_pdf_service_1.CreateInvoicePDFService)(invoicePrintData, printConfigData, numberofCopies);
|
|
57
55
|
}
|
|
@@ -3,4 +3,5 @@ export declare function TotalCalculations(items?: any[], ops?: any[], isTaxable?
|
|
|
3
3
|
* Enhanced version with decimal places control
|
|
4
4
|
*/
|
|
5
5
|
export declare function TotalCalculationsWithDecimals(items: any[] | undefined, ops: any[] | undefined, isTaxable: boolean | undefined, taxCodes: any[] | undefined, Adjust: number, decimalPlaces?: number): any;
|
|
6
|
+
export declare function getTaxName(taxes: any): string;
|
|
6
7
|
export declare function CalculateTaxSummary(items: any[], taxCodes: any[]): unknown[];
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TotalCalculations = TotalCalculations;
|
|
4
4
|
exports.TotalCalculationsWithDecimals = TotalCalculationsWithDecimals;
|
|
5
|
+
exports.getTaxName = getTaxName;
|
|
5
6
|
exports.CalculateTaxSummary = CalculateTaxSummary;
|
|
6
7
|
const math_operations_1 = require("../shared/math-operations");
|
|
7
8
|
const util_1 = require("../shared/util");
|
|
9
|
+
const tr_utils_1 = require("../utils/tr-utils");
|
|
8
10
|
/**
|
|
9
11
|
* Safely handles null/undefined arrays and returns empty array
|
|
10
12
|
*/
|
|
@@ -340,12 +342,45 @@ function TotalCalculationsWithDecimals(items = [], ops = [], isTaxable = false,
|
|
|
340
342
|
}
|
|
341
343
|
return roundedResult;
|
|
342
344
|
}
|
|
345
|
+
function getTaxName(taxes) {
|
|
346
|
+
if (Array.isArray(taxes) && taxes.length > 0) {
|
|
347
|
+
const taxRates = taxes.reduce((rates, tax) => {
|
|
348
|
+
var _a, _b;
|
|
349
|
+
const code = (_a = tax === null || tax === void 0 ? void 0 : tax.Code) === null || _a === void 0 ? void 0 : _a.toString().trim().toUpperCase();
|
|
350
|
+
const rawCalcMethod = (_b = tax === null || tax === void 0 ? void 0 : tax.CalcMethod) === null || _b === void 0 ? void 0 : _b.toString().trim().toUpperCase();
|
|
351
|
+
const calcMethod = !rawCalcMethod || rawCalcMethod === 'PERCENTAGE' ? 'PERCENT' : rawCalcMethod;
|
|
352
|
+
if (['CGST', 'SGST', 'IGST'].includes(code)) {
|
|
353
|
+
rates.gstRate = (0, math_operations_1.Add)(rates.gstRate, tr_utils_1.TrUtils.SetValueToZeroIfNull(tax === null || tax === void 0 ? void 0 : tax.Rate));
|
|
354
|
+
}
|
|
355
|
+
else if (code === 'CESS' && calcMethod === 'PERCENT') {
|
|
356
|
+
rates.cessRate = (0, math_operations_1.Add)(rates.cessRate, tr_utils_1.TrUtils.SetValueToZeroIfNull(tax === null || tax === void 0 ? void 0 : tax.Rate));
|
|
357
|
+
}
|
|
358
|
+
else if (code === 'CESS' && calcMethod === 'PERUNIT') {
|
|
359
|
+
rates.cessPerUnit = (0, math_operations_1.Add)(rates.cessPerUnit, tr_utils_1.TrUtils.SetValueToZeroIfNull(tax === null || tax === void 0 ? void 0 : tax.PerUnitAmt));
|
|
360
|
+
}
|
|
361
|
+
return rates;
|
|
362
|
+
}, { gstRate: 0, cessRate: 0, cessPerUnit: 0 });
|
|
363
|
+
const taxNames = [];
|
|
364
|
+
if (!tr_utils_1.TrUtils.IsZero(taxRates.gstRate)) {
|
|
365
|
+
taxNames.push(tr_utils_1.TrUtils.FixedTo(taxRates.gstRate) + '%');
|
|
366
|
+
}
|
|
367
|
+
if (!tr_utils_1.TrUtils.IsZero(taxRates.cessRate)) {
|
|
368
|
+
taxNames.push(tr_utils_1.TrUtils.FixedTo(taxRates.cessRate) + '% CESS');
|
|
369
|
+
}
|
|
370
|
+
if (!tr_utils_1.TrUtils.IsZero(taxRates.cessPerUnit)) {
|
|
371
|
+
taxNames.push(tr_utils_1.TrUtils.FixPriceValue(taxRates.cessPerUnit) + ' CESS Per Unit');
|
|
372
|
+
}
|
|
373
|
+
return taxNames.join(' + ');
|
|
374
|
+
}
|
|
375
|
+
return '';
|
|
376
|
+
}
|
|
343
377
|
function CalculateTaxSummary(items, taxCodes) {
|
|
344
378
|
return Object.values(items.reduce((acc, item) => {
|
|
345
379
|
const taxes = getResolvedTaxes(item, taxCodes);
|
|
346
380
|
if (taxes.length === 0)
|
|
347
381
|
return acc;
|
|
348
|
-
const percent = (taxes.reduce((sum, tax) =>
|
|
382
|
+
// const percent = (taxes.reduce((sum: number, tax: any) => Add(sum, GetNumber(tax.Rate)), 0) + "%");
|
|
383
|
+
const percent = getTaxName(taxes);
|
|
349
384
|
const taxable = getLineNetAmount(item);
|
|
350
385
|
const cgstAmount = getTaxAmountByCode(taxes, "CGST");
|
|
351
386
|
const sgstAmount = getTaxAmountByCode(taxes, "SGST");
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ export class CNPrintService {
|
|
|
11
11
|
|
|
12
12
|
static GetCreditNotePrintInfo(OriginalInvoiceData: any, OriginalEntityData: any, image: any,
|
|
13
13
|
IncludeGST: boolean, ConsolidateGST: boolean, TaxCodes: any, IsProforma: boolean) {
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
let ForInsurance: boolean = !TrUtils.IsNull(OriginalInvoiceData.BillTo.InsId);
|
|
16
16
|
let InvoicePrintData: any = {};
|
|
17
17
|
let argInvoiceData = TrUtils.Stringify(OriginalInvoiceData);
|
|
@@ -38,7 +38,7 @@ export class CNPrintService {
|
|
|
38
38
|
}
|
|
39
39
|
InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
|
|
40
40
|
InvoicePrintData.Items = this.GetItemsPrintInfo(InvoicePrintData.Items, ConsolidateGST, TaxCodes,
|
|
41
|
-
|
|
41
|
+
OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
|
|
42
42
|
argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
|
|
43
43
|
InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, ROTypeEnum.Invoice, argInvoiceData.Sts);
|
|
44
44
|
InvoicePrintData = this.GetFormattedProductDataForPrint(argInvoiceData, InvoicePrintData);
|
|
@@ -79,6 +79,15 @@ export class CNPrintService {
|
|
|
79
79
|
|
|
80
80
|
static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
|
|
81
81
|
Items.forEach((Item: any) => {
|
|
82
|
+
const LinkCodes = Array.isArray(Item?.Link)
|
|
83
|
+
? Item.Link
|
|
84
|
+
.map((Link: any) => Link?.Code)
|
|
85
|
+
.filter((Code: any) => !TrUtils.IsEmpty(Code))
|
|
86
|
+
.join(', ')
|
|
87
|
+
: '';
|
|
88
|
+
if (!TrUtils.IsEmpty(LinkCodes)) {
|
|
89
|
+
Item.Desc = Item.Desc + ' (' + LinkCodes + ')';
|
|
90
|
+
}
|
|
82
91
|
Item.TCode = this.GetTCodeFromTaxes(Item);
|
|
83
92
|
const cgstAmount = this.GetTaxAmountFromTaxes(Item, 'CGST', Item.CGST);
|
|
84
93
|
const sgstAmount = this.GetTaxAmountFromTaxes(Item, 'SGST', Item.SGST);
|
|
@@ -90,7 +99,7 @@ export class CNPrintService {
|
|
|
90
99
|
let STaxAmtPerItem = Divide(sgstAmount, Item.Qty);
|
|
91
100
|
let ITaxAmtPerItem = Divide(igstAmount, Item.Qty);
|
|
92
101
|
Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
|
|
93
|
-
}else{
|
|
102
|
+
} else {
|
|
94
103
|
Item.UnPr = TrUtils.FixPriceValue(Item.UnPr, DecimalsNumber);
|
|
95
104
|
}
|
|
96
105
|
Item.CGSTAmt = TrUtils.FixPriceValue(cgstAmount, DecimalsNumber);
|
|
@@ -200,12 +200,21 @@ export class DebitNotePrintService {
|
|
|
200
200
|
return InvoicePrintData;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
|
|
204
|
-
Items.forEach((Item: any) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
203
|
+
static GetItemsPrintInfo(Items: any, Consolidate: boolean, TaxCodes: any, LineTotal: string, DecimalsNumber: number) {
|
|
204
|
+
Items.forEach((Item: any) => {
|
|
205
|
+
const LinkCodes = Array.isArray(Item?.Link)
|
|
206
|
+
? Item.Link
|
|
207
|
+
.map((Link: any) => Link?.Code)
|
|
208
|
+
.filter((Code: any) => !TrUtils.IsEmpty(Code))
|
|
209
|
+
.join(', ')
|
|
210
|
+
: '';
|
|
211
|
+
if (!TrUtils.IsEmpty(LinkCodes)) {
|
|
212
|
+
Item.Desc = Item.Desc + ' (' + LinkCodes + ')';
|
|
213
|
+
}
|
|
214
|
+
if (Consolidate) {
|
|
215
|
+
let AfterDiscForEach = Divide(Item.AfterPartDisc, Item.Qty);
|
|
216
|
+
let CTaxAmtPerItem = Divide(this.GetTaxAmountFromTaxes(Item, 'CGST'), Item.Qty);
|
|
217
|
+
let STaxAmtPerItem = Divide(this.GetTaxAmountFromTaxes(Item, 'SGST'), Item.Qty);
|
|
209
218
|
let ITaxAmtPerItem = Divide(this.GetTaxAmountFromTaxes(Item, 'IGST'), Item.Qty);
|
|
210
219
|
Item.UnPr = TrUtils.FixedTo(Add(AfterDiscForEach, CTaxAmtPerItem, STaxAmtPerItem, ITaxAmtPerItem), DecimalsNumber);
|
|
211
220
|
} else {
|
|
@@ -40,14 +40,12 @@ export function GetInvoicePDF(invoiceData: any, entityData: any, headerConfig: a
|
|
|
40
40
|
if (options.ConsolidateGST) {
|
|
41
41
|
invPrint = GetInvoicePrint(invoicePrintData, numberofCopies, withPass, options.Size, options.MoreDiscDetails, options.Orientation);
|
|
42
42
|
} else {
|
|
43
|
-
console.log("options", options);
|
|
44
43
|
if(options.PartInvoice && options.LaborInvoice){
|
|
45
44
|
invoicePrintData.Round = TrUtils.FixedTo(invoiceData.Round);
|
|
46
45
|
invoicePrintData.Total = TrUtils.FixedTo(invoiceData.Total);
|
|
47
46
|
invoicePrintData.SubToal = TrUtils.FixedTo(invoiceData.SubToal);
|
|
48
47
|
invoicePrintData.TaxTotal = TrUtils.FixedTo(invoiceData.TaxTotal);
|
|
49
48
|
}
|
|
50
|
-
console.log("invoicePrintData", invoicePrintData);
|
|
51
49
|
delete invoicePrintData.SIndTotal;
|
|
52
50
|
invPrint = CreateInvoicePDFService(invoicePrintData, printConfigData, numberofCopies);
|
|
53
51
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Add, Divide, Multiply, Subtract } from "../shared/math-operations";
|
|
2
2
|
import { GetNumber } from "../shared/util";
|
|
3
|
+
import { TrUtils } from "../utils/tr-utils";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Safely handles null/undefined arrays and returns empty array
|
|
@@ -427,13 +428,54 @@ export function TotalCalculationsWithDecimals(
|
|
|
427
428
|
return roundedResult;
|
|
428
429
|
}
|
|
429
430
|
|
|
431
|
+
export function getTaxName(taxes: any): string {
|
|
432
|
+
if (Array.isArray(taxes) && taxes.length > 0) {
|
|
433
|
+
const taxRates = taxes.reduce(
|
|
434
|
+
(rates: any, tax: any) => {
|
|
435
|
+
const code = tax?.Code?.toString().trim().toUpperCase();
|
|
436
|
+
const rawCalcMethod = tax?.CalcMethod?.toString().trim().toUpperCase();
|
|
437
|
+
const calcMethod = !rawCalcMethod || rawCalcMethod === 'PERCENTAGE' ? 'PERCENT' : rawCalcMethod;
|
|
438
|
+
|
|
439
|
+
if (['CGST', 'SGST', 'IGST'].includes(code)) {
|
|
440
|
+
rates.gstRate = Add(rates.gstRate, TrUtils.SetValueToZeroIfNull(tax?.Rate));
|
|
441
|
+
} else if (code === 'CESS' && calcMethod === 'PERCENT') {
|
|
442
|
+
rates.cessRate = Add(rates.cessRate, TrUtils.SetValueToZeroIfNull(tax?.Rate));
|
|
443
|
+
} else if (code === 'CESS' && calcMethod === 'PERUNIT') {
|
|
444
|
+
rates.cessPerUnit = Add(
|
|
445
|
+
rates.cessPerUnit,
|
|
446
|
+
TrUtils.SetValueToZeroIfNull(tax?.PerUnitAmt),
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return rates;
|
|
451
|
+
},
|
|
452
|
+
{ gstRate: 0, cessRate: 0, cessPerUnit: 0 },
|
|
453
|
+
);
|
|
454
|
+
|
|
455
|
+
const taxNames: string[] = [];
|
|
456
|
+
if (!TrUtils.IsZero(taxRates.gstRate)) {
|
|
457
|
+
taxNames.push(TrUtils.FixedTo(taxRates.gstRate) + '%');
|
|
458
|
+
}
|
|
459
|
+
if (!TrUtils.IsZero(taxRates.cessRate)) {
|
|
460
|
+
taxNames.push(TrUtils.FixedTo(taxRates.cessRate) + '% CESS');
|
|
461
|
+
}
|
|
462
|
+
if (!TrUtils.IsZero(taxRates.cessPerUnit)) {
|
|
463
|
+
taxNames.push(TrUtils.FixPriceValue(taxRates.cessPerUnit) + ' CESS Per Unit');
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return taxNames.join(' + ');
|
|
467
|
+
}
|
|
468
|
+
return '';
|
|
469
|
+
}
|
|
470
|
+
|
|
430
471
|
export function CalculateTaxSummary(items: any[], taxCodes: any[]) {
|
|
431
472
|
return Object.values(
|
|
432
473
|
items.reduce((acc: any, item: any) => {
|
|
433
474
|
const taxes = getResolvedTaxes(item, taxCodes);
|
|
434
475
|
if (taxes.length === 0) return acc;
|
|
435
476
|
|
|
436
|
-
const percent = (taxes.reduce((sum: number, tax: any) => Add(sum, GetNumber(tax.Rate)), 0) + "%");
|
|
477
|
+
// const percent = (taxes.reduce((sum: number, tax: any) => Add(sum, GetNumber(tax.Rate)), 0) + "%");
|
|
478
|
+
const percent = getTaxName(taxes);
|
|
437
479
|
const taxable = getLineNetAmount(item);
|
|
438
480
|
const cgstAmount = getTaxAmountByCode(taxes, "CGST");
|
|
439
481
|
const sgstAmount = getTaxAmountByCode(taxes, "SGST");
|