@tomei/finance 0.2.12 → 0.2.13

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.
Files changed (47) hide show
  1. package/dist/customer/customer.d.ts +18 -13
  2. package/dist/customer/customer.js +18 -13
  3. package/dist/customer/customer.js.map +1 -1
  4. package/dist/customer/entities/customer.entity.d.ts +9 -4
  5. package/dist/customer/entities/customer.entity.js +46 -9
  6. package/dist/customer/entities/customer.entity.js.map +1 -1
  7. package/dist/customer/index.d.ts +2 -2
  8. package/dist/customer/index.js +3 -3
  9. package/dist/customer/index.js.map +1 -1
  10. package/dist/customer/interfaces/finance-customer-attr.interface.d.ts +7 -1
  11. package/dist/document/document.d.ts +1 -1
  12. package/dist/finance-company/entities/finance-company.entity.d.ts +13 -0
  13. package/dist/finance-company/entities/finance-company.entity.js +113 -0
  14. package/dist/finance-company/entities/finance-company.entity.js.map +1 -0
  15. package/dist/finance-company/finance-company.repository.d.ts +10 -0
  16. package/dist/finance-company/finance-company.repository.js +38 -0
  17. package/dist/finance-company/finance-company.repository.js.map +1 -0
  18. package/dist/finance-company/index.d.ts +5 -1
  19. package/dist/finance-company/index.js +5 -1
  20. package/dist/finance-company/index.js.map +1 -1
  21. package/dist/finance-company/interfaces/finance-company-attr.interface.d.ts +10 -0
  22. package/dist/finance-company/interfaces/finance-company-attr.interface.js +3 -0
  23. package/dist/finance-company/interfaces/finance-company-attr.interface.js.map +1 -0
  24. package/dist/finance-company/interfaces/finance-company.repository.interface.d.ts +3 -0
  25. package/dist/finance-company/interfaces/finance-company.repository.interface.js +3 -0
  26. package/dist/finance-company/interfaces/finance-company.repository.interface.js.map +1 -0
  27. package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +2 -2
  28. package/dist/journal-entry/journal-entry.js +2 -2
  29. package/dist/journal-entry/journal-entry.js.map +1 -1
  30. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +1 -1
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/migrations/finance-company-migration.js +45 -0
  33. package/migrations/finance-customer-migration.js +23 -5
  34. package/package.json +1 -1
  35. package/src/customer/customer.ts +38 -26
  36. package/src/customer/entities/customer.entity.ts +50 -10
  37. package/src/customer/index.ts +2 -2
  38. package/src/customer/interfaces/finance-customer-attr.interface.ts +7 -1
  39. package/src/document/document.ts +1 -1
  40. package/src/finance-company/entities/finance-company.entity.ts +88 -0
  41. package/src/finance-company/finance-company.repository.ts +30 -0
  42. package/src/finance-company/index.ts +11 -1
  43. package/src/finance-company/interfaces/finance-company-attr.interface.ts +10 -0
  44. package/src/finance-company/interfaces/finance-company.repository.interface.ts +4 -0
  45. package/src/journal-entry/interfaces/journal-entry-attr.interface.ts +2 -2
  46. package/src/journal-entry/journal-entry.ts +2 -2
  47. package/src/ledger-transaction/interfaces/ledger-transaction-attr.interface.ts +1 -2
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ async up(queryInterface, Sequelize) {
5
+ await queryInterface.createTable('finance_Company', {
6
+ CompanyId: {
7
+ type: Sequelize.STRING(30),
8
+ primaryKey: true,
9
+ allowNull: false,
10
+ },
11
+ CompSystemCode: {
12
+ type: Sequelize.STRING(10),
13
+ allowNull: false,
14
+ },
15
+ CompSystemRefId: {
16
+ type: Sequelize.STRING(30),
17
+ allowNull: false,
18
+ },
19
+ AccSystemCode: {
20
+ type: Sequelize.STRING(10),
21
+ allowNull: false,
22
+ },
23
+ AccSystemRefId: {
24
+ type: Sequelize.STRING(30),
25
+ allowNull: false,
26
+ },
27
+ PostedToAccSystemYN: {
28
+ type: Sequelize.CHAR(1),
29
+ allowNull: false,
30
+ },
31
+ PostedById: {
32
+ type: Sequelize.STRING(30),
33
+ allowNull: true,
34
+ },
35
+ PostedDateTime: {
36
+ type: Sequelize.DATE,
37
+ allowNull: true,
38
+ },
39
+ });
40
+ },
41
+
42
+ async down(queryInterface) {
43
+ await queryInterface.dropTable('finance_Company');
44
+ },
45
+ };
@@ -8,22 +8,40 @@ module.exports = {
8
8
  primaryKey: true,
9
9
  allowNull: false,
10
10
  },
