@tomei/finance 0.3.34 → 0.3.36

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 (71) hide show
  1. package/dist/account-system-entity/account-system-entity.d.ts +5 -15
  2. package/dist/account-system-entity/account-system-entity.js +13 -43
  3. package/dist/account-system-entity/account-system-entity.js.map +1 -1
  4. package/dist/document/document-item.d.ts +13 -13
  5. package/dist/document/document-item.js +5 -5
  6. package/dist/document/document-item.js.map +1 -1
  7. package/dist/document/document.d.ts +3 -1
  8. package/dist/document/document.js +11 -6
  9. package/dist/document/document.js.map +1 -1
  10. package/dist/document/interfaces/document-attr.interface.d.ts +2 -0
  11. package/dist/document/interfaces/document-attr.interface.js.map +1 -1
  12. package/dist/finance-company/finance-company.d.ts +1 -0
  13. package/dist/finance-company/finance-company.js +168 -98
  14. package/dist/finance-company/finance-company.js.map +1 -1
  15. package/dist/helpers/typeof.js +1 -1
  16. package/dist/helpers/typeof.js.map +1 -1
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.js +3 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +1 -1
  21. package/dist/models/document.entity.js +0 -3
  22. package/dist/models/document.entity.js.map +1 -1
  23. package/dist/models/payment-paid-with.entity.d.ts +18 -0
  24. package/dist/models/payment-paid-with.entity.js +117 -0
  25. package/dist/models/payment-paid-with.entity.js.map +1 -0
  26. package/dist/models/payment.entity.d.ts +0 -6
  27. package/dist/models/payment.entity.js +0 -34
  28. package/dist/models/payment.entity.js.map +1 -1
  29. package/dist/payment/interfaces/payment-attr.interface.d.ts +0 -6
  30. package/dist/payment/interfaces/payment-attr.interface.js.map +1 -1
  31. package/dist/payment/payment.d.ts +9 -17
  32. package/dist/payment/payment.js +38 -37
  33. package/dist/payment/payment.js.map +1 -1
  34. package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +1 -0
  35. package/dist/payment-item/interfaces/payment-item-attr.interface.js.map +1 -1
  36. package/dist/payment-item/payment-item.d.ts +1 -0
  37. package/dist/payment-item/payment-item.js +3 -1
  38. package/dist/payment-item/payment-item.js.map +1 -1
  39. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.d.ts +13 -0
  40. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js +7 -0
  41. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js.map +1 -0
  42. package/dist/payment-paid-with/payment-paid-with.d.ts +24 -0
  43. package/dist/payment-paid-with/payment-paid-with.js +44 -0
  44. package/dist/payment-paid-with/payment-paid-with.js.map +1 -0
  45. package/dist/payment-paid-with/payment-paid-with.repository.d.ts +5 -0
  46. package/dist/payment-paid-with/payment-paid-with.repository.js +12 -0
  47. package/dist/payment-paid-with/payment-paid-with.repository.js.map +1 -0
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/migrations/finance-document-migration.js +8 -0
  50. package/migrations/finance-payment-item-migration.js +4 -0
  51. package/migrations/finance-payment-migration.js +0 -36
  52. package/migrations/finance-paymentpaidwith-migration.js +66 -0
  53. package/package.json +1 -1
  54. package/src/account-system-entity/account-system-entity.ts +14 -55
  55. package/src/document/document-item.ts +16 -16
  56. package/src/document/document.ts +12 -12
  57. package/src/document/interfaces/document-attr.interface.ts +2 -0
  58. package/src/finance-company/finance-company.ts +226 -170
  59. package/src/helpers/typeof.ts +1 -1
  60. package/src/index.ts +2 -0
  61. package/src/ledger-transaction/interfaces/ledger-transaction-attr.interface.ts +1 -1
  62. package/src/models/document.entity.ts +1 -3
  63. package/src/models/payment-paid-with.entity.ts +97 -0
  64. package/src/models/payment.entity.ts +0 -32
  65. package/src/payment/interfaces/payment-attr.interface.ts +0 -6
  66. package/src/payment/payment.ts +50 -47
  67. package/src/payment-item/interfaces/payment-item-attr.interface.ts +1 -0
  68. package/src/payment-item/payment-item.ts +3 -1
  69. package/src/payment-paid-with/interfaces/payment-paid-with.interface.ts +14 -0
  70. package/src/payment-paid-with/payment-paid-with.repository.ts +11 -0
  71. package/src/payment-paid-with/payment-paid-with.ts +54 -0
