@tomei/finance 0.3.27 → 0.3.29

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.27",
3
+ "version": "0.3.29",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/config.ts CHANGED
@@ -16,18 +16,214 @@ const config = {
16
16
  },
17
17
  systemConfig: {
18
18
  EZC: {
19
- accountingSystem: 'quickbooks',
19
+ companyId: 'EZC',
20
20
  companyName: process.env.COMPANY_NAME,
21
+ companySystemCode: process.env.COMPANY_SYSTEM_CODE,
22
+ companySystemRefId: process.env.COMPANY_SYSTEM_REF_ID,
23
+ accountingSystem: 'quickbooks',
21
24
  API_Key: process.env.QUICKBOOK_API_KEY,
22
25
  API_Secret: process.env.QUICKBOOK_API_SECRET,
23
26
  redirectUrl: process.env.EZCASH_REDIRECT_URL,
27
+ paymentMethods: {
28
+ cash: {
29
+ id: 'CS',
30
+ name: 'cash',
31
+ types: {},
32
+ },
33
+ bankTransfer: {
34
+ id: 'BT',
35
+ name: 'Bank Transfer',
36
+ types: {},
37
+ },
38
+ debitCard: {
39
+ id: 'DC',
40
+ name: 'Debit Card',
41
+ types: {
42
+ mastercard: {
43
+ id: 'DC-MSC',
44
+ name: 'Mastercard',
45
+ },
46
+ visa: {
47
+ id: 'DC-VISA',
48
+ name: 'Visa',
49
+ },
50
+ },
51
+ },
52
+ creditCard: {
53
+ id: 'CC',
54
+ name: 'Credit Card',
55
+ types: {
56
+ mastercard: {
57
+ id: 'CC-MSC',
58
+ name: 'Mastercard',
59
+ },
60
+ visa: {
61
+ id: 'CC-VISA',
62
+ name: 'Visa',
63
+ },
64
+ amex: {
65
+ id: 'CC-AMEX',
66
+ name: 'American Express',
67
+ },
68
+ },
69
+ },
70
+ eWallet: {
71
+ id: 'EW',
72
+ name: 'E-Wallet',
73
+ types: {
74
+ touchngo: {
75
+ id: 'EW-T&G',
76
+ name: 'Touch & Go',
77
+ },
78
+ Boost: {
79
+ id: 'EW-BOOST',
80
+ name: 'Boost',
81
+ },
82
+ GrabPay: {
83
+ id: 'EW-GRAB',
84
+ name: 'GrabPay',
85
+ },
86
+ ShopeePay: {
87
+ id: 'EW-SHOPEE',
88
+ name: 'ShopeePay',
89
+ },
90
+ },
91
+ },
92
+ mandate: {
93
+ id: 'MD',
94
+ name: 'Mandate',
95
+ types: {},
96
+ },
97
+ storeCredit: {
98
+ id: 'SC',
99
+ name: 'Store Credit',
100
+ types: {},
101
+ },
102
+ pointsRedemption: {
103
+ id: 'PR',
104
+ name: 'Points Redemption',
105
+ types: {},
106
+ },
107
+ voucher: {
108
+ id: 'VC',
109
+ name: 'Voucher',
110
+ types: {
111
+ gift: {
112
+ id: 'VC-GF',
113
+ name: 'Gift Voucher',
114
+ },
115
+ cash: {
116
+ id: 'VC-CS',
117
+ name: 'Cash Voucher',
118
+ },
119
+ },
120
+ },
121
+ },
24
122
  },
25
123
  EZG: {
124
+ companyId: 'EZG',
26
125
  accountingSystem: 'xero',
27
126
  companyName: process.env.COMPANY_NAME,
127
+ companySystemCode: process.env.COMPANY_SYSTEM_CODE,
128
+ companySystemRefId: process.env.COMPANY_SYSTEM_REF_ID,
28
129
  API_Key: process.env.QUICKBOOK_API_KEY,
29
130
  API_Secret: process.env.QUICKBOOK_API_SECRET,
30
131
  redirectUrl: process.env.EZGOLD_REDIRECT_URL,
132
+ paymentMethods: {
133
+ cash: {
134
+ id: 'CS',
135
+ name: 'cash',
136
+ types: {},
137
+ },
138
+ bankTransfer: {
139
+ id: 'BT',
140
+ name: 'Bank Transfer',
141
+ types: {},
142
+ },
143
+ debitCard: {
144
+ id: 'DC',
145
+ name: 'Debit Card',
146
+ types: {
147
+ mastercard: {
148
+ id: 'DC-MSC',
149
+ name: 'Mastercard',
150
+ },
151
+ visa: {
152
+ id: 'DC-VISA',
153
+ name: 'Visa',
154
+ },
155
+ },
156
+ },
157
+ creditCard: {
158
+ id: 'CC',
159
+ name: 'Credit Card',
160
+ types: {
161
+ mastercard: {
162
+ id: 'CC-MSC',
163
+ name: 'Mastercard',
164
+ },
165
+ visa: {
166
+ id: 'CC-VISA',
167
+ name: 'Visa',
168
+ },
169
+ amex: {
170
+ id: 'CC-AMEX',
171
+ name: 'American Express',
172
+ },
173
+ },
174
+ },
175
+ eWallet: {
176
+ id: 'EW',
177
+ name: 'E-Wallet',
178
+ types: {
179
+ touchngo: {
180
+ id: 'EW-T&G',
181
+ name: 'Touch & Go',
182
+ },
183
+ Boost: {
184
+ id: 'EW-BOOST',
185
+ name: 'Boost',
186
+ },
187
+ GrabPay: {
188
+ id: 'EW-GRAB',
189
+ name: 'GrabPay',
190
+ },
191
+ ShopeePay: {
192
+ id: 'EW-SHOPEE',
193
+ name: 'ShopeePay',
194
+ },
195
+ },
196
+ },
197
+ mandate: {
198
+ id: 'MD',
199
+ name: 'Mandate',
200
+ types: {},
201
+ },
202
+ storeCredit: {
203
+ id: 'SC',
204
+ name: 'Store Credit',
205
+ types: {},
206
+ },
207
+ pointsRedemption: {
208
+ id: 'PR',
209
+ name: 'Points Redemption',
210
+ types: {},
211
+ },
212
+ voucher: {
213
+ id: 'VC',
214
+ name: 'Voucher',
215
+ types: {
216
+ gift: {
217
+ id: 'VC-GF',
218
+ name: 'Gift Voucher',
219
+ },
220
+ cash: {
221
+ id: 'VC-CS',
222
+ name: 'Cash Voucher',
223
+ },
224
+ },
225
+ },
226
+ },
31
227
  },
32
228
  },
