@tomei/finance 0.3.91 → 0.3.93
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.js +7 -0
- package/dist/account/account.js.map +1 -1
- package/dist/customer/customer.d.ts +2 -1
- package/dist/customer/customer.js +28 -28
- package/dist/customer/customer.js.map +1 -1
- package/dist/finance-company/finance-company.js +4 -0
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/account/account.ts +13 -0
- package/src/customer/customer.ts +82 -62
- package/src/finance-company/finance-company.ts +12 -0
package/package.json
CHANGED
package/src/account/account.ts
CHANGED
|
@@ -201,13 +201,20 @@ export default class Account extends AccountSystemEntity {
|
|
|
201
201
|
dbTransaction?: any,
|
|
202
202
|
): Promise<AccountModel> {
|
|
203
203
|
this.AccSystemRefId = AccSystemRefId;
|
|
204
|
+
console.log('Account Save: Before AccountNo FindOne');
|
|
205
|
+
|
|
204
206
|
let data = await this.RepositoryBase.findOne({
|
|
205
207
|
where: {
|
|
206
208
|
AccountNo: this.AccountNo,
|
|
207
209
|
},
|
|
208
210
|
transaction: dbTransaction,
|
|
209
211
|
});
|
|
212
|
+
console.log('Account Save: After AccountNo FindOne');
|
|
213
|
+
console.log(data, '<><><><><> Account Data Result <><><><><><>');
|
|
214
|
+
|
|
210
215
|
if (data) {
|
|
216
|
+
console.log('Account Save: THERE IS DATA FOUND');
|
|
217
|
+
|
|
211
218
|
this.AccountNo = data.AccountNo;
|
|
212
219
|
this.AccSystemRefId = data.AccSystemRefId;
|
|
213
220
|
this.Name = data.Name;
|
|
@@ -223,6 +230,8 @@ export default class Account extends AccountSystemEntity {
|
|
|
223
230
|
this.CreatedAt = data.CreatedAt;
|
|
224
231
|
this.CreatedById = data.CreatedById;
|
|
225
232
|
} else {
|
|
233
|
+
console.log('Account Save: THERE IS NO DATA FOUND');
|
|
234
|
+
|
|
226
235
|
data = await this.RepositoryBase.create(
|
|
227
236
|
{
|
|
228
237
|
AccountNo: this.AccountNo,
|
|
@@ -244,8 +253,12 @@ export default class Account extends AccountSystemEntity {
|
|
|
244
253
|
transaction: dbTransaction,
|
|
245
254
|
},
|
|
246
255
|
);
|
|
256
|
+
|
|
257
|
+
console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
|
|
247
258
|
}
|
|
248
259
|
|
|
260
|
+
console.log(data, 'Account Save: Account details returned');
|
|
261
|
+
|
|
249
262
|
return data;
|
|
250
263
|
}
|
|
251
264
|
}
|
package/src/customer/customer.ts
CHANGED
|
@@ -38,6 +38,8 @@ export default abstract class FinanceCustomerBase
|
|
|
38
38
|
private _AccountReceivable: Account;
|
|
39
39
|
private _AccountPayable: Account;
|
|
40
40
|
|
|
41
|
+
protected _DbTransaction: any;
|
|
42
|
+
|
|
41
43
|
private static _AccountRepository = new AccountRepository();
|
|
42
44
|
|
|
43
45
|
// note: getDetails from spec is void type. Meaning that this probably needed a fix soon
|
|
@@ -91,7 +93,12 @@ export default abstract class FinanceCustomerBase
|
|
|
91
93
|
custSystemRefId: string,
|
|
92
94
|
custSystemCode: string,
|
|
93
95
|
sFinanceCompanyId: string,
|
|
96
|
+
dbTransaction?: any,
|
|
94
97
|
): Promise<C> {
|
|
98
|
+
if (!dbTransaction) {
|
|
99
|
+
dbTransaction = await FinanceDb.getConnection().transaction();
|
|
100
|
+
}
|
|
101
|
+
|
|
95
102
|
const financeCustomerData =
|
|
96
103
|
await FinanceCustomerBase._FinanceCustomerRepository.findOne({
|
|
97
104
|
where: {
|
|
@@ -99,9 +106,11 @@ export default abstract class FinanceCustomerBase
|
|
|
99
106
|
CustSystemCode: custSystemCode,
|
|
100
107
|
CustSystemRefId: custSystemRefId,
|
|
101
108
|
},
|
|
109
|
+
transaction: dbTransaction,
|
|
102
110
|
});
|
|
103
111
|
if (financeCustomerData) {
|
|
104
112
|
const self = new this();
|
|
113
|
+
self._DbTransaction = dbTransaction;
|
|
105
114
|
self.CustomerId = financeCustomerData.CustomerId;
|
|
106
115
|
self.CompanyId = sFinanceCompanyId;
|
|
107
116
|
self.CustSystemCode = custSystemCode;
|
|
@@ -119,90 +128,101 @@ export default abstract class FinanceCustomerBase
|
|
|
119
128
|
|
|
120
129
|
get AccountReceivable(): Promise<Account> {
|
|
121
130
|
return new Promise((resolve, reject) => {
|
|
122
|
-
let transaction;
|
|
131
|
+
let transaction = this._DbTransaction;
|
|
123
132
|
if (this._AccountReceivable) {
|
|
124
133
|
resolve(this._AccountReceivable);
|
|
125
134
|
} else {
|
|
126
|
-
FinanceDb.getConnection()
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
// FinanceDb.getConnection()
|
|
136
|
+
// .transaction()
|
|
137
|
+
// transaction
|
|
138
|
+
// .then((t) => {
|
|
139
|
+
// transaction = t;
|
|
140
|
+
return (
|
|
141
|
+
FinanceCustomerBase._AccountRepository
|
|
142
|
+
.findOne({
|
|
131
143
|
where: {
|
|
132
144
|
AccountType: 'Account Receivable',
|
|
133
145
|
OwnerId: this.CustomerId,
|
|
134
146
|
OwnerType: type(this),
|
|
135
147
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
transaction,
|
|
149
|
+
})
|
|
150
|
+
// })
|
|
151
|
+
.then((accountData) => {
|
|
152
|
+
this._AccountReceivable = new Account(transaction);
|
|
153
|
+
if (accountData) {
|
|
154
|
+
this._AccountReceivable.AccountNo = accountData.AccountNo;
|
|
155
|
+
this._AccountReceivable.ParentAccountNo =
|
|
156
|
+
accountData.ParentAccountNo;
|
|
157
|
+
this._AccountReceivable.AccountType = accountData.AccountType;
|
|
158
|
+
this._AccountReceivable.OwnerId = accountData.OwnerId;
|
|
159
|
+
this._AccountReceivable.OwnerType = accountData.OwnerType;
|
|
160
|
+
} else {
|
|
161
|
+
// this._AccountReceivable.AccountNo = `${this.CustSystemCode}-AR-123456789`;
|
|
162
|
+
// this._AccountReceivable.ParentAccountNo = `${this.CustSystemCode}-AR`;
|
|
163
|
+
this._AccountReceivable.AccountNo = this.ARAccountNo; //SystemInfo.SYSTEM_CODE + '-AR-' + '8 digit running no'
|
|
164
|
+
this._AccountReceivable.ParentAccountNo =
|
|
165
|
+
this.ParentARAccountNo; //SystemInfo.SYSTEM_CODE + '-AR'
|
|
166
|
+
this._AccountReceivable.AccountType = 'Account Receivable';
|
|
167
|
+
this._AccountReceivable.OwnerId = this.CustomerId;
|
|
168
|
+
this._AccountReceivable.OwnerType = type(this);
|
|
169
|
+
}
|
|
170
|
+
resolve(this._AccountReceivable);
|
|
171
|
+
})
|
|
172
|
+
.catch((err) => {
|
|
173
|
+
reject(err);
|
|
174
|
+
})
|
|
175
|
+
);
|
|
161
176
|
}
|
|
162
177
|
});
|
|
163
178
|
}
|
|
164
179
|
|
|
165
180
|
get AccountPayable(): Promise<Account> {
|
|
166
181
|
return new Promise((resolve, reject) => {
|
|
167
|
-
let transaction;
|
|
182
|
+
let transaction = this._DbTransaction;
|
|
168
183
|
if (this._AccountPayable) {
|
|
169
184
|
resolve(this._AccountPayable);
|
|
170
185
|
} else {
|
|
171
|
-
FinanceDb.getConnection()
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
// FinanceDb.getConnection()
|
|
187
|
+
// .transaction()
|
|
188
|
+
// transaction
|
|
189
|
+
// .then((t) => {
|
|
190
|
+
// transaction = t;
|
|
191
|
+
return (
|
|
192
|
+
FinanceCustomerBase._AccountRepository
|
|
193
|
+
.findOne({
|
|
176
194
|
where: {
|
|
177
195
|
AccountType: 'Account Payable',
|
|
178
196
|
OwnerId: this.CustomerId,
|
|
179
197
|
OwnerType: type(this),
|
|
180
198
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
199
|
+
transaction,
|
|
200
|
+
})
|
|
201
|
+
// })
|
|
202
|
+
.then((accountData) => {
|
|
203
|
+
this._AccountPayable = new Account(transaction);
|
|
204
|
+
if (accountData) {
|
|
205
|
+
this._AccountPayable.AccountNo = accountData.AccountNo;
|
|
206
|
+
this._AccountPayable.ParentAccountNo =
|
|
207
|
+
accountData.ParentAccountNo;
|
|
208
|
+
this._AccountPayable.AccountType = accountData.AccountType;
|
|
209
|
+
this._AccountPayable.OwnerId = accountData.OwnerId;
|
|
210
|
+
this._AccountPayable.OwnerType = accountData.OwnerType;
|
|
211
|
+
} else {
|
|
212
|
+
// this._AccountPayable.AccountNo = `${this.CustSystemCode}-AP-123456789`;
|
|
213
|
+
// this._AccountPayable.ParentAccountNo = `${this.CustSystemCode}-AP`;
|
|
214
|
+
this._AccountPayable.AccountNo = this.APAccountNo; //SystemInfo.SYSTEM_CODE + '-AP-' + '8 digit running no'
|
|
215
|
+
this._AccountPayable.ParentAccountNo = this.ParentAPAccountNo; //SystemInfo.SYSTEM_CODE + '-AP'
|
|
216
|
+
this._AccountPayable.AccountType = 'Account Payable';
|
|
217
|
+
this._AccountPayable.OwnerId = this.CustomerId;
|
|
218
|
+
this._AccountPayable.OwnerType = type(this);
|
|
219
|
+
}
|
|
220
|
+
resolve(this._AccountPayable);
|
|
221
|
+
})
|
|
222
|
+
.catch((err) => {
|
|
223
|
+
reject(err);
|
|
224
|
+
})
|
|
225
|
+
);
|
|
206
226
|
}
|
|
207
227
|
});
|
|
208
228
|
}
|
|
@@ -429,10 +429,20 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
429
429
|
};
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
+
console.log(
|
|
433
|
+
'Finance Company Create Account: Before accSystemAccountId Create',
|
|
434
|
+
);
|
|
435
|
+
|
|
432
436
|
const accSystemAccountId = await this.AccountingSystem.createAccount(
|
|
433
437
|
createAccountPayload,
|
|
434
438
|
);
|
|
439
|
+
|
|
440
|
+
console.log(
|
|
441
|
+
'Finance Company Create Account: After accSystemAccountId Create',
|
|
442
|
+
);
|
|
443
|
+
|
|
435
444
|
account.PostedToAccSystemYN = 'Y';
|
|
445
|
+
console.log('Finance Company Create Account: Before new Account Create');
|
|
436
446
|
const newAccount = await account.save(
|
|
437
447
|
this.CompanyId,
|
|
438
448
|
accSystemAccountId,
|
|
@@ -440,6 +450,8 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
440
450
|
dbTransaction,
|
|
441
451
|
);
|
|
442
452
|
|
|
453
|
+
console.log('Finance Company Create Account: After new Account Create');
|
|
454
|
+
|
|
443
455
|
const payload = {
|
|
444
456
|
Action: 'Create',
|
|
445
457
|
Activity: 'Account Created',
|