@tomei/finance 0.3.0 → 0.3.1

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 (167) hide show
  1. package/dist/account/account.d.ts +24 -27
  2. package/dist/account/account.js +47 -67
  3. package/dist/account/account.js.map +1 -1
  4. package/dist/account/account.repository.d.ts +3 -14
  5. package/dist/account/account.repository.js +4 -39
  6. package/dist/account/account.repository.js.map +1 -1
  7. package/dist/account/interfaces/account-attr.interface.d.ts +15 -7
  8. package/dist/account-system-entity/account-system-entity.d.ts +2 -2
  9. package/dist/account-system-entity/account-system-entity.js +1 -1
  10. package/dist/account-system-entity/post-history.repository.d.ts +2 -2
  11. package/dist/account-system-entity/post-history.repository.js +1 -1
  12. package/dist/customer/customer.d.ts +3 -3
  13. package/dist/customer/customer.js +1 -2
  14. package/dist/customer/customer.js.map +1 -1
  15. package/dist/customer/finance-customer.repository.d.ts +2 -2
  16. package/dist/customer/finance-customer.repository.js +1 -1
  17. package/dist/customer/interfaces/finance-customer.repository.interface.d.ts +2 -2
  18. package/dist/document/document-item.d.ts +1 -1
  19. package/dist/document/document-item.js +1 -2
  20. package/dist/document/document-item.js.map +1 -1
  21. package/dist/document/document-item.repository.d.ts +2 -2
  22. package/dist/document/document-item.repository.js +1 -1
  23. package/dist/document/document.d.ts +14 -16
  24. package/dist/document/document.js +50 -38
  25. package/dist/document/document.js.map +1 -1
  26. package/dist/document/document.repository.d.ts +3 -14
  27. package/dist/document/document.repository.js +4 -39
  28. package/dist/document/document.repository.js.map +1 -1
  29. package/dist/document/interfaces/document-item.repository.interface.d.ts +2 -2
  30. package/dist/enum/index.d.ts +2 -1
  31. package/dist/enum/index.js +3 -1
  32. package/dist/enum/index.js.map +1 -1
  33. package/dist/enum/payment-status.enum.d.ts +4 -0
  34. package/dist/enum/payment-status.enum.js +9 -0
  35. package/dist/enum/payment-status.enum.js.map +1 -0
  36. package/dist/finance-company/finance-company.d.ts +5 -8
  37. package/dist/finance-company/finance-company.js +10 -15
  38. package/dist/finance-company/finance-company.js.map +1 -1
  39. package/dist/finance-company/finance-company.repository.d.ts +2 -2
  40. package/dist/finance-company/finance-company.repository.js +1 -1
  41. package/dist/index.d.ts +11 -8
  42. package/dist/index.js +14 -8
  43. package/dist/index.js.map +1 -1
  44. package/dist/interfaces/account-system.interface.d.ts +2 -2
  45. package/dist/journal-entry/journal-entry.d.ts +5 -7
  46. package/dist/journal-entry/journal-entry.js +8 -9
  47. package/dist/journal-entry/journal-entry.js.map +1 -1
  48. package/dist/journal-entry/journal-entry.repository.d.ts +3 -13
  49. package/dist/journal-entry/journal-entry.repository.js +5 -38
  50. package/dist/journal-entry/journal-entry.repository.js.map +1 -1
  51. package/dist/ledger-transaction/ledger-transaction.d.ts +1 -1
  52. package/dist/ledger-transaction/ledger-transaction.js +1 -2
  53. package/dist/ledger-transaction/ledger-transaction.js.map +1 -1
  54. package/dist/models/account.entity.d.ts +7 -3
  55. package/dist/models/account.entity.js +69 -34
  56. package/dist/models/account.entity.js.map +1 -1
  57. package/dist/models/finance-company.entity.d.ts +0 -4
  58. package/dist/models/finance-company.entity.js +0 -20
  59. package/dist/models/finance-company.entity.js.map +1 -1
  60. package/dist/models/payment-item.entity.d.ts +1 -0
  61. package/dist/models/payment-item.entity.js +7 -0
  62. package/dist/models/payment-item.entity.js.map +1 -1
  63. package/dist/models/payment-method-type.entity.d.ts +13 -0
  64. package/dist/models/payment-method-type.entity.js +86 -0
  65. package/dist/models/payment-method-type.entity.js.map +1 -0
  66. package/dist/models/payment-method.entity.d.ts +7 -0
  67. package/dist/models/payment-method.entity.js +46 -0
  68. package/dist/models/payment-method.entity.js.map +1 -0
  69. package/dist/models/payment.entity.d.ts +15 -10
  70. package/dist/models/payment.entity.js +92 -34
  71. package/dist/models/payment.entity.js.map +1 -1
  72. package/dist/payment/interfaces/payment-attr.interface.d.ts +11 -8
  73. package/dist/payment/interfaces/payment-attr.interface.js.map +1 -1
  74. package/dist/payment/interfaces/payment-item-attr.interface.d.ts +1 -0
  75. package/dist/payment/interfaces/payment-item-attr.interface.js.map +1 -1
  76. package/dist/payment/payment-item.repository.d.ts +3 -15
  77. package/dist/payment/payment-item.repository.js +4 -43
  78. package/dist/payment/payment-item.repository.js.map +1 -1
  79. package/dist/payment/payment.d.ts +46 -48
  80. package/dist/payment/payment.js +105 -126
  81. package/dist/payment/payment.js.map +1 -1
  82. package/dist/payment/payment.repository.d.ts +3 -14
  83. package/dist/payment/payment.repository.js +4 -39
  84. package/dist/payment/payment.repository.js.map +1 -1
  85. package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +8 -0
  86. package/dist/payment-item/interfaces/payment-item-attr.interface.js +7 -0
  87. package/dist/payment-item/interfaces/payment-item-attr.interface.js.map +1 -0
  88. package/{src/payment/interfaces/payment-item.repository.interface.ts → dist/payment-item/interfaces/payment-item.repository.interface.d.ts} +0 -1
  89. package/dist/payment-item/interfaces/payment-item.repository.interface.js +3 -0
  90. package/dist/payment-item/interfaces/payment-item.repository.interface.js.map +1 -0
  91. package/dist/payment-item/payment-item.d.ts +22 -0
  92. package/dist/payment-item/payment-item.js +42 -0
  93. package/dist/payment-item/payment-item.js.map +1 -0
  94. package/dist/payment-item/payment-item.repository.d.ts +5 -0
  95. package/dist/payment-item/payment-item.repository.js +12 -0
  96. package/dist/payment-item/payment-item.repository.js.map +1 -0
  97. package/dist/payment-method/interfaces/payment-method-attr.interface.d.ts +4 -0
  98. package/dist/payment-method/interfaces/payment-method-attr.interface.js +3 -0
  99. package/dist/payment-method/interfaces/payment-method-attr.interface.js.map +1 -0
  100. package/dist/payment-method/payment-method.d.ts +10 -0
  101. package/dist/payment-method/payment-method.js +15 -0
  102. package/dist/payment-method/payment-method.js.map +1 -0
  103. package/dist/payment-method/payment-method.repository.d.ts +5 -0
  104. package/dist/payment-method/payment-method.repository.js +12 -0
  105. package/dist/payment-method/payment-method.repository.js.map +1 -0
  106. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.d.ts +8 -0
  107. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js +3 -0
  108. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js.map +1 -0
  109. package/dist/payment-method-type/payment-method-type.d.ts +14 -0
  110. package/dist/payment-method-type/payment-method-type.js +15 -0
  111. package/dist/payment-method-type/payment-method-type.js.map +1 -0
  112. package/dist/payment-method-type/payment-method-type.repository.d.ts +5 -0
  113. package/dist/payment-method-type/payment-method-type.repository.js +12 -0
  114. package/dist/payment-method-type/payment-method-type.repository.js.map +1 -0
  115. package/dist/tsconfig.tsbuildinfo +1 -1
  116. package/migrations/finance-account-migration.js +30 -16
  117. package/migrations/finance-company-migration.js +0 -14
  118. package/migrations/finance-payment-item-migration.js +4 -0
  119. package/migrations/finance-payment-method-migration.js +21 -0
  120. package/migrations/finance-payment-method-type-migration.js +55 -0
  121. package/migrations/finance-payment-migration.js +42 -25
  122. package/package.json +4 -4
  123. package/src/account/account.repository.ts +5 -38
  124. package/src/account/account.ts +79 -100
  125. package/src/account/interfaces/account-attr.interface.ts +15 -7
  126. package/src/account-system-entity/account-system-entity.ts +4 -4
  127. package/src/account-system-entity/post-history.repository.ts +3 -3
  128. package/src/customer/customer.ts +3 -3
  129. package/src/customer/finance-customer.repository.ts +2 -2
  130. package/src/customer/interfaces/finance-customer.repository.interface.ts +2 -2
  131. package/src/document/document-item.repository.ts +2 -2
  132. package/src/document/document-item.ts +1 -1
  133. package/src/document/document.repository.ts +5 -35
  134. package/src/document/document.ts +66 -55
  135. package/src/document/interfaces/document-item.repository.interface.ts +2 -2
  136. package/src/enum/index.ts +2 -0
  137. package/src/enum/payment-status.enum.ts +4 -0
  138. package/src/finance-company/finance-company.repository.ts +3 -3
  139. package/src/finance-company/finance-company.ts +14 -26
  140. package/src/index.ts +13 -7
  141. package/src/interfaces/account-system.interface.ts +2 -2
  142. package/src/journal-entry/journal-entry.repository.ts +5 -34
  143. package/src/journal-entry/journal-entry.ts +13 -16
  144. package/src/ledger-transaction/ledger-transaction.ts +1 -1
  145. package/src/models/account.entity.ts +67 -32
  146. package/src/models/finance-company.entity.ts +0 -16
  147. package/src/models/payment-item.entity.ts +6 -0
  148. package/src/models/payment-method-type.entity.ts +70 -0
  149. package/src/models/payment-method.entity.ts +28 -0
  150. package/src/models/payment.entity.ts +86 -31
  151. package/src/payment/interfaces/payment-attr.interface.ts +11 -8
  152. package/src/payment/payment.repository.ts +5 -35
  153. package/src/payment/payment.ts +150 -179
  154. package/src/{payment → payment-item}/interfaces/payment-item-attr.interface.ts +1 -0
  155. package/src/payment-item/payment-item.repository.ts +11 -0
  156. package/src/payment-item/payment-item.ts +58 -0
  157. package/src/payment-method/interfaces/payment-method-attr.interface.ts +4 -0
  158. package/src/payment-method/payment-method.repository.ts +11 -0
  159. package/src/payment-method/payment-method.ts +20 -0
  160. package/src/payment-method-type/interfaces/payment-method-type-attr.interface.ts +8 -0
  161. package/src/payment-method-type/payment-method-type.repository.ts +11 -0
  162. package/src/payment-method-type/payment-method-type.ts +24 -0
  163. package/src/account/interfaces/account.repository.interface.ts +0 -4
  164. package/src/document/interfaces/document.repository.interface.ts +0 -4
  165. package/src/journal-entry/interfaces/journal-entry.repository.interface.ts +0 -11
  166. package/src/payment/interfaces/payment.repository.interface.ts +0 -4
  167. package/src/payment/payment-item.repository.ts +0 -49