33
229
  },
@@ -10,10 +10,10 @@ import { JournalEntryRepository } from './journal-entry.repository';
10
10
  import { RecordNotFoundError } from '@tomei/general';
11
11
 
12
12
  export default class JournalEntry extends AccountSystemEntity {
13
- private _JournalEntryId: string;
14
- Date: Date;
15
- Name: string;
16
- Description: string;
13
+ private _JournalEntryId = 'New';
14
+ Date = new Date();
15
+ Name = '';
16
+ Description = '';
17
17
 
18
18
  private static _RepositoryBase = new JournalEntryRepository();
19
19
  private static _LedgerTransactionRepository =
@@ -1,6 +1,8 @@
1
+ import { TransactionTypeOptions } from 'src/enum';
2
+
1
3
  export interface ILedgerTransactionAttr {
2
4
  TransactionId: string;
3
- TransactionType: string;
5
+ TransactionType: TransactionTypeOptions;
4
6
  JournalEntryId: string;
5
7
  AccountNo: string;
6
8
  Date: Date;
@@ -4,43 +4,44 @@ import { TransactionTypeOptions } from '../enum/transaction-type.enum';
4
4
  import { LedgerTransactionRepository } from './ledger-transaction.repository';
5
5
 
6
6
  export default class LedgerTransaction {
7
- TransactionId: string;
8
- JournalEntryId: string;
9
- AccountNo: string;
10
- Date: Date;
11
- Name: string;
12
- Description: string;
13
- Currency: string;
14
- DebitAmount: number;
15
- CreditAmount: number;
16
- RelatedObjectId: string;
17
- RelatedObjectType: string;
7
+ TransactionId = 'New';
8
+ TransactionType = TransactionTypeOptions.DEBIT;
9
+ JournalEntryId = '';
10
+ AccountNo = '';
11
+ Date = new Date();
12
+ Name = '';
13
+ Description = '';
14
+ Currency = 'MYR';
15
+ DebitAmount = 0;
16
+ CreditAmount = 0;
17
+ RelatedObjectId = '';
18
+ RelatedObjectType = '';
18
19
 
19
- TransactionType: string;
20
20
  private _DbTransaction: any;
21
21
 
22
22
  private static _LedgerTransactionRepository =
23
23
  new LedgerTransactionRepository();
24
24
 
25
25
  constructor(dbTransaction?: any, transactionId?: string) {
26
- if(dbTransaction){
26
+ if (dbTransaction) {
27
27
  this._DbTransaction = dbTransaction;
28
28
  }
29
29
  }
30
30
 
31
31
  init(params?: ILedgerTransactionAttr) {
32
- this.TransactionId = params.TransactionId;
33
- this.TransactionType = params.TransactionType;
34
- this.JournalEntryId = params.JournalEntryId;
35
- this.AccountNo = params.AccountNo;
36
- this.Date = params.Date;
37
- this.Name = params.Name;
38
- this.Description = params.Description;
39
- this.Currency = params.Currency;
40
- this.DebitAmount = params.DebitAmount;
41
- this.CreditAmount = params.CreditAmount;
42
- this.RelatedObjectId = params.RelatedObjectId;
43
- this.RelatedObjectType = params.RelatedObjectType;
32
+ if (params.TransactionId) this.TransactionId = params.TransactionId;
33
+ if (params.TransactionType) this.TransactionType = params.TransactionType;
34
+ if (params.JournalEntryId) this.JournalEntryId = params.JournalEntryId;
35
+ if (params.AccountNo) this.AccountNo = params.AccountNo;
36
+ if (params.Date) this.Date = params.Date;
37
+ if (params.Name) this.Name = params.Name;
38
+ if (params.Description) this.Description = params.Description;
39
+ if (params.Currency) this.Currency = params.Currency;
40
+ if (params.DebitAmount) this.DebitAmount = params.DebitAmount;
41
+ if (params.CreditAmount) this.CreditAmount = params.CreditAmount;
42
+ if (params.RelatedObjectId) this.RelatedObjectId = params.RelatedObjectId;
43
+ if (params.RelatedObjectType)
44
+ this.RelatedObjectType = params.RelatedObjectType;
44
45
  }
45
46
 
46
47
  getData() {
@@ -61,7 +62,10 @@ export default class LedgerTransaction {
61
62
  }
62
63
 
63
64
  async create() {
64
- return await LedgerTransaction._LedgerTransactionRepository.create(this.getData, {transaction: this._DbTransaction});
65
+ return await LedgerTransaction._LedgerTransactionRepository.create(
66
+ this.getData,
67
+ { transaction: this._DbTransaction },
68
+ );
65
69
  }
66
70
 
67
71
  async newLedgerTransaction(
@@ -85,9 +89,9 @@ export default class LedgerTransaction {
85
89
  });
86
90
 
87
91
  if (transactionType === TransactionTypeOptions.DEBIT) {
88
- this.TransactionType = 'Debit';
92
+ this.TransactionType = TransactionTypeOptions.DEBIT;
89
93
  } else if (transactionType === TransactionTypeOptions.CREDIT) {
90
- this.TransactionType = 'Credit';
94
+ this.TransactionType = TransactionTypeOptions.CREDIT;
91
95
  }
92
96
 
93
97
  if (journalEntryId) {
@@ -8,7 +8,7 @@ import {
8
8
  } from 'sequelize-typescript';
9
9
  import PaymentModel from './payment.entity';
10
10
 
11
- @Table({ tableName: 'finance_Payment', createdAt: false, updatedAt: false })
11
+ @Table({ tableName: 'finance_PaymentItem', createdAt: false, updatedAt: false })
12
12
  export default class PaymentItemModel extends Model {
13
13
  @ForeignKey(() => PaymentModel)
14
14
  @Column({