@tomei/finance 0.3.33 → 0.3.35

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 (66) hide show
  1. package/dist/document/document.d.ts +1 -1
  2. package/dist/document/document.js +9 -6
  3. package/dist/document/document.js.map +1 -1
  4. package/dist/finance-company/finance-company.d.ts +1 -0
  5. package/dist/finance-company/finance-company.js +176 -102
  6. package/dist/finance-company/finance-company.js.map +1 -1
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.js +3 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +2 -1
  11. package/dist/ledger-transaction/ledger-transaction.d.ts +4 -2
  12. package/dist/ledger-transaction/ledger-transaction.js +6 -5
  13. package/dist/ledger-transaction/ledger-transaction.js.map +1 -1
  14. package/dist/models/ledger-transaction.entity.d.ts +6 -1
  15. package/dist/models/ledger-transaction.entity.js +31 -14
  16. package/dist/models/ledger-transaction.entity.js.map +1 -1
  17. package/dist/models/payment-item.entity.d.ts +2 -1
  18. package/dist/models/payment-item.entity.js +9 -2
  19. package/dist/models/payment-item.entity.js.map +1 -1
  20. package/dist/models/payment-paid-with.entity.d.ts +18 -0
  21. package/dist/models/payment-paid-with.entity.js +117 -0
  22. package/dist/models/payment-paid-with.entity.js.map +1 -0
  23. package/dist/models/payment.entity.d.ts +1 -6
  24. package/dist/models/payment.entity.js +2 -29
  25. package/dist/models/payment.entity.js.map +1 -1
  26. package/dist/payment/interfaces/payment-attr.interface.d.ts +1 -6
  27. package/dist/payment/interfaces/payment-attr.interface.js.map +1 -1
  28. package/dist/payment/payment.d.ts +10 -17
  29. package/dist/payment/payment.js +43 -30
  30. package/dist/payment/payment.js.map +1 -1
  31. package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +3 -1
  32. package/dist/payment-item/interfaces/payment-item-attr.interface.js.map +1 -1
  33. package/dist/payment-item/payment-item.d.ts +3 -0
  34. package/dist/payment-item/payment-item.js +6 -0
  35. package/dist/payment-item/payment-item.js.map +1 -1
  36. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.d.ts +13 -0
  37. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js +7 -0
  38. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js.map +1 -0
  39. package/dist/payment-paid-with/payment-paid-with.d.ts +24 -0
  40. package/dist/payment-paid-with/payment-paid-with.js +44 -0
  41. package/dist/payment-paid-with/payment-paid-with.js.map +1 -0
  42. package/dist/payment-paid-with/payment-paid-with.repository.d.ts +5 -0
  43. package/dist/payment-paid-with/payment-paid-with.repository.js +12 -0
  44. package/dist/payment-paid-with/payment-paid-with.repository.js.map +1 -0
  45. package/dist/tsconfig.tsbuildinfo +1 -1
  46. package/migrations/finance-ledger-transaction-migration.js +23 -7
  47. package/migrations/finance-payment-item-migration.js +10 -2
  48. package/migrations/finance-payment-migration.js +2 -34
  49. package/migrations/finance-paymentpaidwith-migration.js +66 -0
  50. package/package.json +1 -1
  51. package/src/document/document.ts +20 -10
  52. package/src/finance-company/finance-company.ts +233 -175
  53. package/src/index.ts +2 -0
  54. package/src/ledger-transaction/interfaces/ledger-transaction-attr.interface.ts +2 -1
  55. package/src/ledger-transaction/ledger-transaction.ts +6 -4
  56. package/src/models/ledger-transaction.entity.ts +27 -13
  57. package/src/models/payment-item.entity.ts +8 -2
  58. package/src/models/payment-paid-with.entity.ts +97 -0
  59. package/src/models/payment.entity.ts +2 -28
  60. package/src/payment/interfaces/payment-attr.interface.ts +1 -6
  61. package/src/payment/payment.ts +55 -50
  62. package/src/payment-item/interfaces/payment-item-attr.interface.ts +3 -1
  63. package/src/payment-item/payment-item.ts +6 -3
  64. package/src/payment-paid-with/interfaces/payment-paid-with.interface.ts +14 -0
  65. package/src/payment-paid-with/payment-paid-with.repository.ts +11 -0
  66. package/src/payment-paid-with/payment-paid-with.ts +54 -0