11
- SystemCode: {
11
+ CompanyId: {
12
12
  type: Sequelize.STRING(30),
13
13
  allowNull: false,
14
+ references: {
15
+ model: 'finance_Company',
16
+ key: 'CompanyId',
17
+ },
18
+ onUpdate: 'CASCADE',
19
+ onDelete: 'CASCADE',
14
20
  },
15
- AccSystemCode: {
16
- type: Sequelize.STRING(30),
21
+ CustSystemCode: {
22
+ type: Sequelize.STRING(10),
17
23
  allowNull: false,
18
24
  },
19
- AccSystemCustomerId: {
25
+ CustSystemRefId: {
20
26
  type: Sequelize.STRING(30),
21
27
  allowNull: false,
22
28
  },
23
- CustomerRefId: {
29
+ AccSystemRefId: {
24
30
  type: Sequelize.STRING(30),
25
31
  allowNull: false,
26
32
  },
33
+ PostedToAccSystemYN: {
34
+ type: Sequelize.CHAR(1),
35
+ allowNull: false,
36
+ },
37
+ PostedById: {
38
+ type: Sequelize.STRING(30),
39
+ allowNull: true,
40
+ },
41
+ PostedDateTime: {
42
+ type: Sequelize.DATE,
43
+ allowNull: true,
44
+ },
27
45
  });
28
46
  },
29
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/finance",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,44 +1,58 @@
1
- import { IAddress, LoginUserBase, RecordNotFoundError } from '@tomei/general';
1
+ import {
2
+ IAddress,
3
+ IPerson,
4
+ LoginUserBase,
5
+ RecordNotFoundError,
6
+ } from '@tomei/general';
7
+ import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
2
8
  import { FinanceCustomerModel } from './entities/customer.entity';
3
9
  import { IFinanceCustomerRepository } from './interfaces/finance-customer.repository.interface';
10
+ export abstract class Customer extends AccountSystemEntity implements IPerson {
11
+ abstract FullName: string;
12
+ abstract IDNo: string;
13
+ abstract IDType: string;
14
+ abstract ContactNo: string;
15
+ abstract Email: string;
16
+ abstract DefaultAddress: IAddress;
4
17
 
5
- export abstract class Customer extends LoginUserBase {
6
- FullName: string;
7
- IDNo: string;
8
- IDType: string;
9
- ContactNo: string;
10
- Email: string;
11
- DefaultAddress: IAddress;
18
+ // note: getDetails from spec is void type. Meaning that this probably needed a fix soon
19
+ async getDetails(): Promise<{
20
+ FullName: string;
21
+ IDNo: string;
22
+ IDType: string;
23
+ Email: string;
24
+ ContactNo: string;
25
+ }> {
26
+ return {
27
+ FullName: this.FullName,
28
+ IDNo: this.IDNo,
29
+ IDType: this.IDType,
30
+ Email: this.Email,
31
+ ContactNo: this.ContactNo,
32
+ };
33
+ }
12
34
 
13
35
  financeCustomerRepository: IFinanceCustomerRepository;
14
36
 
15
37
  CustomerId: string;
16
-
17
- SystemCode: string;
18
- AccSystemCode: string;
19
- AccSystemCustomerId: string; // customer id return from accounting system
20
38
  CustSystemCode: string;
21
39
  CustSystemRefId: string;
22
40
 
23
41
  constructor(
24
- systemCode: string,
25
- accSystemCode: string,
42
+ sFinanceCompanyId: string,
26
43
  custSystemCode: string,
27
44
  custSystemRefId: string,
28
45
  ) {
29
46
  super();
30
47
  const financeCustomerData = this.financeCustomerRepository.findOne({
31
48
  where: {
32
- SystemCode: systemCode,
33
- AccSystemCode: accSystemCode,
34
- AccSystemCustomerId: custSystemCode,
35
- CustomerRefId: custSystemRefId,
49
+ CompanyId: sFinanceCompanyId,
50
+ CustSystemCode: custSystemCode,
51
+ CustSystemRefId: custSystemRefId,
36
52
  },
37
53
  });
38
54
  if (financeCustomerData) {
39
- this.CustomerId = financeCustomerData.CustomerId;
40
- this.AccSystemCode = accSystemCode;
41
- this.AccSystemCustomerId = financeCustomerData.AccSystemCustomerId;
55
+ this.CompanyId = sFinanceCompanyId;
42
56
  this.CustSystemCode = custSystemCode;
43
57
  this.CustSystemRefId = custSystemRefId;
44
58
  } else {
@@ -50,7 +64,7 @@ export abstract class Customer extends LoginUserBase {
50
64
  /*
51
65
  * Get the billing address for a person.
52
66
  **/
53
- abstract getBilligAddress(): Promise<IAddress>;
67
+ abstract getBillingAddress(): Promise<IAddress>;
54
68
 
55
69
  init(person: LoginUserBase) {
56
70
  this.FullName = person.FullName;
@@ -68,10 +82,8 @@ export abstract class Customer extends LoginUserBase {
68
82
  const data = await this.financeCustomerRepository.create(
69
83
  {
70
84
  CustomerId: customerId,
71
- SystemCode: this.SystemCode,
72
- AccSystemCode: this.SystemCode,
73
- AccSystemCustomerId: this.AccSystemCustomerId,
74
- CustomerRefId: this.CustSystemRefId,
85
+ CustSystemCode: this.CustSystemCode,
86
+ CustSystemRefId: this.CustSystemRefId,
75
87
  },
76
88
  dbTransaction,
77
89
  );
@@ -1,5 +1,13 @@
1
1
  import { ApiProperty } from '@nestjs/swagger';
2
- import { Column, DataType, Model, Table } from 'sequelize-typescript';
2
+ import {
3
+ ForeignKey,
4
+ BelongsTo,
5
+ Column,
6
+ DataType,
7
+ Model,
8
+ Table,
9
+ } from 'sequelize-typescript';
10
+ import { FinanceCompanyModel } from '../../finance-company/entities/finance-company.entity';
3
11
 
4
12
  @Table({ tableName: 'finance_Customer', createdAt: false, updatedAt: false })
5
13
  export class FinanceCustomerModel extends Model {
@@ -11,43 +19,75 @@ export class FinanceCustomerModel extends Model {
11
19
  })
12
20
  CustomerId: string;
13
21
 
22
+ @ApiProperty({ type: String, description: 'CompanyId' })
23
+ @ForeignKey(() => FinanceCompanyModel)
24
+ @Column({
25
+ allowNull: false,
26
+ type: DataType.STRING(30),
27
+ })
28
+ CompanyId: string;
29
+
14
30
  @ApiProperty({
15
31
  type: String,
16
- description: 'System Code eg. "EZC", "CRM"',
32
+ description: 'Cust System Code eg. "EZC", "CRM"',
17
33
  })
18
34
  @Column({
19
35
  allowNull: false,
20
- type: DataType.STRING(30),
36
+ type: DataType.STRING(10),
21
37
  })
22
- SystemCode: string;
38
+ CustSystemCode: string;
23
39
 
24
40
  @ApiProperty({
25
41
  type: String,
26
- description: 'Account System Code eg. "EZC", "CRM"',
42
+ description: 'CustSystemRefId',
27
43
  })
28
44
  @Column({
29
45
  allowNull: false,
30
46
  type: DataType.STRING(30),
31
47
  })
32
- AccSystemCode: string;
48
+ CustSystemRefId: string;
33
49
 
34
50
  @ApiProperty({
35
51
  type: String,
36
- description: 'Account Customer Id in Api',
52
+ description: 'Account Customer Id in API',
37
53
  })
38
54
  @Column({
39
55
  allowNull: false,
40
56
  type: DataType.STRING(30),
41
57
  })
42
- AccSystemCustomerId: string;
58
+ AccSystemRefId: string;
43
59
 
44
60
  @ApiProperty({
45
61
  type: String,
46
- description: 'Custoemr Ref Id',
62
+ description: 'PostedToAccSystemYN',
63
+ example: 'Y',
47
64
  })
48
65
  @Column({
49
66
  allowNull: false,
67
+ type: DataType.CHAR(1),
68
+ })
69
+ PostedToAccSystemYN: string;
70
+
71
+ @ApiProperty({
72
+ example: '138140891dd211b288d34bc7b4312a49',
73
+ description: 'PostedById',
74
+ })
75
+ @Column({
76
+ allowNull: true,
50
77
  type: DataType.STRING(30),
51
78
  })
52
- CustomerRefId: string;
79
+ PostedById: string;
80
+
81
+ @ApiProperty({
82
+ example: new Date(),
83
+ description: 'PostedToAccSystem Date',
84
+ })
85
+ @Column({
86
+ allowNull: true,
87
+ type: DataType.DATE,
88
+ })
89
+ PostedDateTime: Date;
90
+
91
+ @BelongsTo(() => FinanceCompanyModel)
92
+ FinanceCompany: FinanceCompanyModel;
53
93
  }
@@ -1,15 +1,15 @@
1
+ import { Customer } from './customer';
1
2
  import { IFinanceCustomerRepository } from './interfaces/finance-customer.repository.interface';
2
3
  import { IFinanceCustomerAttr } from './interfaces/finance-customer-attr.interface';
3
4
  import { FinanceCustomerModel } from './entities/customer.entity';
4
5
  import { ICustomerRepository } from './interfaces/customer.repository.interface';
5
6
  import { FinanceCustomerRepository } from './finance-customer.repository';
6
- import { Customer } from './customer';
7
7
 
8
8
  export {
9
+ Customer,
9
10
  IFinanceCustomerRepository,
10
11
  IFinanceCustomerAttr,
11
12
  FinanceCustomerModel,
12
13
  ICustomerRepository,
13
14
  FinanceCustomerRepository,
14
- Customer,
15
15
  };
@@ -1,4 +1,10 @@
1
1
  export interface IFinanceCustomerAttr {
2
2
  CustomerId: string;
3
- AccSystemId: string;
3
+ CompanyId: string;
4
+ CustSystemCode: string;
5
+ CustSystemRefId: string;
6
+ AccSystemRefId: string;
7
+ PostedToAccSystemYN: string;
8
+ PostedById: string;
9
+ PostedDateTime?: Date;
4
10
  }
@@ -8,7 +8,7 @@ import {
8
8
  CommonService as MediaCommonService,
9
9
  MediaType,
10
10
  } from '@tomei/media';
11
- import { DocumentStatus, DocType } from 'src/enum';
11
+ import { DocumentStatus, DocType } from '../enum';
12
12
  import { DocumentRepository } from './document.repository';
13
13
  import { IDocumentAttr } from './interfaces/document-attr.interface';
14
14
  import { DocumentItemRepository } from './document-item.repository';
@@ -0,0 +1,88 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import { Column, DataType, Model, Table, HasMany } from 'sequelize-typescript';
3
+ import { FinanceCustomerModel } from '../../customer/entities/customer.entity';
4
+
5
+ @Table({ tableName: 'finance_Company', createdAt: false, updatedAt: false })
6
+ export class FinanceCompanyModel extends Model {
7
+ @ApiProperty({ type: String, description: 'CompanyId' })
8
+ @Column({
9
+ primaryKey: true,
10
+ allowNull: false,
11
+ type: DataType.STRING(30),
12
+ })
13
+ CompanyId: string;
14
+
15
+ @ApiProperty({
16
+ type: String,
17
+ description: 'CompanySystemCode',
18
+ })
19
+ @Column({
20
+ allowNull: false,
21
+ type: DataType.STRING(10),
22
+ })
23
+ CompSystemCode: string;
24
+
25
+ @ApiProperty({
26
+ type: String,
27
+ description: 'CompanySystemRefId',
28
+ })
29
+ @Column({
30
+ allowNull: false,
31
+ type: DataType.STRING(30),
32
+ })
33
+ CompSystemRefId: string;
34
+
35
+ @ApiProperty({
36
+ type: String,
37
+ description: 'Account System Code eg. "EZC", "CRM"',
38
+ })
39
+ @Column({
40
+ allowNull: false,
41
+ type: DataType.STRING(10),
42
+ })
43
+ AccSystemCode: string;
44
+
45
+ @ApiProperty({
46
+ type: String,
47
+ description: 'Account Company Id in API',
48
+ })
49
+ @Column({
50
+ allowNull: false,
51
+ type: DataType.STRING(30),
52
+ })
53
+ AccSystemRefId: string;
54
+
55
+ @ApiProperty({
56
+ type: String,
57
+ description: 'PostedToAccSystemYN',
58
+ example: 'Y',
59
+ })
60
+ @Column({
61
+ allowNull: false,
62
+ type: DataType.CHAR(1),
63
+ })
64
+ PostedToAccSystemYN: string;
65
+
66
+ @ApiProperty({
67
+ example: '138140891dd211b288d34bc7b4312a49',
68
+ description: 'PostedById',
69
+ })
70
+ @Column({
71
+ allowNull: true,
72
+ type: DataType.STRING(30),
73
+ })
74
+ PostedById: string;
75
+
76
+ @ApiProperty({
77
+ example: new Date(),
78
+ description: 'PostedToAccSystem Date',
79
+ })
80
+ @Column({
81
+ allowNull: true,
82
+ type: DataType.DATE,
83
+ })
84
+ PostedDateTime: Date;
85
+
86
+ @HasMany(() => FinanceCustomerModel)
87
+ FinanceCustomers: FinanceCustomerModel[];
88
+ }
@@ -0,0 +1,30 @@
1
+ import { Injectable } from '@nestjs/common/decorators';
2
+ import { InjectModel } from '@nestjs/sequelize';
3
+ import { BaseRepository } from '@tomei/general';
4
+ import { FinanceCompanyModel } from './entities/finance-company.entity';
5
+ import { IFinanceCompanyAttr } from './interfaces/finance-company-attr.interface';
6
+ import { IFinanceCompanyRepository } from './interfaces/finance-company.repository.interface';
7
+
8
+ @Injectable()
9
+ export class FinanceCompanyRepository
10
+ extends BaseRepository<FinanceCompanyModel>
11
+ implements IFinanceCompanyRepository
12
+ {
13
+ constructor(
14
+ @InjectModel(FinanceCompanyModel)
15
+ private readonly financeCompanyModel: typeof FinanceCompanyModel,
16
+ ) {
17
+ super(financeCompanyModel);
18
+ }
19
+
20
+ create(
21
+ data: IFinanceCompanyAttr | any,
22
+ options?: any,
23
+ ): Promise<FinanceCompanyModel> | any {
24
+ return this.financeCompanyModel.create(data, options);
25
+ }
26
+
27
+ findOne(options: any): Promise<FinanceCompanyModel> {
28
+ return this.financeCompanyModel.findOne(options);
29
+ }
30
+ }
@@ -1,3 +1,13 @@
1
1
  import { FinanceCompany } from './finance-company';
2
+ import { FinanceCompanyModel } from './entities/finance-company.entity';
3
+ import { IFinanceCompanyAttr } from './interfaces/finance-company-attr.interface';
4
+ import { IFinanceCompanyRepository } from './interfaces/finance-company.repository.interface';
5
+ import { FinanceCompanyRepository } from './finance-company.repository';
2
6
 
3
- export { FinanceCompany };
7
+ export {
8
+ FinanceCompany,
9
+ FinanceCompanyModel,
10
+ IFinanceCompanyAttr,
11
+ IFinanceCompanyRepository,
12
+ FinanceCompanyRepository,
13
+ };
@@ -0,0 +1,10 @@
1
+ export interface IFinanceCompanyAttr {
2
+ CompanyId: string;
3
+ CompSystemCode: string;
4
+ CompSystemRefId: string;
5
+ AccSystemCode: string;
6
+ AccSystemRefId: string;
7
+ PostedToAccSystemYN: string;
8
+ PostedById: string;
9
+ PostedDateTime?: Date;
10
+ }
@@ -0,0 +1,4 @@
1
+ import { IBaseRepository } from '@tomei/general';
2
+ import { FinanceCompanyModel } from '../entities/finance-company.entity';
3
+
4
+ export type IFinanceCompanyRepository = IBaseRepository<FinanceCompanyModel>;
@@ -2,8 +2,8 @@ export interface IJournalEntryAttr {
2
2
  JournalEntryId: string;
3
3
  Date: Date;
4
4
  Name: string;
5
- Description: string;
5
+ Description?: string;
6
6
  PostedById: string;
7
7
  PostedToAccSystemYN: string;
8
- DatePosted?: string;
8
+ PostedDateTime?: Date;
9
9
  }
@@ -88,7 +88,7 @@ export class JournalEntry extends AccountSystemEntity {
88
88
  this.Description = params.Description;
89
89
  this.PostedById = params.PostedById;
90
90
  this.PostedToAccSystemYN = params.PostedToAccSystemYN;
91
- this.DatePosted = params.DatePosted;
91
+ this.PostedDateTime = params.PostedDateTime;
92
92
  }
93
93
 
94
94
  getData() {
@@ -133,7 +133,7 @@ export class JournalEntry extends AccountSystemEntity {
133
133
  Description: '',
134
134
  PostedById: '',
135
135
  PostedToAccSystemYN: 'N',
136
- DatePosted: null,
136
+ PostedDateTime: null,
137
137
  });
138
138
 
139
139
  const ledgerTransaction = new LedgerTransaction(
@@ -1,5 +1,4 @@
1
- import { TransactionTypeOptions } from 'src/enum/transaction-type.enum';
2
-
1
+ import { TransactionTypeOptions } from '../../enum';
3
2
  export interface ILedgerTransactionAttr {
4
3
  TransactionId: string;
5
4
  TransactionType: string;