shareneus 1.7.324 → 1.7.326
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.
|
@@ -2,12 +2,12 @@
|
|
|
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
13
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -25,13 +25,13 @@ 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 =
|
|
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.Ops = this.GetLaborPrintInfo(InvoicePrintData.
|
|
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
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);
|
|
36
36
|
argInvoiceData = this.ReverseItemsForInvoicePrint(argInvoiceData);
|
|
37
37
|
InvoicePrintData.PrintInfo = this.PrepareFormatForInvoicePrint(InvoicePrintData, code_enums_1.ROTypeEnum.Invoice, argInvoiceData.Sts);
|
|
@@ -203,12 +203,14 @@ class DebitNotePrintService {
|
|
|
203
203
|
return Items;
|
|
204
204
|
}
|
|
205
205
|
static ReverseItemsForInvoicePrint(argInvoiceData) {
|
|
206
|
-
argInvoiceData.
|
|
206
|
+
argInvoiceData.Services = argInvoiceData.Services;
|
|
207
|
+
argInvoiceData.Items = argInvoiceData.Items;
|
|
207
208
|
return argInvoiceData;
|
|
208
209
|
}
|
|
209
210
|
static PrepareFormatForInvoicePrint(InvoicePrintData, ROType, InvoiceStatus) {
|
|
210
211
|
let PrintInfo = [];
|
|
211
212
|
let ROLaborParts = {};
|
|
213
|
+
ROLaborParts.Services = InvoicePrintData.Services;
|
|
212
214
|
ROLaborParts.Items = InvoicePrintData.Items;
|
|
213
215
|
ROLaborParts.Sts = InvoiceStatus;
|
|
214
216
|
ROLaborParts.Type = ROType;
|
|
@@ -124,6 +124,7 @@ function negateNumericLikeValue(value) {
|
|
|
124
124
|
return String(normalized === 0 ? 0 : -Math.abs(normalized));
|
|
125
125
|
}
|
|
126
126
|
function getFirstFieldValue(item, dbFields = []) {
|
|
127
|
+
console.log('getFirstFieldValue', item, dbFields);
|
|
127
128
|
for (const field of dbFields) {
|
|
128
129
|
const value = readValue(item, field);
|
|
129
130
|
if (value !== undefined && value !== null && value !== '') {
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import { TrUtils } from '../../utils/tr-utils';
|
|
|
7
7
|
import { InvoiceStatusEnum, PayTypeEnum } from '../../enums/enums';
|
|
8
8
|
import { MyDate } from '../../utils/my-date';
|
|
9
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 =
|
|
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,7 +48,7 @@ export class DebitNotePrintService {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
InvoicePrintData = TrUtils.ConcatObjects(InvoicePrintData, finalTotalsData);
|
|
50
|
-
InvoicePrintData.Ops = this.GetLaborPrintInfo(InvoicePrintData.
|
|
51
|
+
InvoicePrintData.Ops = this.GetLaborPrintInfo(InvoicePrintData.Ops, ConsolidateGST, TaxCodes, OriginalEntityData.Entity.Settings?.Acc?.LTot, InvoicePrintData.Entity.DecimalsNumber);
|
|
51
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);
|
|
@@ -238,7 +239,8 @@ export class DebitNotePrintService {
|
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
static ReverseItemsForInvoicePrint(argInvoiceData: any) {
|
|
241
|
-
|
|
242
|
+
argInvoiceData.Services = argInvoiceData.Services;
|
|
243
|
+
argInvoiceData.Items = argInvoiceData.Items;
|
|
242
244
|
return argInvoiceData;
|
|
243
245
|
}
|
|
244
246
|
|
|
@@ -246,7 +248,7 @@ export class DebitNotePrintService {
|
|
|
246
248
|
let PrintInfo: any[] = [];
|
|
247
249
|
|
|
248
250
|
let ROLaborParts: any = {};
|
|
249
|
-
|
|
251
|
+
ROLaborParts.Services = InvoicePrintData.Services;
|
|
250
252
|
ROLaborParts.Items = InvoicePrintData.Items;
|
|
251
253
|
|
|
252
254
|
ROLaborParts.Sts = InvoiceStatus;
|
|
@@ -59,53 +59,53 @@ function formatFieldValue(item: any, fieldConfig: any, fixedTo: number) {
|
|
|
59
59
|
return formatNumericLikeValue(signedValue, fixedTo, shouldSkipFixedTo(fieldConfig));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function getTaxValue(item: any, taxName: 'CGST' | 'SGST' | 'IGST' | 'GST', taxKind: 'rate' | 'amount') {
|
|
63
|
-
if (taxName === 'GST') {
|
|
64
|
-
if (taxKind === 'rate') {
|
|
65
|
-
return getCombinedTaxValue(item, ['CombinedTaxPercentage', 'GSTPerc'], [
|
|
66
|
-
['CGSTPerc', 'CGST'],
|
|
67
|
-
['SGSTPerc', 'SGST'],
|
|
68
|
-
['IGSTPerc', 'IGST']
|
|
69
|
-
]);
|
|
70
|
-
}
|
|
71
|
-
return getCombinedTaxValue(item, ['TotalTaxAmount', 'TaxAmount', 'GSTAmt'], [
|
|
72
|
-
['CGSTAmt', 'CGST'],
|
|
73
|
-
['SGSTAmt', 'SGST'],
|
|
74
|
-
['IGSTAmt', 'IGST']
|
|
75
|
-
]);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (taxName === 'IGST') {
|
|
79
|
-
const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
|
|
80
|
-
return getFirstFieldValue(item, fields);
|
|
81
|
-
}
|
|
62
|
+
function getTaxValue(item: any, taxName: 'CGST' | 'SGST' | 'IGST' | 'GST', taxKind: 'rate' | 'amount') {
|
|
63
|
+
if (taxName === 'GST') {
|
|
64
|
+
if (taxKind === 'rate') {
|
|
65
|
+
return getCombinedTaxValue(item, ['CombinedTaxPercentage', 'GSTPerc'], [
|
|
66
|
+
['CGSTPerc', 'CGST'],
|
|
67
|
+
['SGSTPerc', 'SGST'],
|
|
68
|
+
['IGSTPerc', 'IGST']
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
return getCombinedTaxValue(item, ['TotalTaxAmount', 'TaxAmount', 'GSTAmt'], [
|
|
72
|
+
['CGSTAmt', 'CGST'],
|
|
73
|
+
['SGSTAmt', 'SGST'],
|
|
74
|
+
['IGSTAmt', 'IGST']
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (taxName === 'IGST') {
|
|
79
|
+
const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
|
|
80
|
+
return getFirstFieldValue(item, fields);
|
|
81
|
+
}
|
|
82
82
|
const fields = taxKind === 'rate'
|
|
83
83
|
? [`${taxName}Perc`, taxName]
|
|
84
84
|
: [`${taxName}Amt`, taxName];
|
|
85
|
-
return getFirstFieldValue(item, fields);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function getCombinedTaxValue(item: any, combinedFields: string[], componentFieldGroups: string[][]) {
|
|
89
|
-
const combinedValue = getFirstFieldValue(item, combinedFields);
|
|
90
|
-
if (combinedValue) {
|
|
91
|
-
return combinedValue;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const values = componentFieldGroups
|
|
95
|
-
.map((fields: string[]) => getFirstFieldValue(item, fields))
|
|
96
|
-
.filter((value: string) => value !== '');
|
|
97
|
-
|
|
98
|
-
if (values.length === 0) {
|
|
99
|
-
return '';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const numericValues = values.map((value: string) => Number(value.replace(/,/g, '').trim()));
|
|
103
|
-
if (numericValues.some((value: number) => !Number.isFinite(value))) {
|
|
104
|
-
return values[0];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return String(numericValues.reduce((sum: number, value: number) => sum + value, 0));
|
|
108
|
-
}
|
|
85
|
+
return getFirstFieldValue(item, fields);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getCombinedTaxValue(item: any, combinedFields: string[], componentFieldGroups: string[][]) {
|
|
89
|
+
const combinedValue = getFirstFieldValue(item, combinedFields);
|
|
90
|
+
if (combinedValue) {
|
|
91
|
+
return combinedValue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const values = componentFieldGroups
|
|
95
|
+
.map((fields: string[]) => getFirstFieldValue(item, fields))
|
|
96
|
+
.filter((value: string) => value !== '');
|
|
97
|
+
|
|
98
|
+
if (values.length === 0) {
|
|
99
|
+
return '';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const numericValues = values.map((value: string) => Number(value.replace(/,/g, '').trim()));
|
|
103
|
+
if (numericValues.some((value: number) => !Number.isFinite(value))) {
|
|
104
|
+
return values[0];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return String(numericValues.reduce((sum: number, value: number) => sum + value, 0));
|
|
108
|
+
}
|
|
109
109
|
|
|
110
110
|
function shouldRenderNegativeTaxAmount(item: any, column: any) {
|
|
111
111
|
return !!item?.Ret && column?.taxKind === 'amount';
|
|
@@ -137,6 +137,7 @@ function negateNumericLikeValue(value: string) {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export function getFirstFieldValue(item: any, dbFields: string[] = []) {
|
|
140
|
+
console.log('getFirstFieldValue', item, dbFields);
|
|
140
141
|
for (const field of dbFields) {
|
|
141
142
|
const value = readValue(item, field);
|
|
142
143
|
if (value !== undefined && value !== null && value !== '') {
|
|
@@ -274,23 +275,23 @@ function formatExpiryDateValue(value: string) {
|
|
|
274
275
|
function shouldSkipFixedTo(header: any) {
|
|
275
276
|
const text = String(header?.text ?? '').trim().toUpperCase();
|
|
276
277
|
const normalizedText = text.replace(/\s+/g, '');
|
|
277
|
-
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%') || normalizedText === 'QTY' || normalizedText === 'OFFERQTY' || normalizedText === 'OFQTY' || normalizedText === 'MPN') {
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
278
|
+
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%') || normalizedText === 'QTY' || normalizedText === 'OFFERQTY' || normalizedText === 'OFQTY' || normalizedText === 'MPN') {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
280
281
|
|
|
281
282
|
const dbFields = Array.isArray(header?.dbFields) ? header.dbFields : [];
|
|
282
283
|
return dbFields.some((field: any) => {
|
|
283
284
|
const normalized = String(field ?? '').trim().toUpperCase();
|
|
284
285
|
return normalized === 'BN'
|
|
285
|
-
|| normalized === 'BNO'
|
|
286
|
-
|| normalized === 'QTY'
|
|
287
|
-
|| normalized === 'OFQTY'
|
|
288
|
-
|| normalized === 'MPN'
|
|
289
|
-
|| normalized.endsWith('.BN')
|
|
290
|
-
|| normalized.endsWith('.QTY')
|
|
291
|
-
|| normalized.endsWith('.OFQTY')
|
|
292
|
-
|| normalized.endsWith('.MPN')
|
|
293
|
-
|| normalized.endsWith('PERC')
|
|
294
|
-
|| normalized.endsWith('.PERC');
|
|
286
|
+
|| normalized === 'BNO'
|
|
287
|
+
|| normalized === 'QTY'
|
|
288
|
+
|| normalized === 'OFQTY'
|
|
289
|
+
|| normalized === 'MPN'
|
|
290
|
+
|| normalized.endsWith('.BN')
|
|
291
|
+
|| normalized.endsWith('.QTY')
|
|
292
|
+
|| normalized.endsWith('.OFQTY')
|
|
293
|
+
|| normalized.endsWith('.MPN')
|
|
294
|
+
|| normalized.endsWith('PERC')
|
|
295
|
+
|| normalized.endsWith('.PERC');
|
|
295
296
|
});
|
|
296
297
|
}
|