@@ -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,28 +35,6 @@ 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
- @Column({
59
- allowNull: false,
60
- type: DataType.STRING(30),
61
- })
62
- MethodTypeId: string;
63
-
64
38
  @Column({
65
39
  allowNull: false,
66
40
  type: DataType.STRING(1000),
@@ -176,10 +150,4 @@ export default class PaymentModel extends Model {
176
150
 
177
151
  @HasMany(() => PaymentItemModel)
178
152
  PaymentItems: PaymentItemModel[];
179
-
180
- @BelongsTo(() => FinanceCompanyModel)
181
- FinanceCompany: FinanceCompanyModel;
182
-
183
- @BelongsTo(() => PaymentMethodTypeModel)
184
- PaymentMethodType: PaymentMethodTypeModel;
185
153
  }
@@ -4,16 +4,10 @@ export class IPaymentAttr {
4
4
  PaymentId: string;
5
5
  PaymentType: PaymentType;
6
6
  PaymentDate: Date;
7
- CompanyId: string;
8
- MethodTypeId: string;
9
7
  Description: string;
10
8
  Currency: string;
11
9
  Amount: number;
12
10
  Status: PaymentStatus;
13
- TransactionId?: string;
14
- TransactionApprovalCode?: string;
15
- TransactionAccountName?: string;
16
- TransactionAccountNo?: string;
17
11
  ReceivedBy: string;
18
12
  UpdatedAt: Date;
19
13
  UpdatedBy: string;
@@ -7,30 +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 '../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 = '';
16
17
  Description = '';
17
18
  Currency = 'MYR';
18
19
  Amount = 0;
19
- private _Status: PaymentStatus;
20
- TransactionId = '';
21
- TransactionApprovalCode = '';
22
- TransactionAccountName = '';
23
- TransactionAccountNo = '';
24
- private _ReceivedBy = '';
25
- private _UpdatedBy = '';
26
- private _UpdatedAt: Date;
20
+ Status: PaymentStatus;
21
+ ReceivedBy = '';
22
+ UpdatedBy = '';
23
+ UpdatedAt: Date;
27
24
  Remarks = '';
28
25
 
29
26
  private static _RepositoryBase = new PaymentRepository();
30
27
  private static _PaymentItemRepository = new PaymentItemRepository();
28
+ private static _PaymentPaidWithRepository = new PaymentPaidWithRepository();
31
29
 
32
30
  private _DbTransaction: any;
33
31
  private _PaymentItems = [];
32
+ private _PaymentPaidWith = [];
34
33
 
35
34
  paymentItemRepository: PaymentItemRepository;
36
35
 
@@ -42,38 +41,6 @@ export default class Payment extends AccountSystemEntity {
42
41
  this._PaymentId = id;
43
42
  }
44
43
 
45
- public get Status() {
46
- return this._Status;
47
- }
48
-
49
- private set Status(status: PaymentStatus) {
50
- this._Status = status;
51
- }
52
-
53
- public get ReceivedBy() {
54
- return this._ReceivedBy;
55
- }
56
-
57
- public set ReceivedBy(id: string) {
58
- this._ReceivedBy = id;
59
- }
60
-
61
- public get UpdatedBy() {
62
- return this._UpdatedBy;
63
- }
64
-
65
- private set UpdatedBy(id: string) {
66
- this._UpdatedBy = id;
67
- }
68
-
69
- public get UpdatedAt() {
70
- return this._UpdatedAt;
71
- }
72
-
73
- private set UpdatedAt(date: Date) {
74
- this._UpdatedAt = date;
75
- }
76
-
77
44
  /* AccountSystemEntity Implementation */
78
45
  get RepositoryBase() {
79
46
  return Payment._RepositoryBase;
@@ -108,16 +75,10 @@ export default class Payment extends AccountSystemEntity {
108
75
  if (paymentData) {
109
76
  this.PaymentType = paymentData.PaymentType;
110
77
  this.PaymentDate = paymentData.PaymentDate;
111
- this.CompanyId = paymentData.CompanyId;
112
- this.MethodTypeId = paymentData.MethodTypeId;
113
78
  this.Description = paymentData.Description;
114
79
  this.Currency = paymentData.Currency;
115
80
  this.Amount = paymentData.Amount;
116
81
  this.Status = paymentData.Status;
117
- this.TransactionId = paymentData.TransactionId;
118
- this.TransactionApprovalCode = paymentData.TransactionApprovalCode;
119
- this.TransactionAccountName = paymentData.TransactionAccountName;
120
- this.TransactionAccountNo = paymentData.TransactionAccountNo;
121
82
  this.ReceivedBy = paymentData.ReceivedBy;
122
83
  this.UpdatedAt = paymentData.UpdatedAt;
123
84
  this.UpdatedBy = paymentData.UpdatedBy;
@@ -192,12 +153,54 @@ export default class Payment extends AccountSystemEntity {
192
153
  });
193
154
  }
194
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
+
195
192
  newPaymentItem(objectBeingPaidFor: ObjectBase): PaymentItem {
196
193
  const paymentItem = new PaymentItem(this, objectBeingPaidFor);
197
194
  this._PaymentItems.push(paymentItem);
198
195
  return paymentItem;
199
196
  }
200
197
 
198
+ newPaymentPaidWIth(paymentMethodId: string) {
199
+ const paymentPaidWith = new PaymentPaidWith(this, paymentMethodId);
200
+ this._PaymentPaidWith.push(paymentPaidWith);
201
+ return paymentPaidWith;
202
+ }
203
+
201
204
  init(Params: IPaymentParams): void {
202
205
  if (Params.Currency) this.Currency = Params.Currency;
203
206
  if (Params.PaymentType) this.PaymentType = Params.PaymentType;
@@ -6,4 +6,5 @@ export class IPaymentItemAttr {
6
6
  Amount: number;
7
7
  Name?: string;
8
8
  Description: string;
9
+ Remarks?: string;
9
10
  }
@@ -1,5 +1,6 @@
1
1
  import { ObjectBase } from '@tomei/general';
2
2
  import Payment from '../payment/payment';
3
+ import type from '../helpers/typeof';
3
4
 
4
5
  export default class PaymentItem extends ObjectBase {
5
6
  private _PaymentId = '';
@@ -9,6 +10,7 @@ export default class PaymentItem extends ObjectBase {
9
10
  Amount = 0;
10
11
  Name = '';
11
12
  Description = '';
13
+ Remarks = '';
12
14
 
13
15
  get PaymentId() {
14
16
  return this._PaymentId;
@@ -51,6 +53,6 @@ export default class PaymentItem extends ObjectBase {
51
53
  super();
52
54
  this.PaymentId = payment.PaymentId;
53
55
  this.PayForObjectId = objectBeingPaidFor.ObjectId;
54
- this.PayForObjectType = objectBeingPaidFor.constructor.name;
56
+ this.PayForObjectType = type(objectBeingPaidFor);
55
57
  }
56
58
  }
@@ -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 '../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
+ }