@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.
Files changed (85) hide show
  1. package/dist/account/entities/account.entity.d.ts +3 -1
  2. package/dist/account/entities/account.entity.js +6 -1
  3. package/dist/account/entities/account.entity.js.map +1 -1
  4. package/dist/account/interfaces/account.repository.interface.d.ts +1 -1
  5. package/dist/config.d.ts +1 -1
  6. package/dist/enum/index.d.ts +2 -1
  7. package/dist/enum/index.js +3 -1
  8. package/dist/enum/index.js.map +1 -1
  9. package/dist/enum/transaction-type.enum.d.ts +4 -0
  10. package/dist/enum/transaction-type.enum.js +9 -0
  11. package/dist/enum/transaction-type.enum.js.map +1 -0
  12. package/dist/finance-company/finance-company.d.ts +10 -0
  13. package/dist/finance-company/finance-company.js +63 -0
  14. package/dist/finance-company/finance-company.js.map +1 -0
  15. package/dist/finance-company/index.d.ts +2 -0
  16. package/dist/finance-company/index.js +6 -0
  17. package/dist/finance-company/index.js.map +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.js +3 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/interfaces/account-system.interface.d.ts +1 -0
  22. package/dist/journal-entry/entities/journal-entry.entity.d.ts +12 -0
  23. package/dist/journal-entry/entities/journal-entry.entity.js +98 -0
  24. package/dist/journal-entry/entities/journal-entry.entity.js.map +1 -0
  25. package/dist/journal-entry/index.d.ts +6 -0
  26. package/dist/journal-entry/index.js +10 -0
  27. package/dist/journal-entry/index.js.map +1 -0
  28. package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +9 -0
  29. package/dist/journal-entry/interfaces/journal-entry-attr.interface.js +3 -0
  30. package/dist/journal-entry/interfaces/journal-entry-attr.interface.js.map +1 -0
  31. package/dist/journal-entry/interfaces/journal-entry.repository.interface.d.ts +10 -0
  32. package/dist/journal-entry/interfaces/journal-entry.repository.interface.js +3 -0
  33. package/dist/journal-entry/interfaces/journal-entry.repository.interface.js.map +1 -0
  34. package/dist/journal-entry/journal-entry.d.ts +32 -0
  35. package/dist/journal-entry/journal-entry.js +97 -0
  36. package/dist/journal-entry/journal-entry.js.map +1 -0
  37. package/dist/journal-entry/journal-entry.repository.d.ts +15 -0
  38. package/dist/journal-entry/journal-entry.repository.js +43 -0
  39. package/dist/journal-entry/journal-entry.repository.js.map +1 -0
  40. package/dist/ledger-transaction/entities/ledger-transaction.entity.d.ts +19 -0
  41. package/dist/ledger-transaction/entities/ledger-transaction.entity.js +157 -0
  42. package/dist/ledger-transaction/entities/ledger-transaction.entity.js.map +1 -0
  43. package/dist/ledger-transaction/index.d.ts +6 -0
  44. package/dist/ledger-transaction/index.js +10 -0
  45. package/dist/ledger-transaction/index.js.map +1 -0
  46. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +18 -0
  47. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js +3 -0
  48. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js.map +1 -0
  49. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.d.ts +5 -0
  50. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js +3 -0
  51. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js.map +1 -0
  52. package/dist/ledger-transaction/ledger-transaction.d.ts +35 -0
  53. package/dist/ledger-transaction/ledger-transaction.js +71 -0
  54. package/dist/ledger-transaction/ledger-transaction.js.map +1 -0
  55. package/dist/ledger-transaction/ledger-transaction.repository.d.ts +10 -0
  56. package/dist/ledger-transaction/ledger-transaction.repository.js +37 -0
  57. package/dist/ledger-transaction/ledger-transaction.repository.js.map +1 -0
  58. package/dist/payment/interfaces/payment-item.repository.interface.d.ts +1 -1
  59. package/dist/payment/interfaces/payment.repository.interface.d.ts +1 -1
  60. package/dist/tsconfig.tsbuildinfo +1 -1
  61. package/migrations/finance-journal-entry-migration.js +41 -0
  62. package/migrations/finance-ledger-transaction-migration.js +73 -0
  63. package/package.json +2 -2
  64. package/src/account/account.ts +189 -189
  65. package/src/account/entities/account.entity.ts +111 -107
  66. package/src/account/interfaces/account-attr.interface.ts +23 -23
  67. package/src/enum/index.ts +6 -5
  68. package/src/enum/transaction-type.enum.ts +4 -0
  69. package/src/finance-company/finance-company.ts +95 -0
  70. package/src/finance-company/index.ts +3 -0
  71. package/src/index.ts +9 -6
  72. package/src/interfaces/account-system.interface.ts +14 -13
  73. package/src/journal-entry/entities/journal-entry.entity.ts +74 -0
  74. package/src/journal-entry/index.ts +13 -0
  75. package/src/journal-entry/interfaces/journal-entry-attr.interface.ts +9 -0
  76. package/src/journal-entry/interfaces/journal-entry.repository.interface.ts +11 -0
  77. package/src/journal-entry/journal-entry.repository.ts +38 -0
  78. package/src/journal-entry/journal-entry.ts +136 -0
  79. package/src/ledger-transaction/entities/ledger-transaction.entity.ts +134 -0
  80. package/src/ledger-transaction/index.ts +13 -0
  81. package/src/ledger-transaction/interfaces/ledger-transaction-attr.interface.ts +20 -0
  82. package/src/ledger-transaction/interfaces/ledger-transaction.repository.interface.ts +7 -0
  83. package/src/ledger-transaction/ledger-transaction.repository.ts +28 -0
  84. package/src/ledger-transaction/ledger-transaction.ts +96 -0
  85. 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 { PaymentModel } from '../../payment/entities/payment.entity';
