@tomei/finance 0.3.76 → 0.3.77

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/finance",
3
- "version": "0.3.76",
3
+ "version": "0.3.77",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -61,6 +61,7 @@ export default class FinanceCompany extends ObjectBase {
61
61
 
62
62
  private _AccountingSystem: IAccountSystem;
63
63
 
64
+ private _DbTransaction: any;
64
65
  private _PaymentMethods = [];
65
66
 
66
67
  get CompSystemCode(): string {
@@ -1326,11 +1327,54 @@ export default class FinanceCompany extends ObjectBase {
1326
1327
  }
1327
1328
  }
1328
1329
 
1329
- get PaymentMethods() {
1330
- if (this._PaymentMethods === null || this._PaymentMethods.length === 0) {
1331
- this.LoadPaymentMethods();
1332
- }
1333
- return this._PaymentMethods;
1330
+ get PaymentMethods(): Promise<PaymentMethod[]> {
1331
+ return new Promise((resolve, reject) => {
1332
+ if (this.CompanyId !== 'New') {
1333
+ FinanceCompany._PaymentMethodRepository
1334
+ .findAll({
1335
+ where: {
1336
+ CompanyId: this.CompanyId,
1337
+ },
1338
+ transaction: this._DbTransaction,
1339
+ })
1340
+ .then((paymentMethod) => {
1341
+ const paymentMethodObjects = paymentMethod.map(
1342
+ (paymentMethodData) => {
1343
+ return new Promise((resolve, reject) => {
1344
+ FinanceCompany._PaymentMethodTypeRepository
1345
+ .findAll({
1346
+ where: {
1347
+ MethodId: paymentMethodData.MethodId,
1348
+ },
1349
+ transaction: this._DbTransaction,
1350
+ raw: true,
1351
+ })
1352
+ .then((paymentMethodTypes) => {
1353
+ const paymentMethodObjects = {
1354
+ ...paymentMethodData.get({ plain: true }),
1355
+ Types: paymentMethodTypes,
1356
+ };
1357
+ resolve(paymentMethodObjects);
1358
+ })
1359
+ .catch((err) => {
1360
+ reject(err);
1361
+ });
1362
+ }).then((paymentMethods) => paymentMethods);
1363
+ },
1364
+ );
1365
+ return Promise.all(paymentMethodObjects);
1366
+ })
1367
+ .then((paymentMethodObjects) => {
1368
+ this._PaymentMethods = paymentMethodObjects;
1369
+ resolve(this._PaymentMethods);
1370
+ })
1371
+ .catch((err) => {
1372
+ reject(err);
1373
+ });
1374
+ } else {
1375
+ resolve(this._PaymentMethods);
1376
+ }
1377
+ });
1334
1378
  }
1335
1379
 
1336
1380
  /**