@@ -1,204 +1,175 @@
1
- import { IBaseRepository, PaymentItemBase } from '@tomei/general';
2
- import { PaymentMethod, PaymentType } from '../enum';
3
- import { IAccountSystem } from '../interfaces';
4
- import { IPaymentRepository } from './interfaces/payment.repository.interface';
5
- import { IPaymentItemRepository } from './interfaces/payment-item.repository.interface';
6
- import { Sequelize } from 'sequelize-typescript';
7
- import { IPaymentAttr } from './interfaces/payment-attr.interface';
8
- import PaymentModel from '../models/payment.entity';
9
- import axios from 'axios';
1
+ import { ObjectBase, RecordNotFoundError } from '@tomei/general';
2
+ import { PaymentType } from '../enum';
10
3
  import { IPaymentParams } from './interfaces/payment-params.interface';
11
4
  import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
12
- import { Account } from '../account/account';
13
- import { FinanceCustomerBase } from '../customer/customer';
14
-
15
- export class Payment extends AccountSystemEntity {
16
- protected BaseRepository: IBaseRepository;
17
- TableName: string;
18
- ObjectId: string;
19
- ObjectName: string;
20
- private Amount: number;
21
- private Currency: string;
22
- private Method: PaymentMethod;
23
- private MethodParty: string;
24
- private Status: string;
25
- private PaymentType: PaymentType;
26
- private PaymentDate: Date;
27
- private AccountNo: string;
28
- private SystemCode: string;
29
- private OwnerId: string;
30
- private OwnerType: string;
31
- private RelatedObjectId: string;
32
- private RelatedObjectType: string;
33
- private CreatedAt: Date;
34
- private CreatedById: string;
35
- private UpdatedAt: Date;
36
- private UpdatedById: string;
37
- private Customer: FinanceCustomerBase;
38
- private ReceivableAccount: Account;
39
- private DepositAccount: Account;
40
- private ReceivableAccountNo: string;
41
- private DepositAccountNo: string;
42
- private PaymentItems: PaymentItemBase[];
43
- private AccountingSystem: IAccountSystem;
44
- private PaymentRepository: IPaymentRepository;
45
- private PaymentItemRepository: IPaymentItemRepository;
46
- private sequelize: Sequelize;
47
- AccSystemCode: string;
48
-
49
- constructor(
50
- AccountingSystem: IAccountSystem,
51
- PaymentRepository: IPaymentRepository,
52
- PaymentItemRepository: IPaymentItemRepository,
53
- Customer: FinanceCustomerBase,
54
- ReceivableAccount: Account,
55
- DepositAccount: Account,
56
- PaymentItems: PaymentItemBase[],
57
- Params?: IPaymentParams,
58
- sequelize?: Sequelize,
59
- ) {
60
- super();
61
- this.AccountingSystem = AccountingSystem;
62
- this.PaymentRepository = PaymentRepository;
63
- this.PaymentItemRepository = PaymentItemRepository;
64
- this.Customer = Customer;
65
- this.ReceivableAccount = ReceivableAccount;
66
- this.DepositAccount = DepositAccount;
67
- this.PaymentItems = PaymentItems;
68
- if (Params) {
69
- this.init(Params);
70
- }
71
- if (sequelize) {
72
- this.sequelize = sequelize;
73
- }
5
+ import { PaymentStatus } from '../enum/payment-status.enum';
6
+ import { PaymentRepository } from './payment.repository';
7
+ import { PaymentItemRepository } from '../payment-item/payment-item.repository';
8
+ import PaymentItemModel from '../models/payment-item.entity';
9
+ import PaymentItem from '../payment-item/payment-item';
10
+
11
+ export default class Payment extends AccountSystemEntity {
12
+ private _PaymentId = 'New';
13
+ PaymentType: PaymentType;
14
+ 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;
27
+
28
+ private static _RepositoryBase = new PaymentRepository();
29
+
30
+ _TableName: string;
31
+ _ObjectId: string;
32
+ _ObjectName: string;
33
+
34
+ private _PaymentItems = null;
35
+
36
+ paymentItemRepository: PaymentItemRepository;
37
+
38
+ public get PaymentId() {
39
+ return this._PaymentId;
74
40
  }
75
41
 
76
- init(Params: IPaymentParams): void {
77
- if (Params.Currency) this.Currency = Params.Currency;
78
- if (Params.Method) this.Method = Params.Method;
79
- if (Params.MethodParty) this.MethodParty = Params.MethodParty;
80
- if (Params.PaymentType) this.PaymentType = Params.PaymentType;
42
+ private set PaymentId(id: string) {
43
+ this._PaymentId = id;
81
44
  }
82
45
 
83
- getAmount(): number {
84
- if (!this.Amount) {
85
- if (this.PaymentItems.length === 0) {
86
- throw new Error('Payment must have at least one payment item');
87
- }
88
- this.PaymentItems.forEach((paymentItem) => {
89
- this.Amount += paymentItem.Amount;
90
- });
91
- }
92
- return this.Amount;
46
+ public get Status() {
47
+ return this._Status;
93
48
  }
94
49
 
95
- getCurrency(): string {
96
- if (!this.Currency) {
97
- throw new Error('Currency is missing.');
98
- }
99
- return this.Currency;
50
+ private set Status(status: PaymentStatus) {
51
+ this._Status = status;
100
52
  }
101
53
 
102
- setSequelize(sequelize: Sequelize): void {
103
- this.sequelize = sequelize;
54
+ public get ReceivedBy() {
55
+ return this._ReceivedBy;
104
56
  }
105
57
 
106
- async getDepositAccountNo(): Promise<string> {
107
- if (!this.DepositAccountNo) {
108
- this.DepositAccountNo = await this.DepositAccount.getAccountNo();
109
- }
110
- return this.DepositAccountNo;
58
+ private set ReceivedBy(id: string) {
59
+ this._ReceivedBy = id;
111
60
  }
112
61
 
113
- async getReceivableAccountNo(): Promise<string> {
114
- if (!this.ReceivableAccountNo) {
115
- this.ReceivableAccountNo = await this.ReceivableAccount.getAccountNo();
116
- }
117
- return this.ReceivableAccountNo;
62
+ public get UpdatedBy() {
63
+ return this._UpdatedBy;
118
64
  }
119
65
 
120
- getPaymentItems(): PaymentItemBase[] {
121
- return this.PaymentItems;
66
+ private set UpdatedBy(id: string) {
67
+ this._UpdatedBy = id;
122
68
  }
123
69
 
124
- async create() {
125
- const transaction = await this.sequelize.transaction();
126
- try {
127
- if (!this.sequelize) {
128
- throw new Error('sequelize instance used for transaction is required.');
129
- }
130
- if (!this.PaymentType) {
131
- throw new Error('Payment Type is required.');
132
- }
133
- if (!this.Method) {
134
- throw new Error('Method is required.');
135
- }
136
- if (this.PaymentItems.length === 0) {
137
- throw new Error('Payment must have at least one payment item');
138
- }
70
+ public get UpdatedAt() {
71
+ return this._UpdatedAt;
72
+ }
139
73
 
140
- this.ReceivableAccountNo = await this.ReceivableAccount.getAccountNo();
141
- this.DepositAccountNo = await this.DepositAccount.getAccountNo();
142
-
143
- this.ObjectId = await this.AccountingSystem.makePayment(
144
- this.Customer,
145
- this,
146
- );
147
-
148
- this.Status = 'Successfull';
149
- const paymentAttribute: IPaymentAttr = {
150
- PaymentId: this.ObjectId,
151
- AccountNo: this.DepositAccountNo,
152
- PaymentType: this.PaymentType,
153
- PaymentDate: new Date(),
154
- Currency: this.Currency,
155
- Amount: this.Amount,
156
- Status: this.Status,
157
- Method: this.Method,
158
- MethodParty: this.MethodParty,
159
- ReceivedBy: this.ReceivableAccountNo,
160
- UpdatedAt: new Date(),
161
- UpdatedBy: 'System', //still ambigous
162
- };
163
- const payment = await this.PaymentRepository.create(paymentAttribute, {
164
- transaction,
165
- });
166
- const paymentItemsData = [];
167
- this.PaymentItems.forEach(async (paymentItem) => {
168
- paymentItemsData.push({
169
- PaymentId: this.ObjectId,
170
- PayForObjectId: paymentItem.ObjectId,
171
- PayForObjectType: paymentItem.Type,
172
- Amount: paymentItem.Amount,
173
- Currency: paymentItem.Currency,
174
- });
175
- });
74
+ private set UpdatedAt(date: Date) {
75
+ this._UpdatedAt = date;
76
+ }
176
77
 
177
- await this.PaymentItemRepository.bulkCreate(paymentItemsData, {
178
- transaction,
78
+ /* AccountSystemEntity Implementation */
79
+ get RepositoryBase() {
80
+ return Payment._RepositoryBase;
81
+ }
82
+
83
+ /* ObjectBase Implementation */
84
+ get ObjectId() {
85
+ return this.PaymentId;
86
+ }
87
+
88
+ get ObjectName() {
89
+ return this.PaymentId;
90
+ }
91
+
92
+ get TableName() {
93
+ return 'finance_Payment';
94
+ }
95
+
96
+ constructor(dbTransaction: any);
97
+ constructor(dbTransaction: any, paymentId: string);
98
+ constructor(dbTransaction: any, paymentId?: string) {
99
+ super();
100
+ this.RepositoryBase.findOne({
101
+ where: {
102
+ PaymentId: paymentId,
103
+ },
104
+ transaction: dbTransaction,
105
+ })
106
+ .then((paymentData) => {
107
+ if (paymentData) {
108
+ this.PaymentType = paymentData.PaymentType;
109
+ this.PaymentDate = paymentData.PaymentDate;
110
+ this.CompanyId = paymentData.CompanyId;
111
+ this.MethodTypeId = paymentData.MethodTypeId;
112
+ this.Currency = paymentData.Currency;
113
+ this.Amount = paymentData.Amount;
114
+ 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
+ this.ReceivedBy = paymentData.ReceivedBy;
120
+ this.UpdatedAt = paymentData.UpdatedAt;
121
+ this.UpdatedBy = paymentData.UpdatedBy;
122
+ this.Remarks = paymentData.Remarks;
123
+ this.AccSystemRefId = paymentData.AccSystemRefId;
124
+ this.PostedToAccSystemYN = paymentData.PostedToAccSystemYN;
125
+ this.PostedById = paymentData.PostedById;
126
+ this.PostedDateTime = paymentData.PostedDateTime;
127
+ } else {
128
+ const notFoundError = new RecordNotFoundError('No Record Found.');
129
+ throw notFoundError;
130
+ }
131
+ })
132
+ .catch((err) => {
133
+ // tslint:disable-next-line:no-console
134
+ console.log('Payment Class constructor err: ', err);
179
135
  });
136
+ }
180
137
 
181
- const payload = {
182
- Action: 'Create',
183
- Activity: 'Payment Created',
184
- Description: `Account (ID: ${this.ObjectId}) has been created`,
185
- EntityType: typeof PaymentModel,
186
- EntityValueBefore: JSON.stringify({}),
187
- EntityValueAfter: JSON.stringify(payment),
188
- PerformedById: payment.UpdatedBy,
189
- PerformedAt: payment.UpdatedAt,
190
- EntityId: this.ObjectId,
191
- };
192
-
193
- await axios.post(
194
- `${process.env.COMMON_API_URL}/activity-histories`,
195
- payload,
196
- );
197
-
198
- await transaction.commit();
199
- } catch (error) {
200
- await transaction.rollback();
201
- throw error;
138
+ public get PaymentItems() {
139
+ if (this._PaymentItems === null) {
140
+ this._PaymentItems = new Array<PaymentItemModel>();
141
+ if (this.PaymentId !== 'New') {
142
+ this.paymentItemRepository
143
+ .findAll({
144
+ where: {
145
+ PaymentId: this.PaymentId,
146
+ },
147
+ })
148
+ .then((allPaymentItems) => {
149
+ this._PaymentItems = allPaymentItems;
150
+ });
151
+ }
202
152
  }
153
+
154
+ return this._PaymentItems;
155
+ }
156
+
157
+ /**
158
+ * Create a new Payment Item which is automatically added to the PaymentItems list
159
+ *
160
+ * @returns {PaymentItem}
161
+ */
162
+ async newPaymentItem(objectBeingPaidFor: ObjectBase): Promise<PaymentItem> {
163
+ const paymentItem = new PaymentItem(
164
+ new Payment(null, this.PaymentId),
165
+ objectBeingPaidFor,
166
+ );
167
+ this.PaymentItems.push(paymentItem);
168
+ return paymentItem;
169
+ }
170
+
171
+ init(Params: IPaymentParams): void {
172
+ if (Params.Currency) this.Currency = Params.Currency;
173
+ if (Params.PaymentType) this.PaymentType = Params.PaymentType;
203
174
  }
204
175
  }
@@ -4,4 +4,5 @@ export class IPaymentItemAttr {
4
4
  PayForObjectType: string;
5
5
  Currency: string;
6
6
  Amount: number;
7
+ TaxCode?: string;
7
8
  }
@@ -0,0 +1,11 @@
1
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
+ import PaymentItemModel from '../models/payment-item.entity';
3
+
4
+ export class PaymentItemRepository
5
+ extends RepositoryBase<PaymentItemModel>
6
+ implements IRepositoryBase<PaymentItemModel>
7
+ {
8
+ constructor() {
9
+ super(PaymentItemModel);
10
+ }
11
+ }
@@ -0,0 +1,58 @@
1
+ import { ObjectBase } from '@tomei/general';
2
+ import Payment from '../payment/payment';
3
+
4
+ export default class PaymentItem extends ObjectBase {
5
+ private _PaymentId: string;
6
+ private _PayForObjectId: string;
7
+ private _PayForObjectType: string;
8
+ Currency = 'MYR';
9
+ Amount = 0;
10
+
11
+ _TableName: string;
12
+ _ObjectId: string;
13
+ _ObjectName: string;
14
+
15
+ get PaymentId() {
16
+ return this._PaymentId;
17
+ }
18
+
19
+ private set PaymentId(id: string) {
20
+ this._PaymentId = id;
21
+ }
22
+
23
+ get PayForObjectId() {
24
+ return this._PayForObjectId;
25
+ }
26
+
27
+ private set PayForObjectId(id: string) {
28
+ this._PayForObjectId = id;
29
+ }
30
+
31
+ get PayForObjectType(): string {
32
+ return this._PayForObjectType;
33
+ }
34
+
35
+ private set PayForObjectType(type: string) {
36
+ this._PayForObjectType = type;
37
+ }
38
+
39
+ /* ObjectBase Implementation */
40
+ get ObjectId() {
41
+ return '';
42
+ }
43
+
44
+ get ObjectName() {
45
+ return '';
46
+ }
47
+
48
+ get TableName() {
49
+ return 'finance_PaymentItem';
50
+ }
51
+
52
+ constructor(payment: Payment, objectBeingPaidFor: ObjectBase) {
53
+ super();
54
+ this.PaymentId = payment.PaymentId;
55
+ this.PayForObjectId = objectBeingPaidFor.ObjectId;
56
+ this.PayForObjectType = typeof objectBeingPaidFor;
57
+ }
58
+ }
@@ -0,0 +1,4 @@
1
+ export interface IPaymentMethodAttr {
2
+ MethodId: string;
3
+ Name: string;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
+ import PaymentMethodModel from 'src/models/payment-method.entity';
3
+
4
+ export class PaymentMethodRepository
5
+ extends RepositoryBase<PaymentMethodModel>
6
+ implements IRepositoryBase<PaymentMethodModel>
7
+ {
8
+ constructor() {
9
+ super(PaymentMethodModel);
10
+ }
11
+ }
@@ -0,0 +1,20 @@
1
+ export default class PaymentMethod {
2
+ MethodId: string;
3
+ Name: string;
4
+
5
+ _TableName: string;
6
+ _ObjectId: string;
7
+ _ObjectName: string;
8
+
9
+ get ObjectId() {
10
+ return '';
11
+ }
12
+
13
+ get ObjectName() {
14
+ return '';
15
+ }
16
+
17
+ get TableName() {
18
+ return 'finance_PaymentMethod';
19
+ }
20
+ }
@@ -0,0 +1,8 @@
1
+ export interface IPaymentMethodTypeAttr {
2
+ MethodTypeId: string;
3
+ MethodId: string;
4
+ Name: string;
5
+ AccountNo: string;
6
+ ProcessingFeeRate: number;
7
+ ProcessingFeeAccountNo: string;
8
+ }
@@ -0,0 +1,11 @@
1
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
+ import PaymentMethodType from '../models/payment-method-type.entity';
3
+
4
+ export class PaymentMethodTypeRepository
5
+ extends RepositoryBase<PaymentMethodType>
6
+ implements IRepositoryBase<PaymentMethodType>
7
+ {
8
+ constructor() {
9
+ super(PaymentMethodType);
10
+ }
11
+ }
@@ -0,0 +1,24 @@
1
+ export default class PaymentMethodType {
2
+ MethodTypeId: string;
3
+ MethodId: string;
4
+ Name: string;
5
+ AccountNo: string;
6
+ ProcessingFeeRate: number;
7
+ ProcessingFeeAccountNo: string;
8
+
9
+ _TableName: string;
10
+ _ObjectId: string;
11
+ _ObjectName: string;
12
+
13
+ get ObjectId() {
14
+ return '';
15
+ }
16
+
17
+ get ObjectName() {
18
+ return '';
19
+ }
20
+
21
+ get TableName() {
22
+ return 'finance_PaymentMethodType';
23
+ }
24
+ }
@@ -1,4 +0,0 @@
1
- import { IBaseRepository } from '@tomei/general';
2
- import AccountModel from '../../models/account.entity';
3
-
4
- export type IAccountRepository = IBaseRepository<AccountModel>;
@@ -1,4 +0,0 @@
1
- import { IBaseRepository } from '@tomei/general';
2
- import DocumentModel from '../../models/document.entity';
3
-
4
- export type IDocumentRepository = IBaseRepository<DocumentModel>;
@@ -1,11 +0,0 @@
1
- export interface IJournalEntryRepository<T> {
2
- create?(data: T | any, options?: any): Promise<T> | any;
3
-
4
- findAll?(options?: any): Promise<T[]>;
5
-
6
- findAllWithPagination(options: any): Promise<{ count: number; rows: T[] }>;
7
-
8
- findOne?(options: any): Promise<T>;
9
-
10
- update?(data: any, options?: any): Promise<any>;
11
- }
@@ -1,4 +0,0 @@
1
- import { IBaseRepository } from '@tomei/general';
2
- import PaymentModel from '../../models/payment.entity';
3
-
4
- export type IPaymentRepository = IBaseRepository<PaymentModel>;
@@ -1,49 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/sequelize';
3
- import { BaseRepository } from '@tomei/general';
4
- import PaymentItemModel from '../models/payment-item.entity';
5
- import { IPaymentItemAttr } from './interfaces/payment-item-attr.interface';
6
- import { IPaymentItemRepository } from './interfaces/payment-item.repository.interface';
7
-
8
- @Injectable()
9
- export class PaymentItemRepository
10
- extends BaseRepository<PaymentItemModel>
11
- implements IPaymentItemRepository
12
- {
13
- constructor(
14
- @InjectModel(PaymentItemModel)
15
- private readonly paymentItemModel: typeof PaymentItemModel,
16
- ) {
17
- super(paymentItemModel);
18
- }
19
-
20
- create(
21
- data: IPaymentItemAttr,
22
- options?: any,
23
- ): Promise<PaymentItemModel> | any {
24
- return this.paymentItemModel.create({ ...data }, options);
25
- }
26
-
27
- bulkCreate(data: IPaymentItemAttr[], options?: any): any {
28
- const payload: any = [...data];
29
- return this.paymentItemModel.bulkCreate(payload, options);
30
- }
31
-
32
- findAll(options: any): Promise<PaymentItemModel[]> {
33
- return this.paymentItemModel.findAll(options);
34
- }
35
-
36
- findAllWithPagination(
37
- options: any,
38
- ): Promise<{ count: number; rows: PaymentItemModel[] }> {
39
- return this.paymentItemModel.findAndCountAll(options);
40
- }
41
-
42
- findOne(options: any): Promise<PaymentItemModel> {
43
- return this.paymentItemModel.findOne(options);
44
- }
45
-
46
- update(data: IPaymentItemAttr, options?: any): any {
47
- return this.paymentItemModel.update({ ...data }, options);
48
- }
49
- }