@tomei/finance 0.3.3 → 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.3",
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,