@tomei/finance 0.3.19 → 0.3.21
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/journal-entry/journal-entry.d.ts +0 -2
- package/dist/journal-entry/journal-entry.js +22 -24
- package/dist/journal-entry/journal-entry.js.map +1 -1
- package/dist/ledger-transaction/ledger-transaction.d.ts +2 -2
- package/dist/ledger-transaction/ledger-transaction.js +9 -3
- package/dist/ledger-transaction/ledger-transaction.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/journal-entry/journal-entry.ts +25 -31
- package/src/ledger-transaction/ledger-transaction.ts +11 -4
package/package.json
CHANGED
|
@@ -19,11 +19,9 @@ export default class JournalEntry extends AccountSystemEntity {
|
|
|
19
19
|
private static _LedgerTransactionRepository =
|
|
20
20
|
new LedgerTransactionRepository();
|
|
21
21
|
|
|
22
|
-
ledgerTransactionRepository: LedgerTransactionRepository;
|
|
23
|
-
|
|
24
22
|
private _DbTransaction: any;
|
|
25
|
-
private _DebitTransactions =
|
|
26
|
-
private _CreditTransactions =
|
|
23
|
+
private _DebitTransactions: LedgerTransaction[] = [];
|
|
24
|
+
private _CreditTransactions: LedgerTransaction[] = [];
|
|
27
25
|
|
|
28
26
|
get JournalEntryId() {
|
|
29
27
|
return this._JournalEntryId;
|
|
@@ -79,6 +77,18 @@ export default class JournalEntry extends AccountSystemEntity {
|
|
|
79
77
|
.catch((err) => {
|
|
80
78
|
console.log('Journal entry constructor err: ', err);
|
|
81
79
|
});
|
|
80
|
+
} else {
|
|
81
|
+
this.init({
|
|
82
|
+
JournalEntryId: cuid(),
|
|
83
|
+
CompanyId: this.CompanyId,
|
|
84
|
+
Date: new Date(),
|
|
85
|
+
Name: '',
|
|
86
|
+
Description: '',
|
|
87
|
+
AccSystemRefId: '',
|
|
88
|
+
PostedToAccSystemYN: 'N',
|
|
89
|
+
PostedById: '',
|
|
90
|
+
PostedDateTime: null,
|
|
91
|
+
});
|
|
82
92
|
}
|
|
83
93
|
}
|
|
84
94
|
|
|
@@ -97,12 +107,11 @@ export default class JournalEntry extends AccountSystemEntity {
|
|
|
97
107
|
})
|
|
98
108
|
.then((debitTransactions) => {
|
|
99
109
|
const debitTransactionObjects = debitTransactions.map(
|
|
100
|
-
(debitTransactionData) =>
|
|
101
|
-
new LedgerTransaction(
|
|
110
|
+
(debitTransactionData) => new LedgerTransaction(
|
|
102
111
|
this._DbTransaction,
|
|
103
112
|
debitTransactionData.TransactionId,
|
|
104
|
-
)
|
|
105
|
-
|
|
113
|
+
)
|
|
114
|
+
|
|
106
115
|
);
|
|
107
116
|
return Promise.all(debitTransactionObjects);
|
|
108
117
|
})
|
|
@@ -133,12 +142,12 @@ export default class JournalEntry extends AccountSystemEntity {
|
|
|
133
142
|
})
|
|
134
143
|
.then((creditTransaction) => {
|
|
135
144
|
const creditTransactionObjects = creditTransaction.map(
|
|
136
|
-
(creditTransactionData) =>
|
|
145
|
+
(creditTransactionData) =>
|
|
137
146
|
new LedgerTransaction(
|
|
138
147
|
this._DbTransaction,
|
|
139
148
|
creditTransactionData.TransactionId,
|
|
140
|
-
)
|
|
141
|
-
|
|
149
|
+
)
|
|
150
|
+
|
|
142
151
|
);
|
|
143
152
|
return Promise.all(creditTransactionObjects);
|
|
144
153
|
})
|
|
@@ -258,33 +267,18 @@ export default class JournalEntry extends AccountSystemEntity {
|
|
|
258
267
|
async newLedgerTransaction(
|
|
259
268
|
transactionType: TransactionTypeOptions,
|
|
260
269
|
): Promise<LedgerTransaction> {
|
|
261
|
-
this.init({
|
|
262
|
-
JournalEntryId: cuid(),
|
|
263
|
-
CompanyId: this.CompanyId,
|
|
264
|
-
Date: new Date(),
|
|
265
|
-
Name: '',
|
|
266
|
-
Description: '',
|
|
267
|
-
AccSystemRefId: '',
|
|
268
|
-
PostedToAccSystemYN: 'N',
|
|
269
|
-
PostedById: '',
|
|
270
|
-
PostedDateTime: null,
|
|
271
|
-
});
|
|
272
270
|
|
|
273
271
|
const ledgerTransaction = new LedgerTransaction(
|
|
274
|
-
this.
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
const newLedgerTransaction = await ledgerTransaction.newLedgerTransaction(
|
|
278
|
-
transactionType,
|
|
279
|
-
this.JournalEntryId,
|
|
272
|
+
this._DbTransaction,
|
|
280
273
|
);
|
|
274
|
+
ledgerTransaction.JournalEntryId = this.JournalEntryId;
|
|
281
275
|
|
|
282
276
|
if (transactionType === TransactionTypeOptions.DEBIT) {
|
|
283
|
-
this.
|
|
277
|
+
this._DebitTransactions.push(ledgerTransaction);
|
|
284
278
|
} else if (transactionType === TransactionTypeOptions.CREDIT) {
|
|
285
|
-
this.
|
|
279
|
+
this._CreditTransactions.push(ledgerTransaction);
|
|
286
280
|
}
|
|
287
281
|
|
|
288
|
-
return
|
|
282
|
+
return ledgerTransaction;
|
|
289
283
|
}
|
|
290
284
|
}
|
|
@@ -17,10 +17,16 @@ export default class LedgerTransaction {
|
|
|
17
17
|
RelatedObjectType: string;
|
|
18
18
|
|
|
19
19
|
TransactionType: string;
|
|
20
|
+
private _DbTransaction: any;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
private static _LedgerTransactionRepository =
|
|
23
|
+
new LedgerTransactionRepository();
|
|
22
24
|
|
|
23
|
-
constructor(dbTransaction?: any, transactionId?: string) {
|
|
25
|
+
constructor(dbTransaction?: any, transactionId?: string) {
|
|
26
|
+
if(dbTransaction){
|
|
27
|
+
this._DbTransaction = dbTransaction;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
24
30
|
|
|
25
31
|
init(params?: ILedgerTransactionAttr) {
|
|
26
32
|
this.TransactionId = params.TransactionId;
|
|
@@ -55,7 +61,7 @@ export default class LedgerTransaction {
|
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
async create() {
|
|
58
|
-
return await
|
|
64
|
+
return await LedgerTransaction._LedgerTransactionRepository.create(this.getData, {transaction: this._DbTransaction});
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
async newLedgerTransaction(
|
|
@@ -65,7 +71,8 @@ export default class LedgerTransaction {
|
|
|
65
71
|
this.init({
|
|
66
72
|
TransactionId: cuid(),
|
|
67
73
|
TransactionType: transactionType,
|
|
68
|
-
JournalEntryId:
|
|
74
|
+
JournalEntryId: journalEntryId,
|
|
75
|
+
//TODO: AccountNo should be Filled In. Not sure with What
|
|
69
76
|
AccountNo: '',
|
|
70
77
|
Date: new Date(),
|
|
71
78
|
Name: '',
|