@tomei/finance 0.1.13 → 0.2.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.
- package/dist/account/entities/account.entity.d.ts +3 -1
- package/dist/account/entities/account.entity.js +6 -1
- package/dist/account/entities/account.entity.js.map +1 -1
- package/dist/account/interfaces/account.repository.interface.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/enum/index.d.ts +2 -1
- package/dist/enum/index.js +3 -1
- package/dist/enum/index.js.map +1 -1
- package/dist/enum/transaction-type.enum.d.ts +4 -0
- package/dist/enum/transaction-type.enum.js +9 -0
- package/dist/enum/transaction-type.enum.js.map +1 -0
- package/dist/finance-company/finance-company.d.ts +10 -0
- package/dist/finance-company/finance-company.js +63 -0
- package/dist/finance-company/finance-company.js.map +1 -0
- package/dist/finance-company/index.d.ts +2 -0
- package/dist/finance-company/index.js +6 -0
- package/dist/finance-company/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/account-system.interface.d.ts +1 -0
- package/dist/journal-entry/entities/journal-entry.entity.d.ts +12 -0
- package/dist/journal-entry/entities/journal-entry.entity.js +98 -0
- package/dist/journal-entry/entities/journal-entry.entity.js.map +1 -0
- package/dist/journal-entry/index.d.ts +6 -0
- package/dist/journal-entry/index.js +10 -0
- package/dist/journal-entry/index.js.map +1 -0
- package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +9 -0
- package/dist/journal-entry/interfaces/journal-entry-attr.interface.js +3 -0
- package/dist/journal-entry/interfaces/journal-entry-attr.interface.js.map +1 -0
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.d.ts +10 -0
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.js +3 -0
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.js.map +1 -0
- package/dist/journal-entry/journal-entry.d.ts +32 -0
- package/dist/journal-entry/journal-entry.js +97 -0
- package/dist/journal-entry/journal-entry.js.map +1 -0
- package/dist/journal-entry/journal-entry.repository.d.ts +15 -0
- package/dist/journal-entry/journal-entry.repository.js +43 -0
- package/dist/journal-entry/journal-entry.repository.js.map +1 -0
- package/dist/ledger-transaction/entities/ledger-transaction.entity.d.ts +19 -0
- package/dist/ledger-transaction/entities/ledger-transaction.entity.js +157 -0
- package/dist/ledger-transaction/entities/ledger-transaction.entity.js.map +1 -0
- package/dist/ledger-transaction/index.d.ts +6 -0
- package/dist/ledger-transaction/index.js +10 -0
- package/dist/ledger-transaction/index.js.map +1 -0
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +18 -0
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js +3 -0
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js.map +1 -0
- package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.d.ts +5 -0
- package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js +3 -0
- package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js.map +1 -0
- package/dist/ledger-transaction/ledger-transaction.d.ts +35 -0
- package/dist/ledger-transaction/ledger-transaction.js +71 -0
- package/dist/ledger-transaction/ledger-transaction.js.map +1 -0
- package/dist/ledger-transaction/ledger-transaction.repository.d.ts +10 -0
- package/dist/ledger-transaction/ledger-transaction.repository.js +37 -0
- package/dist/ledger-transaction/ledger-transaction.repository.js.map +1 -0
- package/dist/payment/interfaces/payment-item.repository.interface.d.ts +1 -1
- package/dist/payment/interfaces/payment.repository.interface.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/finance-journal-entry-migration.js +41 -0
- package/migrations/finance-ledger-transaction-migration.js +73 -0
- package/package.json +2 -2
- package/src/account/account.ts +189 -189
- package/src/account/entities/account.entity.ts +111 -107
- package/src/account/interfaces/account-attr.interface.ts +23 -23
- package/src/enum/index.ts +6 -5
- package/src/enum/transaction-type.enum.ts +4 -0
- package/src/finance-company/finance-company.ts +95 -0
- package/src/finance-company/index.ts +3 -0
- package/src/index.ts +9 -6
- package/src/interfaces/account-system.interface.ts +14 -13
- package/src/journal-entry/entities/journal-entry.entity.ts +74 -0
- package/src/journal-entry/index.ts +13 -0
- package/src/journal-entry/interfaces/journal-entry-attr.interface.ts +9 -0
- package/src/journal-entry/interfaces/journal-entry.repository.interface.ts +11 -0
- package/src/journal-entry/journal-entry.repository.ts +38 -0
- package/src/journal-entry/journal-entry.ts +136 -0
- package/src/ledger-transaction/entities/ledger-transaction.entity.ts +134 -0
- package/src/ledger-transaction/index.ts +13 -0
- package/src/ledger-transaction/interfaces/ledger-transaction-attr.interface.ts +20 -0
- package/src/ledger-transaction/interfaces/ledger-transaction.repository.interface.ts +7 -0
- package/src/ledger-transaction/ledger-transaction.repository.ts +28 -0
- package/src/ledger-transaction/ledger-transaction.ts +96 -0
- package/src/payment/payment.ts +209 -209
|
@@ -1,107 +1,111 @@
|
|
|
1
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
-
import {
|
|
3
|
-
Column,
|
|
4
|
-
CreatedAt,
|
|
5
|
-
Model,
|
|
6
|
-
Table,
|
|
7
|
-
DataType,
|
|
8
|
-
UpdatedAt,
|
|
9
|
-
HasMany,
|
|
10
|
-
} from 'sequelize-typescript';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
@
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
CreatedAt
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
UpdatedAt
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import {
|
|
3
|
+
Column,
|
|
4
|
+
CreatedAt,
|
|
5
|
+
Model,
|
|
6
|
+
Table,
|
|
7
|
+
DataType,
|
|
8
|
+
UpdatedAt,
|
|
9
|
+
HasMany,
|
|
10
|
+
} from 'sequelize-typescript';
|
|
11
|
+
import { LedgerTransactionModel } from 'src/ledger-transaction/entities/ledger-transaction.entity';
|
|
12
|
+
import { PaymentModel } from '../../payment/entities/payment.entity';
|
|
13
|
+
|
|
14
|
+
@Table({ tableName: 'finance_Account', createdAt: false, updatedAt: false })
|
|
15
|
+
export class AccountModel extends Model {
|
|
16
|
+
@ApiProperty({ type: String, description: 'AccountNo' })
|
|
17
|
+
@Column({
|
|
18
|
+
primaryKey: true,
|
|
19
|
+
allowNull: false,
|
|
20
|
+
type: DataType.STRING(30),
|
|
21
|
+
})
|
|
22
|
+
AccountNo: string;
|
|
23
|
+
|
|
24
|
+
@ApiProperty({
|
|
25
|
+
type: String,
|
|
26
|
+
description: 'System Code eg. "EZC", "CRM"',
|
|
27
|
+
})
|
|
28
|
+
@Column({
|
|
29
|
+
allowNull: false,
|
|
30
|
+
type: DataType.STRING(10),
|
|
31
|
+
})
|
|
32
|
+
SystemCode: string;
|
|
33
|
+
|
|
34
|
+
@ApiProperty({
|
|
35
|
+
type: String,
|
|
36
|
+
description: 'Name of the account',
|
|
37
|
+
})
|
|
38
|
+
@Column({
|
|
39
|
+
allowNull: true,
|
|
40
|
+
type: DataType.STRING(200),
|
|
41
|
+
})
|
|
42
|
+
Name: string;
|
|
43
|
+
|
|
44
|
+
@ApiProperty({
|
|
45
|
+
type: String,
|
|
46
|
+
description: 'Owner id of the account',
|
|
47
|
+
})
|
|
48
|
+
@Column({
|
|
49
|
+
allowNull: false,
|
|
50
|
+
type: DataType.STRING(30),
|
|
51
|
+
})
|
|
52
|
+
OwnerId: string;
|
|
53
|
+
|
|
54
|
+
@ApiProperty({
|
|
55
|
+
type: String,
|
|
56
|
+
description: 'Owner type',
|
|
57
|
+
})
|
|
58
|
+
@Column({
|
|
59
|
+
allowNull: false,
|
|
60
|
+
type: DataType.STRING(30),
|
|
61
|
+
})
|
|
62
|
+
OwnerType: string;
|
|
63
|
+
|
|
64
|
+
@ApiProperty({ type: String, description: 'Associated Object id' })
|
|
65
|
+
@Column({
|
|
66
|
+
allowNull: false,
|
|
67
|
+
type: DataType.STRING(30),
|
|
68
|
+
})
|
|
69
|
+
RelatedObjectId: string;
|
|
70
|
+
|
|
71
|
+
@ApiProperty({ type: String, description: 'Associated Object type' })
|
|
72
|
+
@Column({
|
|
73
|
+
allowNull: false,
|
|
74
|
+
type: DataType.STRING(200),
|
|
75
|
+
})
|
|
76
|
+
RelatedObjectType: string;
|
|
77
|
+
|
|
78
|
+
@ApiProperty({
|
|
79
|
+
example: new Date(),
|
|
80
|
+
description: 'Timestamp for data creation.',
|
|
81
|
+
})
|
|
82
|
+
@CreatedAt
|
|
83
|
+
CreatedAt: Date;
|
|
84
|
+
|
|
85
|
+
@ApiProperty({
|
|
86
|
+
example: '138140891dd211b288d34bc7b4312a49',
|
|
87
|
+
description: 'The CreatedById for Media.',
|
|
88
|
+
})
|
|
89
|
+
@Column({ allowNull: false, type: DataType.STRING(30) })
|
|
90
|
+
CreatedById: string;
|
|
91
|
+
|
|
92
|
+
@ApiProperty({
|
|
93
|
+
example: new Date(),
|
|
94
|
+
description: 'Timestamp for latest data modification',
|
|
95
|
+
})
|
|
96
|
+
@UpdatedAt
|
|
97
|
+
UpdatedAt: Date;
|
|
98
|
+
|
|
99
|
+
@ApiProperty({
|
|
100
|
+
example: '138140891dd211b288d34bc7b4312a49',
|
|
101
|
+
description: 'The UpdatedById for Media.',
|
|
102
|
+
})
|
|
103
|
+
@Column({ allowNull: false, type: DataType.STRING(30) })
|
|
104
|
+
UpdatedById: string;
|
|
105
|
+
|
|
106
|
+
@HasMany(() => PaymentModel)
|
|
107
|
+
Payments: PaymentModel[];
|
|
108
|
+
|
|
109
|
+
@HasMany(() => LedgerTransactionModel)
|
|
110
|
+
LedgerTransactions: LedgerTransactionModel[];
|
|
111
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ObjectBase, PersonBase } from '@tomei/general';
|
|
2
|
-
|
|
3
|
-
export interface IAccountAttr {
|
|
4
|
-
AccountNo: string;
|
|
5
|
-
SystemCode: string;
|
|
6
|
-
Name: string;
|
|
7
|
-
OwnerId: string;
|
|
8
|
-
OwnerType: string;
|
|
9
|
-
RelatedObjectId: string;
|
|
10
|
-
RelatedObjectType: string;
|
|
11
|
-
CreatedAt: Date;
|
|
12
|
-
CreatedById: string;
|
|
13
|
-
UpdatedAt: Date;
|
|
14
|
-
UpdatedById: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ICreateAccountAttr {
|
|
18
|
-
Owner: PersonBase;
|
|
19
|
-
RelatedObject?: ObjectBase;
|
|
20
|
-
AccountType?: string;
|
|
21
|
-
AccountSubType?: string;
|
|
22
|
-
ParentAccountNo?: string;
|
|
23
|
-
}
|
|
1
|
+
import { ObjectBase, PersonBase } from '@tomei/general';
|
|
2
|
+
|
|
3
|
+
export interface IAccountAttr {
|
|
4
|
+
AccountNo: string;
|
|
5
|
+
SystemCode: string;
|
|
6
|
+
Name: string;
|
|
7
|
+
OwnerId: string;
|
|
8
|
+
OwnerType: string;
|
|
9
|
+
RelatedObjectId: string;
|
|
10
|
+
RelatedObjectType: string;
|
|
11
|
+
CreatedAt: Date;
|
|
12
|
+
CreatedById: string;
|
|
13
|
+
UpdatedAt: Date;
|
|
14
|
+
UpdatedById: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ICreateAccountAttr {
|
|
18
|
+
Owner: PersonBase;
|
|
19
|
+
RelatedObject?: ObjectBase;
|
|
20
|
+
AccountType?: string;
|
|
21
|
+
AccountSubType?: string;
|
|
22
|
+
ParentAccountNo?: string;
|
|
23
|
+
}
|
package/src/enum/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ClientScopes } from './quick-book-client-scopes.enum';
|
|
2
|
-
import { PaymentType } from './payment-type.enum';
|
|
3
|
-
import { PaymentMethod } from './payment-method.enum';
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ClientScopes } from './quick-book-client-scopes.enum';
|
|
2
|
+
import { PaymentType } from './payment-type.enum';
|
|
3
|
+
import { PaymentMethod } from './payment-method.enum';
|
|
4
|
+
import { TransactionTypeOptions } from './transaction-type.enum';
|
|
5
|
+
|
|
6
|
+
export { ClientScopes, PaymentType, PaymentMethod, TransactionTypeOptions };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BadRequestException } from '@nestjs/common';
|
|
2
|
+
import { IAccountSystem } from 'src/interfaces';
|
|
3
|
+
import { JournalEntry, JournalEntryRepository } from 'src/journal-entry';
|
|
4
|
+
import { LedgerTransactionRepository } from 'src/ledger-transaction';
|
|
5
|
+
import * as uniqid from 'uniqid';
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import { JournalEntryModel } from 'src/journal-entry';
|
|
8
|
+
|
|
9
|
+
export class FinanceCompany {
|
|
10
|
+
journalEntryRepository: JournalEntryRepository;
|
|
11
|
+
ledgerTransactionRepository: LedgerTransactionRepository;
|
|
12
|
+
|
|
13
|
+
accountingSystem: IAccountSystem;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
journalEntryRepository: JournalEntryRepository,
|
|
17
|
+
ledgerTransactionRepository: LedgerTransactionRepository,
|
|
18
|
+
accountingSystem: IAccountSystem,
|
|
19
|
+
) {
|
|
20
|
+
this.ledgerTransactionRepository = ledgerTransactionRepository;
|
|
21
|
+
this.journalEntryRepository = journalEntryRepository;
|
|
22
|
+
this.accountingSystem = accountingSystem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async postJournal(journalEntryId: string, userId: string): Promise<any> {
|
|
26
|
+
const journalEntry = new JournalEntry(
|
|
27
|
+
this.journalEntryRepository,
|
|
28
|
+
this.ledgerTransactionRepository,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
journalEntry.CreditTransactions?.length < 1 ||
|
|
33
|
+
journalEntry.DebitTransactions?.length < 1
|
|
34
|
+
) {
|
|
35
|
+
throw new BadRequestException(
|
|
36
|
+
'There should be at least 1 debit ledger transaction and 1 credit ledger transaction in the journal entry',
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (
|
|
41
|
+
journalEntry.CreditTransactions?.length !==
|
|
42
|
+
journalEntry.DebitTransactions?.length
|
|
43
|
+
) {
|
|
44
|
+
throw new BadRequestException(
|
|
45
|
+
'Credit ledger transaction and debit ledger transaction should the same amount',
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const matchingJournalEntry = await this.journalEntryRepository.findOne({
|
|
50
|
+
where: {
|
|
51
|
+
JournalEntryId: journalEntryId,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
matchingJournalEntry.PostedById = userId;
|
|
56
|
+
await matchingJournalEntry.save();
|
|
57
|
+
|
|
58
|
+
const allLedgerTransactions =
|
|
59
|
+
await this.ledgerTransactionRepository.findAll();
|
|
60
|
+
|
|
61
|
+
for (const ledgerTransaction of allLedgerTransactions) {
|
|
62
|
+
ledgerTransaction.JournalEntryId = journalEntryId;
|
|
63
|
+
ledgerTransaction.save();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
journalEntry.init({
|
|
67
|
+
JournalEntryId: uniqid(),
|
|
68
|
+
Date: new Date(),
|
|
69
|
+
Name: '',
|
|
70
|
+
Description: '',
|
|
71
|
+
PostedById: userId,
|
|
72
|
+
PostedToAccSystemYN: 'N',
|
|
73
|
+
DatePosted: null,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await this.accountingSystem.postJournalEntry(matchingJournalEntry);
|
|
77
|
+
|
|
78
|
+
const payload = {
|
|
79
|
+
Action: 'Create',
|
|
80
|
+
Activity: 'Post Journal Entry',
|
|
81
|
+
Description: `Journal Entry (ID: ${matchingJournalEntry.JournalEntryId}) has been created`,
|
|
82
|
+
EntityType: typeof JournalEntryModel,
|
|
83
|
+
EntityValueBefore: JSON.stringify({}),
|
|
84
|
+
EntityValueAfter: JSON.stringify(matchingJournalEntry),
|
|
85
|
+
PerformedById: userId,
|
|
86
|
+
PerformedAt: new Date(),
|
|
87
|
+
EntityId: matchingJournalEntry.JournalEntryId,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
await axios.post(
|
|
91
|
+
`${process.env.COMMON_API_URL}/activity-histories`,
|
|
92
|
+
payload,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export * from './account';
|
|
2
|
-
export * from './customer';
|
|
3
|
-
export * from './enum';
|
|
4
|
-
export * from './interfaces';
|
|
5
|
-
export * from './payment';
|
|
6
|
-
export
|
|
1
|
+
export * from './account';
|
|
2
|
+
export * from './customer';
|
|
3
|
+
export * from './enum';
|
|
4
|
+
export * from './interfaces';
|
|
5
|
+
export * from './payment';
|
|
6
|
+
export * from './ledger-transaction';
|
|
7
|
+
export * from './journal-entry';
|
|
8
|
+
export * from './finance-company';
|
|
9
|
+
export { getConfig } from './config';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Customer } from '../customer';
|
|
2
|
-
import { Payment } from '../payment';
|
|
3
|
-
|
|
4
|
-
export interface IAccountSystem {
|
|
5
|
-
createAccount(payload: any): Promise<any>;
|
|
6
|
-
createInvoice(payload: any): Promise<any>;
|
|
7
|
-
createDebitNote(payload: any): Promise<any>;
|
|
8
|
-
createCreditNote(payload: any): Promise<any>;
|
|
9
|
-
postTransaction(payload: any): Promise<any>;
|
|
10
|
-
createCustomer(payload: any): Promise<any>;
|
|
11
|
-
makePayment(customer: Customer, paymentInfo: Payment): Promise<any>;
|
|
12
|
-
collectPayments(customer: Customer, paymentInfo: Payment): Promise<any>;
|
|
13
|
-
|
|
1
|
+
import { Customer } from '../customer';
|
|
2
|
+
import { Payment } from '../payment';
|
|
3
|
+
|
|
4
|
+
export interface IAccountSystem {
|
|
5
|
+
createAccount(payload: any): Promise<any>;
|
|
6
|
+
createInvoice(payload: any): Promise<any>;
|
|
7
|
+
createDebitNote(payload: any): Promise<any>;
|
|
8
|
+
createCreditNote(payload: any): Promise<any>;
|
|
9
|
+
postTransaction(payload: any): Promise<any>;
|
|
10
|
+
createCustomer(payload: any): Promise<any>;
|
|
11
|
+
makePayment(customer: Customer, paymentInfo: Payment): Promise<any>;
|
|
12
|
+
collectPayments(customer: Customer, paymentInfo: Payment): Promise<any>;
|
|
13
|
+
postJournalEntry(payload: any): Promise<any>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { Column, Model, Table, DataType, HasMany } from 'sequelize-typescript';
|
|
3
|
+
import { LedgerTransactionModel } from 'src/ledger-transaction';
|
|
4
|
+
|
|
5
|
+
@Table({
|
|
6
|
+
tableName: 'finance_JournalEntry',
|
|
7
|
+
timestamps: false,
|
|
8
|
+
})
|
|
9
|
+
export class JournalEntryModel extends Model {
|
|
10
|
+
@ApiProperty({ type: String, description: 'JournalEntryId' })
|
|
11
|
+
@Column({
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
allowNull: false,
|
|
14
|
+
type: DataType.STRING(30),
|
|
15
|
+
})
|
|
16
|
+
JournalEntryId: string;
|
|
17
|
+
|
|
18
|
+
@ApiProperty({ type: Date, description: 'Date' })
|
|
19
|
+
@Column({
|
|
20
|
+
allowNull: true,
|
|
21
|
+
type: DataType.DATE,
|
|
22
|
+
})
|
|
23
|
+
Date: Date;
|
|
24
|
+
|
|
25
|
+
@ApiProperty({
|
|
26
|
+
type: String,
|
|
27
|
+
description: 'Name of the journal entry',
|
|
28
|
+
})
|
|
29
|
+
@Column({
|
|
30
|
+
allowNull: false,
|
|
31
|
+
type: DataType.STRING(200),
|
|
32
|
+
})
|
|
33
|
+
Name: string;
|
|
34
|
+
|
|
35
|
+
@ApiProperty({
|
|
36
|
+
type: String,
|
|
37
|
+
description: 'Description of the journal entry',
|
|
38
|
+
})
|
|
39
|
+
@Column({
|
|
40
|
+
allowNull: true,
|
|
41
|
+
type: DataType.STRING(1000),
|
|
42
|
+
})
|
|
43
|
+
Description: string;
|
|
44
|
+
|
|
45
|
+
@ApiProperty({
|
|
46
|
+
example: '138140891dd211b288d34bc7b4312a49',
|
|
47
|
+
description: 'PostedById',
|
|
48
|
+
})
|
|
49
|
+
@Column({ allowNull: false, type: DataType.STRING(30) })
|
|
50
|
+
PostedById: string;
|
|
51
|
+
|
|
52
|
+
@ApiProperty({
|
|
53
|
+
type: String,
|
|
54
|
+
description: 'PostedToAccSystemYN',
|
|
55
|
+
})
|
|
56
|
+
@Column({
|
|
57
|
+
allowNull: false,
|
|
58
|
+
type: DataType.CHAR(1),
|
|
59
|
+
})
|
|
60
|
+
PostedToAccSystemYN: string;
|
|
61
|
+
|
|
62
|
+
@ApiProperty({
|
|
63
|
+
example: new Date(),
|
|
64
|
+
description: 'PostedToAccSystem Date',
|
|
65
|
+
})
|
|
66
|
+
@Column({
|
|
67
|
+
allowNull: true,
|
|
68
|
+
type: DataType.DATE,
|
|
69
|
+
})
|
|
70
|
+
DatePostedToAccSystem: Date;
|
|
71
|
+
|
|
72
|
+
@HasMany(() => LedgerTransactionModel)
|
|
73
|
+
LedgerTransactions: LedgerTransactionModel[];
|
|
74
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JournalEntry } from './journal-entry';
|
|
2
|
+
import { IJournalEntryRepository } from './interfaces/journal-entry.repository.interface';
|
|
3
|
+
import { JournalEntryRepository } from './journal-entry.repository';
|
|
4
|
+
import { JournalEntryModel } from './entities/journal-entry.entity';
|
|
5
|
+
import { IJournalEntryAttr } from './interfaces/journal-entry-attr.interface';
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
JournalEntry,
|
|
9
|
+
IJournalEntryRepository,
|
|
10
|
+
JournalEntryRepository,
|
|
11
|
+
JournalEntryModel,
|
|
12
|
+
IJournalEntryAttr,
|
|
13
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { InjectModel } from '@nestjs/sequelize';
|
|
2
|
+
import { JournalEntryModel } from './entities/journal-entry.entity';
|
|
3
|
+
import { IJournalEntryRepository } from './interfaces/journal-entry.repository.interface';
|
|
4
|
+
import { IJournalEntryAttr } from './interfaces/journal-entry-attr.interface';
|
|
5
|
+
|
|
6
|
+
export class JournalEntryRepository
|
|
7
|
+
implements IJournalEntryRepository<JournalEntryModel>
|
|
8
|
+
{
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(JournalEntryModel)
|
|
11
|
+
private readonly journalEntryModel: typeof JournalEntryModel,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
create(
|
|
15
|
+
data: IJournalEntryAttr | any,
|
|
16
|
+
options?: any,
|
|
17
|
+
): Promise<JournalEntryModel> | any {
|
|
18
|
+
return this.journalEntryModel.create(data, options);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
findAll(options?: any): Promise<JournalEntryModel[]> {
|
|
22
|
+
return this.journalEntryModel.findAll(options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
findAllWithPagination(
|
|
26
|
+
options: any,
|
|
27
|
+
): Promise<{ count: number; rows: JournalEntryModel[] }> {
|
|
28
|
+
return this.journalEntryModel.findAndCountAll(options);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
findOne(options: any): Promise<JournalEntryModel> {
|
|
32
|
+
return this.journalEntryModel.findOne(options);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
update(data: IJournalEntryAttr, options?: any): any {
|
|
36
|
+
return this.journalEntryModel.update({ ...data }, options);
|
|
37
|
+
}
|
|
38
|
+
}
|