@tomei/finance 0.5.3 → 0.5.5
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/account/account.d.ts +35 -35
- package/dist/account/account.js +233 -233
- package/dist/account/account.repository.d.ts +5 -5
- package/dist/account/account.repository.js +11 -11
- package/dist/account/interfaces/account-attr.interface.d.ts +29 -29
- package/dist/account/interfaces/account-attr.interface.js +2 -2
- package/dist/account/interfaces/account.repository.interface.d.ts +3 -0
- package/dist/account/interfaces/account.repository.interface.js +3 -0
- package/dist/account/interfaces/account.repository.interface.js.map +1 -0
- package/dist/account-system-entity/account-system-entity.d.ts +11 -11
- package/dist/account-system-entity/account-system-entity.js +66 -66
- package/dist/account-system-entity/post-history.repository.d.ts +5 -5
- package/dist/account-system-entity/post-history.repository.js +11 -11
- package/dist/config.d.ts +1888 -1888
- package/dist/config.js +331 -331
- package/dist/customer/customer.d.ts +43 -43
- package/dist/customer/customer.js +237 -236
- package/dist/customer/customer.js.map +1 -1
- package/dist/customer/finance-customer.repository.d.ts +5 -5
- package/dist/customer/finance-customer.repository.js +25 -25
- package/dist/customer/interfaces/customer.repository.interface.d.ts +3 -3
- package/dist/customer/interfaces/customer.repository.interface.js +2 -2
- package/dist/customer/interfaces/finance-customer-attr.interface.d.ts +10 -10
- package/dist/customer/interfaces/finance-customer-attr.interface.js +2 -2
- package/dist/customer/interfaces/finance-customer.repository.interface.d.ts +3 -3
- package/dist/customer/interfaces/finance-customer.repository.interface.js +2 -2
- package/dist/database.d.ts +4 -4
- package/dist/database.js +14 -14
- package/dist/document/document-item.d.ts +38 -38
- package/dist/document/document-item.js +83 -83
- package/dist/document/document-item.repository.d.ts +5 -5
- package/dist/document/document-item.repository.js +11 -11
- package/dist/document/document.d.ts +76 -76
- package/dist/document/document.js +566 -566
- package/dist/document/document.js.map +1 -1
- package/dist/document/document.repository.d.ts +5 -5
- package/dist/document/document.repository.js +11 -11
- package/dist/document/interfaces/document-attr.interface.d.ts +27 -27
- package/dist/document/interfaces/document-attr.interface.js +6 -6
- package/dist/document/interfaces/document-item-attr.interface.d.ts +22 -22
- package/dist/document/interfaces/document-item-attr.interface.js +6 -6
- package/dist/document/interfaces/document-item.repository.interface.d.ts +3 -3
- package/dist/document/interfaces/document-item.repository.interface.js +2 -2
- package/dist/document/interfaces/document.repository.interface.d.ts +3 -0
- package/dist/document/interfaces/document.repository.interface.js +3 -0
- package/dist/document/interfaces/document.repository.interface.js.map +1 -0
- package/dist/enum/doc-type.enum.d.ts +8 -8
- package/dist/enum/doc-type.enum.js +12 -12
- package/dist/enum/document-status.enum.d.ts +6 -6
- package/dist/enum/document-status.enum.js +10 -10
- package/dist/enum/index.d.ts +8 -8
- package/dist/enum/index.js +17 -17
- package/dist/enum/payment-method.enum.d.ts +3 -3
- package/dist/enum/payment-method.enum.js +7 -7
- package/dist/enum/payment-status.enum.d.ts +4 -4
- package/dist/enum/payment-status.enum.js +8 -8
- package/dist/enum/payment-type.enum.d.ts +4 -4
- package/dist/enum/payment-type.enum.js +8 -8
- package/dist/enum/quick-book-client-scopes.enum.d.ts +13 -13
- package/dist/enum/quick-book-client-scopes.enum.js +18 -18
- package/dist/enum/transaction-type.enum.d.ts +4 -4
- package/dist/enum/transaction-type.enum.js +8 -8
- package/dist/finance-company/finance-company.d.ts +57 -57
- package/dist/finance-company/finance-company.js +1191 -1191
- package/dist/finance-company/finance-company.repository.d.ts +5 -5
- package/dist/finance-company/finance-company.repository.js +11 -11
- package/dist/helpers/typeof.d.ts +1 -1
- package/dist/helpers/typeof.js +26 -26
- package/dist/index.d.ts +17 -17
- package/dist/index.js +32 -32
- package/dist/interfaces/account-system.interface.d.ts +13 -13
- package/dist/interfaces/account-system.interface.js +2 -2
- package/dist/interfaces/index.d.ts +2 -2
- package/dist/interfaces/index.js +2 -2
- package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +11 -11
- package/dist/journal-entry/interfaces/journal-entry-attr.interface.js +2 -2
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.d.ts +10 -0
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.js +3 -0
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.js.map +1 -0
- package/dist/journal-entry/journal-entry.d.ts +39 -39
- package/dist/journal-entry/journal-entry.js +215 -215
- package/dist/journal-entry/journal-entry.repository.d.ts +5 -5
- package/dist/journal-entry/journal-entry.repository.js +11 -11
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +17 -17
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js +2 -2
- package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.d.ts +5 -5
- package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js +2 -2
- package/dist/ledger-transaction/ledger-transaction.d.ts +48 -48
- package/dist/ledger-transaction/ledger-transaction.js +155 -155
- package/dist/ledger-transaction/ledger-transaction.repository.d.ts +5 -5
- package/dist/ledger-transaction/ledger-transaction.repository.js +11 -11
- package/dist/models/account.entity.d.ts +30 -30
- package/dist/models/account.entity.js +232 -232
- package/dist/models/customer.entity.d.ts +13 -13
- package/dist/models/customer.entity.js +109 -109
- package/dist/models/document-item.entity.d.ts +27 -27
- package/dist/models/document-item.entity.js +172 -172
- package/dist/models/document.entity.d.ts +36 -36
- package/dist/models/document.entity.js +242 -242
- package/dist/models/finance-company.entity.d.ts +9 -9
- package/dist/models/finance-company.entity.js +44 -44
- package/dist/models/journal-entry.entity.d.ts +16 -16
- package/dist/models/journal-entry.entity.js +127 -127
- package/dist/models/ledger-transaction.entity.d.ts +24 -24
- package/dist/models/ledger-transaction.entity.js +172 -172
- package/dist/models/payment-item.entity.d.ts +12 -12
- package/dist/models/payment-item.entity.js +75 -75
- package/dist/models/payment-method-type.entity.d.ts +13 -13
- package/dist/models/payment-method-type.entity.js +85 -85
- package/dist/models/payment-method.entity.d.ts +10 -10
- package/dist/models/payment-method.entity.js +62 -62
- package/dist/models/payment-paid-with.entity.d.ts +24 -24
- package/dist/models/payment-paid-with.entity.js +158 -158
- package/dist/models/payment.entity.d.ts +27 -27
- package/dist/models/payment.entity.js +188 -188
- package/dist/models/post-history.entity.d.ts +11 -11
- package/dist/models/post-history.entity.js +63 -63
- package/dist/payment/interfaces/payment-attr.interface.d.ts +22 -22
- package/dist/payment/interfaces/payment-attr.interface.js +6 -6
- package/dist/payment/interfaces/payment-item-attr.interface.d.ts +7 -0
- package/dist/payment/interfaces/payment-item-attr.interface.js +7 -0
- package/dist/payment/interfaces/payment-item-attr.interface.js.map +1 -0
- package/dist/payment/interfaces/payment-item.repository.interface.d.ts +3 -0
- package/dist/payment/interfaces/payment-item.repository.interface.js +3 -0
- package/dist/payment/interfaces/payment-item.repository.interface.js.map +1 -0
- package/dist/payment/interfaces/payment-params.interface.d.ts +7 -7
- package/dist/payment/interfaces/payment-params.interface.js +2 -2
- package/dist/payment/interfaces/payment.repository.interface.d.ts +3 -0
- package/dist/payment/interfaces/payment.repository.interface.js +3 -0
- package/dist/payment/interfaces/payment.repository.interface.js.map +1 -0
- package/dist/payment/payment-item.repository.d.ts +17 -0
- package/dist/payment/payment-item.repository.js +51 -0
- package/dist/payment/payment-item.repository.js.map +1 -0
- package/dist/payment/payment.d.ts +51 -51
- package/dist/payment/payment.js +179 -179
- package/dist/payment/payment.repository.d.ts +5 -5
- package/dist/payment/payment.repository.js +11 -11
- package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +10 -10
- package/dist/payment-item/interfaces/payment-item-attr.interface.js +6 -6
- package/dist/payment-item/payment-item.d.ts +23 -23
- package/dist/payment-item/payment-item.js +115 -115
- package/dist/payment-item/payment-item.repository.d.ts +5 -5
- package/dist/payment-item/payment-item.repository.js +11 -11
- package/dist/payment-method/interfaces/payment-method-attr.interface.d.ts +5 -5
- package/dist/payment-method/interfaces/payment-method-attr.interface.js +2 -2
- package/dist/payment-method/payment-method.d.ts +18 -18
- package/dist/payment-method/payment-method.js +98 -98
- package/dist/payment-method/payment-method.repository.d.ts +5 -5
- package/dist/payment-method/payment-method.repository.js +11 -11
- package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.d.ts +8 -8
- package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js +2 -2
- package/dist/payment-method-type/payment-method-type.d.ts +16 -16
- package/dist/payment-method-type/payment-method-type.js +70 -70
- package/dist/payment-method-type/payment-method-type.repository.d.ts +5 -5
- package/dist/payment-method-type/payment-method-type.repository.js +11 -11
- package/dist/payment-paid-with/interfaces/payment-paid-with.interface.d.ts +19 -19
- package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js +6 -6
- package/dist/payment-paid-with/payment-paid-with.d.ts +31 -31
- package/dist/payment-paid-with/payment-paid-with.js +52 -52
- package/dist/payment-paid-with/payment-paid-with.repository.d.ts +5 -5
- package/dist/payment-paid-with/payment-paid-with.repository.js +11 -11
- package/dist/test-document.d.ts +3 -3
- package/dist/test-document.js +18 -18
- package/dist/test.d.ts +1 -1
- package/dist/test.js +7 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/customer/customer.ts +3 -1
- package/src/document/document.ts +10 -6
|
@@ -1,216 +1,216 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const cuid = require("cuid");
|
|
13
|
-
const enum_1 = require("../enum");
|
|
14
|
-
const account_system_entity_1 = require("../account-system-entity/account-system-entity");
|
|
15
|
-
const ledger_transaction_repository_1 = require("../ledger-transaction/ledger-transaction.repository");
|
|
16
|
-
const ledger_transaction_1 = require("../ledger-transaction/ledger-transaction");
|
|
17
|
-
const journal_entry_repository_1 = require("./journal-entry.repository");
|
|
18
|
-
const general_1 = require("@tomei/general");
|
|
19
|
-
class JournalEntry extends account_system_entity_1.AccountSystemEntity {
|
|
20
|
-
get JournalEntryId() {
|
|
21
|
-
return this._JournalEntryId;
|
|
22
|
-
}
|
|
23
|
-
set JournalEntryId(id) {
|
|
24
|
-
this._JournalEntryId = id;
|
|
25
|
-
}
|
|
26
|
-
get RepositoryBase() {
|
|
27
|
-
return JournalEntry._RepositoryBase;
|
|
28
|
-
}
|
|
29
|
-
get TableName() {
|
|
30
|
-
return 'finance_JournalEntry';
|
|
31
|
-
}
|
|
32
|
-
get ObjectName() {
|
|
33
|
-
return this.Name;
|
|
34
|
-
}
|
|
35
|
-
get ObjectId() {
|
|
36
|
-
return this._JournalEntryId;
|
|
37
|
-
}
|
|
38
|
-
constructor(dbTransaction, journalEntryId) {
|
|
39
|
-
super();
|
|
40
|
-
this._JournalEntryId = 'New';
|
|
41
|
-
this.Date = new Date();
|
|
42
|
-
this.Name = '';
|
|
43
|
-
this.Description = '';
|
|
44
|
-
this._DebitTransactions = [];
|
|
45
|
-
this._CreditTransactions = [];
|
|
46
|
-
if (dbTransaction) {
|
|
47
|
-
this._DbTransaction = dbTransaction;
|
|
48
|
-
}
|
|
49
|
-
if (journalEntryId) {
|
|
50
|
-
this.RepositoryBase.findOne({
|
|
51
|
-
where: {
|
|
52
|
-
JournalEntryId: journalEntryId,
|
|
53
|
-
},
|
|
54
|
-
transaction: dbTransaction,
|
|
55
|
-
})
|
|
56
|
-
.then((journalEntryData) => {
|
|
57
|
-
if (journalEntryData) {
|
|
58
|
-
this.CompanyId = journalEntryData.CompanyId;
|
|
59
|
-
this.Date = journalEntryData.Date;
|
|
60
|
-
this.Name = journalEntryData.Name;
|
|
61
|
-
this.Description = journalEntryData.Description;
|
|
62
|
-
this.AccSystemRefId = journalEntryData.AccSystemRefId;
|
|
63
|
-
this.PostedToAccSystemYN = journalEntryData.PostedToAccSystemYN;
|
|
64
|
-
this.PostedById = journalEntryData.PostedById;
|
|
65
|
-
this.PostedDateTime = journalEntryData.PostedDateTime;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
|
|
69
|
-
throw notFoundError;
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
.catch((err) => {
|
|
73
|
-
console.log('Journal entry constructor err: ', err);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
this.init({
|
|
78
|
-
JournalEntryId: 'New',
|
|
79
|
-
CompanyId: '',
|
|
80
|
-
Date: new Date(),
|
|
81
|
-
Name: '',
|
|
82
|
-
Description: '',
|
|
83
|
-
AccSystemRefId: '',
|
|
84
|
-
PostedToAccSystemYN: 'N',
|
|
85
|
-
PostedById: '',
|
|
86
|
-
PostedDateTime: null,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
get DebitTransactions() {
|
|
91
|
-
return new Promise((resolve, reject) => {
|
|
92
|
-
if (this.JournalEntryId !== 'New') {
|
|
93
|
-
JournalEntry._LedgerTransactionRepository
|
|
94
|
-
.findAll({
|
|
95
|
-
where: {
|
|
96
|
-
TransactionType: enum_1.TransactionTypeOptions.DEBIT,
|
|
97
|
-
},
|
|
98
|
-
transaction: this._DbTransaction,
|
|
99
|
-
})
|
|
100
|
-
.then((debitTransactions) => {
|
|
101
|
-
const debitTransactionObjects = debitTransactions.map((debitTransactionData) => new ledger_transaction_1.default(this._DbTransaction, debitTransactionData.TransactionId));
|
|
102
|
-
return Promise.all(debitTransactionObjects);
|
|
103
|
-
})
|
|
104
|
-
.then((debitTransactionObjects) => {
|
|
105
|
-
this._DebitTransactions = debitTransactionObjects;
|
|
106
|
-
resolve(this._DebitTransactions);
|
|
107
|
-
})
|
|
108
|
-
.catch((err) => {
|
|
109
|
-
reject(err);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
resolve(this._DebitTransactions);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
get CreditTransactions() {
|
|
118
|
-
return new Promise((resolve, reject) => {
|
|
119
|
-
if (this.JournalEntryId !== 'New') {
|
|
120
|
-
JournalEntry._LedgerTransactionRepository
|
|
121
|
-
.findAll({
|
|
122
|
-
where: {
|
|
123
|
-
TransactionType: enum_1.TransactionTypeOptions.CREDIT,
|
|
124
|
-
},
|
|
125
|
-
transaction: this._DbTransaction,
|
|
126
|
-
})
|
|
127
|
-
.then((creditTransaction) => {
|
|
128
|
-
const creditTransactionObjects = creditTransaction.map((creditTransactionData) => new ledger_transaction_1.default(this._DbTransaction, creditTransactionData.TransactionId));
|
|
129
|
-
return Promise.all(creditTransactionObjects);
|
|
130
|
-
})
|
|
131
|
-
.then((creditTransactionObjects) => {
|
|
132
|
-
this._CreditTransactions = creditTransactionObjects;
|
|
133
|
-
resolve(this._CreditTransactions);
|
|
134
|
-
})
|
|
135
|
-
.catch((err) => {
|
|
136
|
-
reject(err);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
resolve(this._CreditTransactions);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
init(params) {
|
|
145
|
-
if (params.JournalEntryId)
|
|
146
|
-
this.JournalEntryId = params.JournalEntryId;
|
|
147
|
-
if (params.CompanyId)
|
|
148
|
-
this.CompanyId = params.CompanyId;
|
|
149
|
-
if (params.Date)
|
|
150
|
-
this.Date = params.Date;
|
|
151
|
-
if (params.Name)
|
|
152
|
-
this.Name = params.Name;
|
|
153
|
-
if (params.Description)
|
|
154
|
-
this.Description = params.Description;
|
|
155
|
-
if (params.PostedById)
|
|
156
|
-
this.PostedById = params.PostedById;
|
|
157
|
-
if (params.PostedToAccSystemYN)
|
|
158
|
-
this.PostedToAccSystemYN = params.PostedToAccSystemYN;
|
|
159
|
-
if (params.PostedDateTime)
|
|
160
|
-
this.PostedDateTime = params.PostedDateTime;
|
|
161
|
-
}
|
|
162
|
-
getData() {
|
|
163
|
-
return {
|
|
164
|
-
JournalEntryId: this.JournalEntryId,
|
|
165
|
-
Date: this.Date,
|
|
166
|
-
Name: this.Name,
|
|
167
|
-
Description: this.Description,
|
|
168
|
-
PostedById: this.PostedById,
|
|
169
|
-
PostedToAccSystemYN: this.PostedToAccSystemYN,
|
|
170
|
-
PostedDateTime: this.PostedDateTime,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
create() {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
return yield this.RepositoryBase.create(this.getData);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
save(userId, dbTransaction) {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
try {
|
|
181
|
-
this.JournalEntryId = cuid();
|
|
182
|
-
const data = yield this.RepositoryBase.create({
|
|
183
|
-
JournalEntryId: this.JournalEntryId,
|
|
184
|
-
CompanyId: this.CompanyId,
|
|
185
|
-
Date: this.Date,
|
|
186
|
-
Name: this.Name,
|
|
187
|
-
Description: this.Description,
|
|
188
|
-
PostedById: userId,
|
|
189
|
-
PostedToAccSystemYN: this.PostedToAccSystemYN,
|
|
190
|
-
PostedDateTime: this.PostedDateTime,
|
|
191
|
-
}, { transaction: dbTransaction });
|
|
192
|
-
return data;
|
|
193
|
-
}
|
|
194
|
-
catch (error) {
|
|
195
|
-
throw error;
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
newLedgerTransaction(transactionType) {
|
|
200
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
const ledgerTransaction = new ledger_transaction_1.default(transactionType, this._DbTransaction);
|
|
202
|
-
ledgerTransaction.JournalEntryId = this.JournalEntryId;
|
|
203
|
-
if (transactionType === enum_1.TransactionTypeOptions.DEBIT) {
|
|
204
|
-
this._DebitTransactions.push(ledgerTransaction);
|
|
205
|
-
}
|
|
206
|
-
else if (transactionType === enum_1.TransactionTypeOptions.CREDIT) {
|
|
207
|
-
this._CreditTransactions.push(ledgerTransaction);
|
|
208
|
-
}
|
|
209
|
-
return ledgerTransaction;
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
exports.default = JournalEntry;
|
|
214
|
-
JournalEntry._RepositoryBase = new journal_entry_repository_1.JournalEntryRepository();
|
|
215
|
-
JournalEntry._LedgerTransactionRepository = new ledger_transaction_repository_1.LedgerTransactionRepository();
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const cuid = require("cuid");
|
|
13
|
+
const enum_1 = require("../enum");
|
|
14
|
+
const account_system_entity_1 = require("../account-system-entity/account-system-entity");
|
|
15
|
+
const ledger_transaction_repository_1 = require("../ledger-transaction/ledger-transaction.repository");
|
|
16
|
+
const ledger_transaction_1 = require("../ledger-transaction/ledger-transaction");
|
|
17
|
+
const journal_entry_repository_1 = require("./journal-entry.repository");
|
|
18
|
+
const general_1 = require("@tomei/general");
|
|
19
|
+
class JournalEntry extends account_system_entity_1.AccountSystemEntity {
|
|
20
|
+
get JournalEntryId() {
|
|
21
|
+
return this._JournalEntryId;
|
|
22
|
+
}
|
|
23
|
+
set JournalEntryId(id) {
|
|
24
|
+
this._JournalEntryId = id;
|
|
25
|
+
}
|
|
26
|
+
get RepositoryBase() {
|
|
27
|
+
return JournalEntry._RepositoryBase;
|
|
28
|
+
}
|
|
29
|
+
get TableName() {
|
|
30
|
+
return 'finance_JournalEntry';
|
|
31
|
+
}
|
|
32
|
+
get ObjectName() {
|
|
33
|
+
return this.Name;
|
|
34
|
+
}
|
|
35
|
+
get ObjectId() {
|
|
36
|
+
return this._JournalEntryId;
|
|
37
|
+
}
|
|
38
|
+
constructor(dbTransaction, journalEntryId) {
|
|
39
|
+
super();
|
|
40
|
+
this._JournalEntryId = 'New';
|
|
41
|
+
this.Date = new Date();
|
|
42
|
+
this.Name = '';
|
|
43
|
+
this.Description = '';
|
|
44
|
+
this._DebitTransactions = [];
|
|
45
|
+
this._CreditTransactions = [];
|
|
46
|
+
if (dbTransaction) {
|
|
47
|
+
this._DbTransaction = dbTransaction;
|
|
48
|
+
}
|
|
49
|
+
if (journalEntryId) {
|
|
50
|
+
this.RepositoryBase.findOne({
|
|
51
|
+
where: {
|
|
52
|
+
JournalEntryId: journalEntryId,
|
|
53
|
+
},
|
|
54
|
+
transaction: dbTransaction,
|
|
55
|
+
})
|
|
56
|
+
.then((journalEntryData) => {
|
|
57
|
+
if (journalEntryData) {
|
|
58
|
+
this.CompanyId = journalEntryData.CompanyId;
|
|
59
|
+
this.Date = journalEntryData.Date;
|
|
60
|
+
this.Name = journalEntryData.Name;
|
|
61
|
+
this.Description = journalEntryData.Description;
|
|
62
|
+
this.AccSystemRefId = journalEntryData.AccSystemRefId;
|
|
63
|
+
this.PostedToAccSystemYN = journalEntryData.PostedToAccSystemYN;
|
|
64
|
+
this.PostedById = journalEntryData.PostedById;
|
|
65
|
+
this.PostedDateTime = journalEntryData.PostedDateTime;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
|
|
69
|
+
throw notFoundError;
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
.catch((err) => {
|
|
73
|
+
console.log('Journal entry constructor err: ', err);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.init({
|
|
78
|
+
JournalEntryId: 'New',
|
|
79
|
+
CompanyId: '',
|
|
80
|
+
Date: new Date(),
|
|
81
|
+
Name: '',
|
|
82
|
+
Description: '',
|
|
83
|
+
AccSystemRefId: '',
|
|
84
|
+
PostedToAccSystemYN: 'N',
|
|
85
|
+
PostedById: '',
|
|
86
|
+
PostedDateTime: null,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
get DebitTransactions() {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
if (this.JournalEntryId !== 'New') {
|
|
93
|
+
JournalEntry._LedgerTransactionRepository
|
|
94
|
+
.findAll({
|
|
95
|
+
where: {
|
|
96
|
+
TransactionType: enum_1.TransactionTypeOptions.DEBIT,
|
|
97
|
+
},
|
|
98
|
+
transaction: this._DbTransaction,
|
|
99
|
+
})
|
|
100
|
+
.then((debitTransactions) => {
|
|
101
|
+
const debitTransactionObjects = debitTransactions.map((debitTransactionData) => new ledger_transaction_1.default(this._DbTransaction, debitTransactionData.TransactionId));
|
|
102
|
+
return Promise.all(debitTransactionObjects);
|
|
103
|
+
})
|
|
104
|
+
.then((debitTransactionObjects) => {
|
|
105
|
+
this._DebitTransactions = debitTransactionObjects;
|
|
106
|
+
resolve(this._DebitTransactions);
|
|
107
|
+
})
|
|
108
|
+
.catch((err) => {
|
|
109
|
+
reject(err);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
resolve(this._DebitTransactions);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
get CreditTransactions() {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
if (this.JournalEntryId !== 'New') {
|
|
120
|
+
JournalEntry._LedgerTransactionRepository
|
|
121
|
+
.findAll({
|
|
122
|
+
where: {
|
|
123
|
+
TransactionType: enum_1.TransactionTypeOptions.CREDIT,
|
|
124
|
+
},
|
|
125
|
+
transaction: this._DbTransaction,
|
|
126
|
+
})
|
|
127
|
+
.then((creditTransaction) => {
|
|
128
|
+
const creditTransactionObjects = creditTransaction.map((creditTransactionData) => new ledger_transaction_1.default(this._DbTransaction, creditTransactionData.TransactionId));
|
|
129
|
+
return Promise.all(creditTransactionObjects);
|
|
130
|
+
})
|
|
131
|
+
.then((creditTransactionObjects) => {
|
|
132
|
+
this._CreditTransactions = creditTransactionObjects;
|
|
133
|
+
resolve(this._CreditTransactions);
|
|
134
|
+
})
|
|
135
|
+
.catch((err) => {
|
|
136
|
+
reject(err);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
resolve(this._CreditTransactions);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
init(params) {
|
|
145
|
+
if (params.JournalEntryId)
|
|
146
|
+
this.JournalEntryId = params.JournalEntryId;
|
|
147
|
+
if (params.CompanyId)
|
|
148
|
+
this.CompanyId = params.CompanyId;
|
|
149
|
+
if (params.Date)
|
|
150
|
+
this.Date = params.Date;
|
|
151
|
+
if (params.Name)
|
|
152
|
+
this.Name = params.Name;
|
|
153
|
+
if (params.Description)
|
|
154
|
+
this.Description = params.Description;
|
|
155
|
+
if (params.PostedById)
|
|
156
|
+
this.PostedById = params.PostedById;
|
|
157
|
+
if (params.PostedToAccSystemYN)
|
|
158
|
+
this.PostedToAccSystemYN = params.PostedToAccSystemYN;
|
|
159
|
+
if (params.PostedDateTime)
|
|
160
|
+
this.PostedDateTime = params.PostedDateTime;
|
|
161
|
+
}
|
|
162
|
+
getData() {
|
|
163
|
+
return {
|
|
164
|
+
JournalEntryId: this.JournalEntryId,
|
|
165
|
+
Date: this.Date,
|
|
166
|
+
Name: this.Name,
|
|
167
|
+
Description: this.Description,
|
|
168
|
+
PostedById: this.PostedById,
|
|
169
|
+
PostedToAccSystemYN: this.PostedToAccSystemYN,
|
|
170
|
+
PostedDateTime: this.PostedDateTime,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
create() {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
return yield this.RepositoryBase.create(this.getData);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
save(userId, dbTransaction) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
try {
|
|
181
|
+
this.JournalEntryId = cuid();
|
|
182
|
+
const data = yield this.RepositoryBase.create({
|
|
183
|
+
JournalEntryId: this.JournalEntryId,
|
|
184
|
+
CompanyId: this.CompanyId,
|
|
185
|
+
Date: this.Date,
|
|
186
|
+
Name: this.Name,
|
|
187
|
+
Description: this.Description,
|
|
188
|
+
PostedById: userId,
|
|
189
|
+
PostedToAccSystemYN: this.PostedToAccSystemYN,
|
|
190
|
+
PostedDateTime: this.PostedDateTime,
|
|
191
|
+
}, { transaction: dbTransaction });
|
|
192
|
+
return data;
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
newLedgerTransaction(transactionType) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const ledgerTransaction = new ledger_transaction_1.default(transactionType, this._DbTransaction);
|
|
202
|
+
ledgerTransaction.JournalEntryId = this.JournalEntryId;
|
|
203
|
+
if (transactionType === enum_1.TransactionTypeOptions.DEBIT) {
|
|
204
|
+
this._DebitTransactions.push(ledgerTransaction);
|
|
205
|
+
}
|
|
206
|
+
else if (transactionType === enum_1.TransactionTypeOptions.CREDIT) {
|
|
207
|
+
this._CreditTransactions.push(ledgerTransaction);
|
|
208
|
+
}
|
|
209
|
+
return ledgerTransaction;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.default = JournalEntry;
|
|
214
|
+
JournalEntry._RepositoryBase = new journal_entry_repository_1.JournalEntryRepository();
|
|
215
|
+
JournalEntry._LedgerTransactionRepository = new ledger_transaction_repository_1.LedgerTransactionRepository();
|
|
216
216
|
//# sourceMappingURL=journal-entry.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
-
import JournalEntryModel from '../models/journal-entry.entity';
|
|
3
|
-
export declare class JournalEntryRepository extends RepositoryBase<JournalEntryModel> implements IRepositoryBase<JournalEntryModel> {
|
|
4
|
-
constructor();
|
|
5
|
-
}
|
|
1
|
+
import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
2
|
+
import JournalEntryModel from '../models/journal-entry.entity';
|
|
3
|
+
export declare class JournalEntryRepository extends RepositoryBase<JournalEntryModel> implements IRepositoryBase<JournalEntryModel> {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JournalEntryRepository = void 0;
|
|
4
|
-
const general_1 = require("@tomei/general");
|
|
5
|
-
const journal_entry_entity_1 = require("../models/journal-entry.entity");
|
|
6
|
-
class JournalEntryRepository extends general_1.RepositoryBase {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(journal_entry_entity_1.default);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.JournalEntryRepository = JournalEntryRepository;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JournalEntryRepository = void 0;
|
|
4
|
+
const general_1 = require("@tomei/general");
|
|
5
|
+
const journal_entry_entity_1 = require("../models/journal-entry.entity");
|
|
6
|
+
class JournalEntryRepository extends general_1.RepositoryBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(journal_entry_entity_1.default);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.JournalEntryRepository = JournalEntryRepository;
|
|
12
12
|
//# sourceMappingURL=journal-entry.repository.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { TransactionTypeOptions } from '../../enum';
|
|
2
|
-
export interface ILedgerTransactionAttr {
|
|
3
|
-
TransactionId?: string;
|
|
4
|
-
TransactionType?: TransactionTypeOptions;
|
|
5
|
-
JournalEntryId?: string;
|
|
6
|
-
AccountNo?: string;
|
|
7
|
-
Date?: Date;
|
|
8
|
-
Name?: string;
|
|
9
|
-
Description?: string;
|
|
10
|
-
Currency?: string;
|
|
11
|
-
DebitAmount?: number;
|
|
12
|
-
CreditAmount?: number;
|
|
13
|
-
RelatedObjectId?: string;
|
|
14
|
-
RelatedObjectType?: string;
|
|
15
|
-
RelatedDocNo?: string;
|
|
16
|
-
RelatedPaymentId?: string;
|
|
17
|
-
}
|
|
1
|
+
import { TransactionTypeOptions } from '../../enum';
|
|
2
|
+
export interface ILedgerTransactionAttr {
|
|
3
|
+
TransactionId?: string;
|
|
4
|
+
TransactionType?: TransactionTypeOptions;
|
|
5
|
+
JournalEntryId?: string;
|
|
6
|
+
AccountNo?: string;
|
|
7
|
+
Date?: Date;
|
|
8
|
+
Name?: string;
|
|
9
|
+
Description?: string;
|
|
10
|
+
Currency?: string;
|
|
11
|
+
DebitAmount?: number;
|
|
12
|
+
CreditAmount?: number;
|
|
13
|
+
RelatedObjectId?: string;
|
|
14
|
+
RelatedObjectType?: string;
|
|
15
|
+
RelatedDocNo?: string;
|
|
16
|
+
RelatedPaymentId?: string;
|
|
17
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=ledger-transaction-attr.interface.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface ILedgerTransactionRepository<T> {
|
|
2
|
-
create?(data: T | any, options?: any): Promise<T> | any;
|
|
3
|
-
findAll?(options?: any): Promise<T[]>;
|
|
4
|
-
findOne?(options: any): Promise<T>;
|
|
5
|
-
}
|
|
1
|
+
export interface ILedgerTransactionRepository<T> {
|
|
2
|
+
create?(data: T | any, options?: any): Promise<T> | any;
|
|
3
|
+
findAll?(options?: any): Promise<T[]>;
|
|
4
|
+
findOne?(options: any): Promise<T>;
|
|
5
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=ledger-transaction.repository.interface.js.map
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { ILedgerTransactionAttr } from './interfaces/ledger-transaction-attr.interface';
|
|
2
|
-
import { TransactionTypeOptions } from '../enum/transaction-type.enum';
|
|
3
|
-
import LedgerTransactionModel from '../models/ledger-transaction.entity';
|
|
4
|
-
export default class LedgerTransaction {
|
|
5
|
-
TransactionId: string;
|
|
6
|
-
TransactionType: TransactionTypeOptions;
|
|
7
|
-
JournalEntryId: string;
|
|
8
|
-
AccountNo: string;
|
|
9
|
-
Date: Date;
|
|
10
|
-
Name: string;
|
|
11
|
-
Description: string;
|
|
12
|
-
Currency: string;
|
|
13
|
-
DebitAmount: number;
|
|
14
|
-
CreditAmount: number;
|
|
15
|
-
RelatedObjectId: string;
|
|
16
|
-
RelatedObjectType: string;
|
|
17
|
-
RelatedDocNo: string;
|
|
18
|
-
RelatedPaymentId: string;
|
|
19
|
-
private _DbTransaction;
|
|
20
|
-
private static _LedgerTransactionRepository;
|
|
21
|
-
constructor(transactionType: TransactionTypeOptions, dbTransaction?: any, transactionId?: string);
|
|
22
|
-
init(params?: ILedgerTransactionAttr): void;
|
|
23
|
-
getData(): {
|
|
24
|
-
TransactionId: string;
|
|
25
|
-
TransactionType: TransactionTypeOptions;
|
|
26
|
-
JournalEntryId: string;
|
|
27
|
-
AccountNo: string;
|
|
28
|
-
Date: Date;
|
|
29
|
-
Name: string;
|
|
30
|
-
Description: string;
|
|
31
|
-
Currency: string;
|
|
32
|
-
DebitAmount: number;
|
|
33
|
-
CreditAmount: number;
|
|
34
|
-
RelatedObjectId: string;
|
|
35
|
-
RelatedObjectType: string;
|
|
36
|
-
RelatedDocNo: string;
|
|
37
|
-
RelatedPaymentId: string;
|
|
38
|
-
};
|
|
39
|
-
save(dbTransaction?: any): Promise<LedgerTransactionModel>;
|
|
40
|
-
create(): Promise<LedgerTransactionModel>;
|
|
41
|
-
findAll(options: any): Promise<LedgerTransactionModel[]>;
|
|
42
|
-
findAllWithPagination(options: any): Promise<{
|
|
43
|
-
count: number;
|
|
44
|
-
rows: LedgerTransactionModel[];
|
|
45
|
-
}>;
|
|
46
|
-
accountTransactionHistory(accountNo: string): Promise<LedgerTransactionModel[]>;
|
|
47
|
-
newLedgerTransaction(transactionType: TransactionTypeOptions, journalEntryId?: string): Promise<any>;
|
|
48
|
-
}
|
|
1
|
+
import { ILedgerTransactionAttr } from './interfaces/ledger-transaction-attr.interface';
|
|
2
|
+
import { TransactionTypeOptions } from '../enum/transaction-type.enum';
|
|
3
|
+
import LedgerTransactionModel from '../models/ledger-transaction.entity';
|
|
4
|
+
export default class LedgerTransaction {
|
|
5
|
+
TransactionId: string;
|
|
6
|
+
TransactionType: TransactionTypeOptions;
|
|
7
|
+
JournalEntryId: string;
|
|
8
|
+
AccountNo: string;
|
|
9
|
+
Date: Date;
|
|
10
|
+
Name: string;
|
|
11
|
+
Description: string;
|
|
12
|
+
Currency: string;
|
|
13
|
+
DebitAmount: number;
|
|
14
|
+
CreditAmount: number;
|
|
15
|
+
RelatedObjectId: string;
|
|
16
|
+
RelatedObjectType: string;
|
|
17
|
+
RelatedDocNo: string;
|
|
18
|
+
RelatedPaymentId: string;
|
|
19
|
+
private _DbTransaction;
|
|
20
|
+
private static _LedgerTransactionRepository;
|
|
21
|
+
constructor(transactionType: TransactionTypeOptions, dbTransaction?: any, transactionId?: string);
|
|
22
|
+
init(params?: ILedgerTransactionAttr): void;
|
|
23
|
+
getData(): {
|
|
24
|
+
TransactionId: string;
|
|
25
|
+
TransactionType: TransactionTypeOptions;
|
|
26
|
+
JournalEntryId: string;
|
|
27
|
+
AccountNo: string;
|
|
28
|
+
Date: Date;
|
|
29
|
+
Name: string;
|
|
30
|
+
Description: string;
|
|
31
|
+
Currency: string;
|
|
32
|
+
DebitAmount: number;
|
|
33
|
+
CreditAmount: number;
|
|
34
|
+
RelatedObjectId: string;
|
|
35
|
+
RelatedObjectType: string;
|
|
36
|
+
RelatedDocNo: string;
|
|
37
|
+
RelatedPaymentId: string;
|
|
38
|
+
};
|
|
39
|
+
save(dbTransaction?: any): Promise<LedgerTransactionModel>;
|
|
40
|
+
create(): Promise<LedgerTransactionModel>;
|
|
41
|
+
findAll(options: any): Promise<LedgerTransactionModel[]>;
|
|
42
|
+
findAllWithPagination(options: any): Promise<{
|
|
43
|
+
count: number;
|
|
44
|
+
rows: LedgerTransactionModel[];
|
|
45
|
+
}>;
|
|
46
|
+
accountTransactionHistory(accountNo: string): Promise<LedgerTransactionModel[]>;
|
|
47
|
+
newLedgerTransaction(transactionType: TransactionTypeOptions, journalEntryId?: string): Promise<any>;
|
|
48
|
+
}
|