@@ -8,7 +8,9 @@ import {
8
8
  BelongsTo,
9
9
  } from 'sequelize-typescript';
10
10
  import AccountModel from './account.entity';
11
+ import DocumentModel from './document.entity';
11
12
  import JournalEntryModel from './journal-entry.entity';
13
+ import PaymentModel from './payment.entity';
12
14
 
13
15
  @Table({
14
16
  tableName: 'finance_LedgerTransaction',
@@ -56,22 +58,12 @@ export default class LedgerTransactionModel extends Model {
56
58
  })
57
59
  Date: Date;
58
60
 
59
- @ApiProperty({
60
- type: String,
61
- description: 'Name of the ledger transaction',
62
- })
63
- @Column({
64
- allowNull: false,
65
- type: DataType.STRING(200),
66
- })
67
- Name: string;
68
-
69
61
  @ApiProperty({
70
62
  type: String,
71
63
  description: 'Description of the ledger transaction',
72
64
  })
73
65
  @Column({
74
- allowNull: true,
66
+ allowNull: false,
75
67
  type: DataType.STRING(1000),
76
68
  })
77
69
  Description: string;
@@ -111,7 +103,7 @@ export default class LedgerTransactionModel extends Model {
111
103
  description: 'RelatedObjectId',
112
104
  })
113
105
  @Column({
114
- allowNull: false,
106
+ allowNull: true,
115
107
  type: DataType.STRING(30),
116
108
  })
117
109
  RelatedObjectId: string;
@@ -121,14 +113,36 @@ export default class LedgerTransactionModel extends Model {
121
113
  description: 'RelatedObjectType',
122
114
  })
123
115
  @Column({
124
- allowNull: false,
116
+ allowNull: true,
125
117
  type: DataType.STRING(200),
126
118
  })
127
119
  RelatedObjectType: string;
128
120
 
121
+ @ApiProperty({ type: String, description: 'DocNo' })
122
+ @ForeignKey(() => DocumentModel)
123
+ @Column({
124
+ allowNull: true,
125
+ type: DataType.STRING(30),
126
+ })
127
+ RelatedDocNo: string;
128
+
129
+ @ApiProperty({ type: String, description: 'PaymentId' })
130
+ @ForeignKey(() => PaymentModel)
131
+ @Column({
132
+ allowNull: true,
133
+ type: DataType.STRING(30),
134
+ })
135
+ RelatedPaymentId: string;
136
+
129
137
  @BelongsTo(() => AccountModel)
130
138
  Account: AccountModel;
131
139
 
132
140
  @BelongsTo(() => JournalEntryModel)
133
141
  JournalEntry: JournalEntryModel;
142
+
143
+ @BelongsTo(() => DocumentModel)
144
+ Document: DocumentModel;
145
+
146
+ @BelongsTo(() => PaymentModel)
147
+ Payment: PaymentModel;
134
148
  }
