@tomei/finance 0.3.2 → 0.3.4

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.2",
3
+ "version": "0.3.4",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -6,8 +6,8 @@ import {
6
6
  RecordNotFoundError,
7
7
  } from '@tomei/general';
8
8
  import FinanceCustomerModel from '../models/customer.entity';
9
- import { IFinanceCustomerRepository } from './interfaces/finance-customer.repository.interface';
10
9
  import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
10
+ import { FinanceCustomerRepository } from './finance-customer.repository';
11
11
 
12
12
  // const AccountSystemEntity = import('../account-system-entity').then(({AccountSystemEntity}) => AccountSystemEntity);
13
13
  export default abstract class FinanceCustomerBase
@@ -38,7 +38,7 @@ export default abstract class FinanceCustomerBase
38
38
  };
39
39
  }
40
40
 
41
- financeCustomerRepository: IFinanceCustomerRepository;
41
+ protected static _FinanceCustomerRepository = new FinanceCustomerRepository();
42
42
 
43
43
  CustomerId: string;
44
44
  CustSystemCode: string;
@@ -51,13 +51,14 @@ export default abstract class FinanceCustomerBase
51
51
  sFinanceCompanyId: string,
52
52
  ) {
53
53
  super();
54
- const financeCustomerData = this.financeCustomerRepository.findOne({
55
- where: {
56
- CompanyId: sFinanceCompanyId,
57
- CustSystemCode: custSystemCode,
58
- CustSystemRefId: custSystemRefId,
59
- },
60
- });
54
+ const financeCustomerData =
55
+ FinanceCustomerBase._FinanceCustomerRepository.findOne({
56
+ where: {
57
+ CompanyId: sFinanceCompanyId,
58
+ CustSystemCode: custSystemCode,
59
+ CustSystemRefId: custSystemRefId,
60
+ },
61
+ });
61
62
  if (financeCustomerData) {
62
63
  this.CompanyId = sFinanceCompanyId;
63
64
  this.CustSystemCode = custSystemCode;
@@ -86,7 +87,7 @@ export default abstract class FinanceCustomerBase
86
87
  customerId: string,
87
88
  dbTransaction?: any,
88
89
  ): Promise<FinanceCustomerModel> {
89
- const data = await this.financeCustomerRepository.create(
90
+ const data = await FinanceCustomerBase._FinanceCustomerRepository.create(
90
91
  {
91
92
  CustomerId: customerId,
92
93
  CustSystemCode: this.CustSystemCode,
@@ -1,30 +1,13 @@
1
1
  import { Injectable } from '@nestjs/common/decorators';
2
- import { InjectModel } from '@nestjs/sequelize';
3
- import { RepositoryBase } from '@tomei/general';
2
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
4
3
  import FinanceCustomerModel from '../models/customer.entity';
5
- import { IFinanceCustomerAttr } from './interfaces/finance-customer-attr.interface';
6
- import { IFinanceCustomerRepository } from './interfaces/finance-customer.repository.interface';
7
4
 
8
5
  @Injectable()
9
6
  export class FinanceCustomerRepository
10
7
  extends RepositoryBase<FinanceCustomerModel>
11
- implements IFinanceCustomerRepository
8
+ implements IRepositoryBase<FinanceCustomerModel>
12
9
  {
13
- constructor(
14
- @InjectModel(FinanceCustomerModel)
15
- private readonly financeCustomerModel: typeof FinanceCustomerModel,
16
- ) {
17
- super(financeCustomerModel);
18
- }
19
-
20
- create(
21
- data: IFinanceCustomerAttr | any,
22
- options?: any,
23
- ): Promise<FinanceCustomerModel> | any {
24
- return this.financeCustomerModel.create(data, options);
25
- }
26
-
27
- findOne(options: any): Promise<FinanceCustomerModel> {
28
- return this.financeCustomerModel.findOne(options);
10
+ constructor() {
11
+ super(FinanceCustomerModel);
29
12
  }
30
13
  }
@@ -21,8 +21,7 @@ import { PaymentItemRepository } from '../payment-item/payment-item.repository';
21
21
  import Payment from '../payment/payment';
22
22
  import { DocumentRepository } from '../document/document.repository';
23
23
  import { DocumentItemRepository } from '../document/document-item.repository';
24
-
25
- const { getConfig } = require('../config');
24
+ import { getConfig } from '../config';
26
25
  const config = getConfig();
27
26
 
28
27
  export default class FinanceCompany extends ObjectBase {
@@ -86,7 +85,7 @@ export default class FinanceCompany extends ObjectBase {
86
85
  return 'finance_Company';
87
86
  }
88
87
 
89
- private constructor(
88
+ constructor(
90
89
  compSystemCode: string,
91
90
  compSystemRefId: string,
92
91
  accSystemCode: string,
@@ -11,9 +11,9 @@ import {
11
11
  HasMany,
12
12
  } from 'sequelize-typescript';
13
13
  import LedgerTransactionModel from './ledger-transaction.entity';
14
- import PaymentModel from './payment.entity';
15
14
  import DocumentItemModel from './document-item.entity';
16
15
  import FinanceCompanyModel from './finance-company.entity';
16
+ import PaymentMethodTypeModel from './payment-method-type.entity';
17
17
 
18
18
  @Table({ tableName: 'finance_Account', createdAt: false, updatedAt: false })
19
19
  export default class AccountModel extends Model {
@@ -192,8 +192,8 @@ export default class AccountModel extends Model {
192
192
  })
193
193
  PostedDateTime: Date;
194
194
 
195
- @HasMany(() => PaymentModel)
196
- Payments: PaymentModel[];
195
+ @HasMany(() => PaymentMethodTypeModel)
196
+ PaymentMethodTypes: PaymentMethodTypeModel[];
197
197
 
198
198
  @HasMany(() => DocumentItemModel)
199
199
  DocumentItems: DocumentItemModel[];
@@ -5,7 +5,7 @@ import { AccountSystemEntity } from '../account-system-entity/account-system-ent
5
5
  import { PaymentStatus } from '../enum/payment-status.enum';
6
6
  import { PaymentRepository } from './payment.repository';
7
7
  import { PaymentItemRepository } from '../payment-item/payment-item.repository';
8
- import PaymentItemModel from '../models/payment-item.entity';
8
+ // import PaymentItemModel from '../models/payment-item.entity';
9
9
  import PaymentItem from '../payment-item/payment-item';
10
10
 
11
11
  export default class Payment extends AccountSystemEntity {