12
-
13
- @Table({ tableName: 'finance_Account', createdAt: false, updatedAt: false })
14
- export class AccountModel extends Model {
15
- @ApiProperty({ type: String, description: 'AccountNo' })
16
- @Column({
17
- primaryKey: true,
18
- allowNull: false,
19
- type: DataType.STRING(30),
20
- })
21
- AccountNo: string;
22
-
23
- @ApiProperty({
24
- type: String,
25
- description: 'System Code eg. "EZC", "CRM"',
26
- })
27
- @Column({
28
- allowNull: false,
29
- type: DataType.STRING(10),
30
- })
31
- SystemCode: string;
32
-
33
- @ApiProperty({
34
- type: String,
35
- description: 'Name of the account',
36
- })
37
- @Column({
38
- allowNull: true,
39
- type: DataType.STRING(200),
40
- })
41
- Name: string;
42
-
43
- @ApiProperty({
44
- type: String,
45
- description: 'Owner id of the account',
46
- })
47
- @Column({
48
- allowNull: false,
49
- type: DataType.STRING(30),
50
- })
51
- OwnerId: string;
52
-
53
- @ApiProperty({
54
- type: String,
55
- description: 'Owner type',
56
- })
57
- @Column({
58
- allowNull: false,
59
- type: DataType.STRING(30),
60
- })
61
- OwnerType: string;
62
-
63
- @ApiProperty({ type: String, description: 'Associated Object id' })
64
- @Column({
65
- allowNull: false,
66
- type: DataType.STRING(30),
67
- })
68
- RelatedObjectId: string;
69
-
70
- @ApiProperty({ type: String, description: 'Associated Object type' })
71
- @Column({
72
- allowNull: false,
73
- type: DataType.STRING(200),
74
- })
75
- RelatedObjectType: string;
76
-
77
- @ApiProperty({
78
- example: new Date(),
79
- description: 'Timestamp for data creation.',
80
- })
81
- @CreatedAt
82
- CreatedAt: Date;
83
-
84
- @ApiProperty({
85
- example: '138140891dd211b288d34bc7b4312a49',
86
- description: 'The CreatedById for Media.',
87
- })
88
- @Column({ allowNull: false, type: DataType.STRING(30) })
89
- CreatedById: string;
90
-
91
- @ApiProperty({
92
- example: new Date(),
93
- description: 'Timestamp for latest data modification',
94
- })
95
- @UpdatedAt
96
- UpdatedAt: Date;
97
-
98
- @ApiProperty({
99
- example: '138140891dd211b288d34bc7b4312a49',
100
- description: 'The UpdatedById for Media.',
101
- })
102
- @Column({ allowNull: false, type: DataType.STRING(30) })
103
- UpdatedById: string;
104
-
105
- @HasMany(() => PaymentModel)
106
- PaymentModel: PaymentModel[];
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
- export { ClientScopes, PaymentType, PaymentMethod };
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,4 @@
1
+ export enum TransactionTypeOptions {
2
+ Debit = 1,
3
+ Credit = 2,
4
+ }
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ import { FinanceCompany } from './finance-company';
2
+
3
+ export { FinanceCompany };
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 { getConfig } from './config';
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,9 @@
1
+ export interface IJournalEntryAttr {
2
+ JournalEntryId: string;
3
+ Date: Date;
4
+ Name: string;
5
+ Description: string;
6
+ PostedById: string;
7
+ PostedToAccSystemYN: string;
8
+ DatePosted?: string;
9
+ }
@@ -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
+ }