@@ -43,10 +43,16 @@ export default class PaymentItemModel extends Model {
43
43
  Amount: number;
44
44
 
45
45
  @Column({
46
- type: DataType.STRING(30),
46
+ type: DataType.STRING(200),
47
47
  allowNull: true,
48
48
  })
49
- TaxCode: string;
49
+ Name: string;
50
+
51
+ @Column({
52
+ type: DataType.STRING(1000),
53
+ allowNull: false,
54
+ })
55
+ Description: string;
50
56
 
51
57
  @BelongsTo(() => PaymentModel)
52
58
  Payment: PaymentModel;
@@ -0,0 +1,97 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import {
3
+ BelongsTo,
4
+ Column,
5
+ DataType,
6
+ ForeignKey,
7
+ Model,
8
+ Table,
9
+ } from 'sequelize-typescript';
10
+ import { PaymentStatus } from '../enum';
11
+ import PaymentMethodTypeModel from './payment-method-type.entity';
12
+ import PaymentModel from './payment.entity';
13
+
14
+ @Table({
15
+ tableName: 'finance_PaymentPaidWith',
16
+ createdAt: false,
17
+ updatedAt: false,
18
+ })
19
+ export default class PaymentPaidWithModel extends Model {
20
+ @ApiProperty({
21
+ example: 'cl6nzvo780000qcw38ihpd8w6',
22
+ description: 'PaymentId',
23
+ })
24
+ @ForeignKey(() => PaymentModel)
25
+ @Column({
26
+ primaryKey: true,
27
+ allowNull: false,
28
+ type: DataType.STRING(30),
29
+ })
30
+ PaymentId: string;
31
+
32
+ @ApiProperty({
33
+ example: 'cl6nzvo780000qcw38ihpd8w6',
34
+ description: 'MethodTypeId',
35
+ })
36
+ @ForeignKey(() => PaymentMethodTypeModel)
37
+ @Column({
38
+ primaryKey: true,
39
+ allowNull: false,
40
+ type: DataType.STRING(30),
41
+ })
42
+ MethodTypeId: string;
43
+
44
+ @Column({
45
+ allowNull: false,
46
+ type: DataType.CHAR(3),
47
+ })
48
+ Currency: string;
49
+
50
+ @Column({
51
+ allowNull: false,
52
+ type: DataType.DECIMAL(10, 2),
53
+ })
54
+ Amount: number;
55
+
56
+ @Column({
57
+ allowNull: false,
58
+ type: DataType.STRING(30),
59
+ })
60
+ Status: PaymentStatus;
61
+
62
+ @Column({
63
+ allowNull: true,
64
+ type: DataType.STRING(100),
65
+ })
66
+ TransactionId: string;
67
+
68
+ @Column({
69
+ allowNull: true,
70
+ type: DataType.STRING(100),
71
+ })
72
+ TransactionApprovalCode: string;
73
+
74
+ @Column({
75
+ allowNull: true,
76
+ type: DataType.STRING(100),
77
+ })
78
+ TransactionApprovalName: string;
79
+
80
+ @Column({
81
+ allowNull: true,
82
+ type: DataType.STRING(100),
83
+ })
84
+ TransactionAccountNo: string;
85
+
86
+ @Column({
87
+ allowNull: true,
88
+ type: DataType.TEXT,
89
+ })
90
+ Remarks: string;
91
+
92
+ @BelongsTo(() => PaymentModel)
93
+ Payment: PaymentModel;
94
+
95
+ @BelongsTo(() => PaymentMethodTypeModel)
96
+ PaymentMethodType: PaymentMethodTypeModel;
97
+ }
@@ -1,18 +1,14 @@
1
1
  import { ApiProperty } from '@nestjs/swagger';
2
2
  import {
3
- BelongsTo,
4
3
  Column,
5
4
  DataType,
6
- ForeignKey,
7
5
  HasMany,
8
6
  Model,
9
7
  Table,
10
8
  UpdatedAt,
11
9
  } from 'sequelize-typescript';
12
10
  import { PaymentType, PaymentStatus } from '../enum';
13
- import FinanceCompanyModel from './finance-company.entity';
14
11
  import PaymentItemModel from './payment-item.entity';
15
- import PaymentMethodTypeModel from './payment-method-type.entity';
16
12
 
17
13
  @Table({
18
14
  tableName: 'finance_Payment',
@@ -39,27 +35,11 @@ export default class PaymentModel extends Model {
39
35
  })
40
36
  PaymentDate: Date;
41
37
 
42
- @ApiProperty({
43
- example: 'cl6nzvo780000qcw38ihpd8w6',
44
- description: 'CompanyId',
45
- })
46
- @ForeignKey(() => FinanceCompanyModel)
47
- @Column({
48
- allowNull: false,
49
- type: DataType.STRING(30),
50
- })
51
- CompanyId: string;
52
-
53
- @ApiProperty({
54
- example: 'cl6nzvo780000qcw38ihpd8w6',
55
- description: 'MethodTypeId',
56
- })
57
- @ForeignKey(() => PaymentMethodTypeModel)
58
38
  @Column({
59
39
  allowNull: false,
60
- type: DataType.STRING(30),
40
+ type: DataType.STRING(1000),
61
41
  })
62
- MethodTypeId: string;
42
+ Description: string;
63
43
 
64
44
  @Column({
65
45
  allowNull: false,
@@ -170,10 +150,4 @@ export default class PaymentModel extends Model {
170
150
 
171
151
  @HasMany(() => PaymentItemModel)
172
152
  PaymentItems: PaymentItemModel[];
173
-
174
- @BelongsTo(() => FinanceCompanyModel)
175
- FinanceCompany: FinanceCompanyModel;
176
-
177
- @BelongsTo(() => PaymentMethodTypeModel)
178
- PaymentMethodType: PaymentMethodTypeModel;
179
153
  }
@@ -4,15 +4,10 @@ export class IPaymentAttr {
4
4
  PaymentId: string;
5
5
  PaymentType: PaymentType;
6
6
  PaymentDate: Date;
7
- CompanyId: string;
8
- MethodTypeId: string;
7
+ Description: string;
9
8
  Currency: string;
10
9
  Amount: number;
11
10
  Status: PaymentStatus;
12
- TransactionId?: string;
13
- TransactionApprovalCode?: string;
14
- TransactionAccountName?: string;
15
- TransactionAccountNo?: string;
16
11
  ReceivedBy: string;
17
12
  UpdatedAt: Date;
18
13
  UpdatedBy: string;
@@ -7,29 +7,29 @@ import { PaymentRepository } from './payment.repository';
7
7
  import { PaymentItemRepository } from '../payment-item/payment-item.repository';
8
8
  // import PaymentItemModel from '../models/payment-item.entity';
9
9
  import PaymentItem from '../payment-item/payment-item';
10
+ import PaymentPaidWith from '../payment-paid-with/payment-paid-with';
11
+ import { PaymentPaidWithRepository } from 'src/payment-paid-with/payment-paid-with.repository';
10
12
 
11
13
  export default class Payment extends AccountSystemEntity {
12
14
  private _PaymentId = 'New';
13
15
  PaymentType: PaymentType;
14
16
  PaymentDate: Date;
15
- MethodTypeId: string;
16
- Currency: string;
17
- Amount: number;
18
- private _Status: PaymentStatus;
19
- TransactionId: string;
20
- TransactionApprovalCode: string;
21
- TransactionAccountName: string;
22
- TransactionAccountNo: string;
23
- private _ReceivedBy: string;
24
- private _UpdatedBy: string;
25
- private _UpdatedAt: Date;
26
- Remarks: string;
17
+ Description = '';
18
+ Currency = 'MYR';
19
+ Amount = 0;
20
+ Status: PaymentStatus;
21
+ ReceivedBy = '';
22
+ UpdatedBy = '';
23
+ UpdatedAt: Date;
24
+ Remarks = '';
27
25
 
28
26
  private static _RepositoryBase = new PaymentRepository();
29
27
  private static _PaymentItemRepository = new PaymentItemRepository();
28
+ private static _PaymentPaidWithRepository = new PaymentPaidWithRepository();
30
29
 
31
30
  private _DbTransaction: any;
32
31
  private _PaymentItems = [];
32
+ private _PaymentPaidWith = [];
33
33
 
34
34
  paymentItemRepository: PaymentItemRepository;
35
35
 
@@ -41,38 +41,6 @@ export default class Payment extends AccountSystemEntity {
41
41
  this._PaymentId = id;
42
42
  }
43
43
 
44
- public get Status() {
45
- return this._Status;
46
- }
47
-
48
- private set Status(status: PaymentStatus) {
49
- this._Status = status;
50
- }
51
-
52
- public get ReceivedBy() {
53
- return this._ReceivedBy;
54
- }
55
-
56
- public set ReceivedBy(id: string) {
57
- this._ReceivedBy = id;
58
- }
59
-
60
- public get UpdatedBy() {
61
- return this._UpdatedBy;
62
- }
63
-
64
- private set UpdatedBy(id: string) {
65
- this._UpdatedBy = id;
66
- }
67
-
68
- public get UpdatedAt() {
69
- return this._UpdatedAt;
70
- }
71
-
72
- private set UpdatedAt(date: Date) {
73
- this._UpdatedAt = date;
74
- }
75
-
76
44
  /* AccountSystemEntity Implementation */
77
45
  get RepositoryBase() {
78
46
  return Payment._RepositoryBase;
@@ -107,15 +75,10 @@ export default class Payment extends AccountSystemEntity {
107
75
  if (paymentData) {
108
76
  this.PaymentType = paymentData.PaymentType;
109
77
  this.PaymentDate = paymentData.PaymentDate;
110
- this.CompanyId = paymentData.CompanyId;
111
- this.MethodTypeId = paymentData.MethodTypeId;
78
+ this.Description = paymentData.Description;
112
79
  this.Currency = paymentData.Currency;
113
80
  this.Amount = paymentData.Amount;
114
81
  this.Status = paymentData.Status;
115
- this.TransactionId = paymentData.TransactionId;
116
- this.TransactionApprovalCode = paymentData.TransactionApprovalCode;
117
- this.TransactionAccountName = paymentData.TransactionAccountName;
118
- this.TransactionAccountNo = paymentData.TransactionAccountNo;
119
82
  this.ReceivedBy = paymentData.ReceivedBy;
120
83
  this.UpdatedAt = paymentData.UpdatedAt;
121
84
  this.UpdatedBy = paymentData.UpdatedBy;
@@ -190,12 +153,54 @@ export default class Payment extends AccountSystemEntity {
190
153
  });
191
154
  }
192
155
 
156
+ get PaymentPaidWith(): Promise<PaymentPaidWith[]> {
157
+ return new Promise((resolve, reject) => {
158
+ if (this.PaymentId !== 'New') {
159
+ Payment._PaymentPaidWithRepository
160
+ .findAll({
161
+ where: {
162
+ PaymentId: this.PaymentId,
163
+ },
164
+ transaction: this._DbTransaction,
165
+ })
166
+ .then((paymentPaidWithItems) => {
167
+ const paymentPaidWithObjects = paymentPaidWithItems.map(
168
+ (paymentPaidWithItem) => {
169
+ new PaymentPaidWith(
170
+ new Payment(
171
+ this._DbTransaction,
172
+ paymentPaidWithItem.PaymentId,
173
+ ),
174
+ paymentPaidWithItem.MethodTypeId,
175
+ );
176
+ },
177
+ );
178
+ return Promise.all(paymentPaidWithObjects);
179
+ })
180
+ .then((paymentPaidWithObjects) => {
181
+ this._PaymentPaidWith = paymentPaidWithObjects;
182
+ resolve(this._PaymentPaidWith);
183
+ })
184
+ .catch((err) => {
185
+ reject(err);
186
+ });
187
+ }
188
+ resolve(this._PaymentItems);
189
+ });
190
+ }
191
+
193
192
  newPaymentItem(objectBeingPaidFor: ObjectBase): PaymentItem {
194
193
  const paymentItem = new PaymentItem(this, objectBeingPaidFor);
195
194
  this._PaymentItems.push(paymentItem);
196
195
  return paymentItem;
197
196
  }
198
197
 
198
+ newPaymentPaidWIth(paymentMethodId: string) {
199
+ const paymentPaidWith = new PaymentPaidWith(this, paymentMethodId);
200
+ this._PaymentPaidWith.push(paymentPaidWith);
201
+ return paymentPaidWith;
202
+ }
203
+
199
204
  init(Params: IPaymentParams): void {
200
205
  if (Params.Currency) this.Currency = Params.Currency;
201
206
  if (Params.PaymentType) this.PaymentType = Params.PaymentType;
@@ -4,5 +4,7 @@ export class IPaymentItemAttr {
4
4
  PayForObjectType: string;
5
5
  Currency: string;
6
6
  Amount: number;
7
- TaxCode?: string;
7
+ Name?: string;
8
+ Description: string;
9
+ Remarks?: string;
8
10
  }
@@ -2,11 +2,14 @@ import { ObjectBase } from '@tomei/general';
2
2
  import Payment from '../payment/payment';
3
3
 
4
4
  export default class PaymentItem extends ObjectBase {
5
- private _PaymentId: string;
6
- private _PayForObjectId: string;
7
- private _PayForObjectType: string;
5
+ private _PaymentId = '';
6
+ private _PayForObjectId = '';
7
+ private _PayForObjectType = '';
8
8
  Currency = 'MYR';
9
9
  Amount = 0;
10
+ Name = '';
11
+ Description = '';
12
+ Remarks = '';
10
13
 
11
14
  get PaymentId() {
12
15
  return this._PaymentId;
@@ -0,0 +1,14 @@
1
+ import { PaymentStatus } from '../../enum';
2
+
3
+ export class IPaymentPaidWithAttr {
4
+ PaymentId: string;
5
+ MethodTypeId: string;
6
+ Currency: string;
7
+ Amount: number;
8
+ Status: PaymentStatus;
9
+ TransactionId?: string;
10
+ TransactionApprovalCode?: string;
11
+ TransactionApprovalName?: string;
12
+ TransactionAccountNo?: string;
13
+ Remarks?: string;
14
+ }
@@ -0,0 +1,11 @@
1
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
+ import PaymentPaidWithModel from 'src/models/payment-paid-with.entity';
3
+
4
+ export class PaymentPaidWithRepository
5
+ extends RepositoryBase<PaymentPaidWithModel>
6
+ implements IRepositoryBase<PaymentPaidWithModel>
7
+ {
8
+ constructor() {
9
+ super(PaymentPaidWithModel);
10
+ }
11
+ }
@@ -0,0 +1,54 @@
1
+ import { ObjectBase } from '@tomei/general';
2
+ import { PaymentStatus } from '../enum';
3
+ import Payment from '../payment/payment';
4
+ import { PaymentPaidWithRepository } from './payment-paid-with.repository';
5
+
6
+ export default class PaymentPaidWith extends ObjectBase {
7
+ private _PaymentId = '';
8
+ private _MethodTypeId = '';
9
+ Currency = 'MYR';
10
+ Amount = 0;
11
+ Status: PaymentStatus;
12
+ TransactionId = '';
13
+ TransactionApprovalCode = '';
14
+ TransactionApprovalName = '';
15
+ TransactionAccountNo = '';
16
+ Remarks = '';
17
+
18
+ private static _RepositoryBase = new PaymentPaidWithRepository();
19
+
20
+ public get PaymentId() {
21
+ return this._PaymentId;
22
+ }
23
+
24
+ public set PaymentId(id: string) {
25
+ this._PaymentId = id;
26
+ }
27
+
28
+ public get MethodTypeId() {
29
+ return this._MethodTypeId;
30
+ }
31
+
32
+ public set MethodTypeId(id: string) {
33
+ this._MethodTypeId = id;
34
+ }
35
+
36
+ /* ObjectBase Implementation */
37
+ get ObjectId() {
38
+ return '';
39
+ }
40
+
41
+ get ObjectName() {
42
+ return '';
43
+ }
44
+
45
+ get TableName() {
46
+ return 'finance_PaymentPaidWith';
47
+ }
48
+
49
+ constructor(payment: Payment, paymentMethodTypeId: string) {
50
+ super();
51
+ this.PaymentId = payment.PaymentId;
52
+ this.MethodTypeId = paymentMethodTypeId;
53
+ }
54
+ }