@goweekdays/core 2.14.0 → 2.15.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @goweekdays/core
2
2
 
3
+ ## 2.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 770a91a: Finance business profile initial release
8
+
9
+ ### Patch Changes
10
+
11
+ - c54c430: Integrate account balance tracker
12
+ - b31181e: Support updating journal entries with line diffing
13
+
3
14
  ## 2.14.0
4
15
 
5
16
  ### Minor Changes
package/CLAUDE.md ADDED
@@ -0,0 +1,274 @@
1
+ # server-core-module (`@goweekdays/core`)
2
+
3
+ Shared server module exported as a package consumed by all app servers.
4
+ Built with Express + MongoDB (Atlas) + TypeScript.
5
+
6
+ ## Resource Layer Pattern
7
+
8
+ Each resource lives under `src/resources/<resource-name>/` and follows this structure:
9
+
10
+ ```
11
+ resource-name/
12
+ resource.model.ts # Types and validation schema
13
+ resource.repository.ts # Direct database interaction
14
+ resource.service.ts # Business logic (optional — see below)
15
+ resource.controller.ts # API request handler
16
+ index.ts # Barrel export
17
+ ```
18
+
19
+ ### `.model.ts`
20
+
21
+ Defines the TypeScript type and Joi validation schema for the resource. This is the source of truth for the shape of the data.
22
+
23
+ ### `.repository.ts`
24
+
25
+ Contains all functions that directly interact with the database (MongoDB). No business logic here — only reads and writes.
26
+
27
+ ### `.service.ts`
28
+
29
+ Builds business logic by composing repository functions and third-party integrations (e.g. hashing, email, S3, transactions). Never accesses the database directly — all DB interaction goes through the repository. **This layer is optional** — if a resource only needs basic CRUD with no business logic, a service file is not required.
30
+
31
+ ### `.controller.ts`
32
+
33
+ Handles incoming API requests. Validates the request input, then delegates to the service layer if business logic exists, or calls the repository directly if the resource has no service.
34
+
35
+ ### `index.ts`
36
+
37
+ Re-exports all layers so consumers can import from the resource folder directly.
38
+
39
+ ```typescript
40
+ export * from "./user.model";
41
+ export * from "./user.repository";
42
+ export * from "./user.service";
43
+ export * from "./user.controller";
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Naming Conventions
49
+
50
+ | Layer | Pattern | Example |
51
+ | ---------- | --------------------------- | ---------------------------------------------------- |
52
+ | File | `<resource>.<layer>.ts` | `user.model.ts`, `finance.journal.config.service.ts` |
53
+ | Type | `T<Resource>` | `TUser`, `TJobPost` |
54
+ | Schema | `schema<Resource>` | `schemaUser`, `schemaJobPost` |
55
+ | Model fn | `model<Resource>()` | `modelUser()`, `modelJobPost()` |
56
+ | Repository | `use<Resource>Repo()` | `useUserRepo()`, `useOrgRepo()` |
57
+ | Service | `use<Resource>Service()` | `useUserService()`, `useOrgService()` |
58
+ | Controller | `use<Resource>Controller()` | `useUserController()` |
59
+
60
+ Multi-word resource names use dot notation in file names: `finance.journal.config.model.ts`, `job.post.repository.ts`.
61
+
62
+ ---
63
+
64
+ ## Error Handling
65
+
66
+ Always use the typed error classes from `@goweekdays/utils` — never throw a generic `new Error()`.
67
+
68
+ - `BadRequestError` — invalid input or a violated business rule
69
+ - `NotFoundError` — resource does not exist
70
+ - `InternalServerError` — unexpected DB or system failure
71
+ - `AppError` — base class; use `instanceof AppError` in catch blocks to re-throw typed errors as-is
72
+
73
+ ---
74
+
75
+ ## Controller Input Extraction
76
+
77
+ Validate the entire `req.body` against a Joi schema to ensure no unexpected keys are passed. Extract only the fields you need after validation.
78
+
79
+ 1. Define a Joi schema that describes exactly the expected shape
80
+ 2. Validate `req.body` (or `req.params` / `req.query`) against it — reject if invalid
81
+ 3. Destructure only the needed fields from the validated result
82
+ 4. Delegate to the service or repository
83
+
84
+ This prevents unexpected or extra fields from leaking into the database.
85
+
86
+ ---
87
+
88
+ ## Transactions
89
+
90
+ Use a MongoDB session whenever a service function writes to more than one collection. The pattern is always:
91
+
92
+ 1. Start session and transaction
93
+ 2. Pass `session` down to every repo call
94
+ 3. Commit on success, abort on error, and always end the session in `finally`
95
+
96
+ Transactions belong in the service layer only — never in a controller or repository.
97
+
98
+ ---
99
+
100
+ ## What Not To Do
101
+
102
+ - **No business logic in controllers** — controllers only handle HTTP input/output and delegate
103
+ - **No direct DB access in controllers or services** — all DB interaction belongs in the repository only
104
+ - **No generic `Error` throws** — use the typed error classes above
105
+ - **No Zod** — validation is done with Joi throughout this module
106
+ - **No extra fields into the DB** — always validate the full request body before using any of it
107
+
108
+ # Monthly Account Balance Tracking — Instruction Set
109
+
110
+ ## Objective
111
+
112
+ Maintain a monthly balance tracker for each account using the structure:
113
+
114
+ (accountId, fiscalYear, month)
115
+
116
+ Each record must contain:
117
+
118
+ - openingDebit
119
+ - openingCredit
120
+ - movementDebit
121
+ - movementCredit
122
+ - closingDebit
123
+ - closingCredit
124
+ - netBalance
125
+
126
+ ---
127
+
128
+ # 1. When Posting a Journal Entry
129
+
130
+ For each journal line in a transaction:
131
+
132
+ 1. Identify:
133
+
134
+ - accountId
135
+ - transactionDate
136
+ - month
137
+ - fiscalYear
138
+ - debitAmount
139
+ - creditAmount
140
+
141
+ 2. Locate the balance record:
142
+
143
+ (accountId, fiscalYear, month)
144
+
145
+ ---
146
+
147
+ # 2. If Balance Record Exists
148
+
149
+ Update the movement values.
150
+
151
+ If the journal line is debit:
152
+
153
+ movementDebit += debitAmount
154
+
155
+ If the journal line is credit:
156
+
157
+ movementCredit += creditAmount
158
+
159
+ Then recompute the closing balance.
160
+
161
+ ---
162
+
163
+ # 3. If Balance Record Does NOT Exist
164
+
165
+ Create a new balance record.
166
+
167
+ Determine the opening balance using the following rules.
168
+
169
+ ## Rule A — Previous Month Record Exists
170
+
171
+ Find the latest previous balance record for the same account.
172
+
173
+ (accountId, previousMonth, fiscalYear)
174
+
175
+ Set the opening balance:
176
+
177
+ openingDebit = previousRecord.closingDebit
178
+ openingCredit = previousRecord.closingCredit
179
+
180
+ ## Rule B — No Previous Record Exists
181
+
182
+ This means the account is used for the first time.
183
+
184
+ Set:
185
+
186
+ openingDebit = 0
187
+ openingCredit = 0
188
+
189
+ ## Initialize Movement
190
+
191
+ After determining the opening balance:
192
+
193
+ movementDebit = debitAmount
194
+ movementCredit = creditAmount
195
+
196
+ ---
197
+
198
+ # 4. Recompute Closing Balance
199
+
200
+ After movement updates, compute the net balance.
201
+
202
+ netBalance = (openingDebit + movementDebit) - (openingCredit + movementCredit)
203
+
204
+ If netBalance > 0:
205
+
206
+ closingDebit = netBalance
207
+ closingCredit = 0
208
+
209
+ If netBalance < 0:
210
+
211
+ closingDebit = 0
212
+ closingCredit = abs(netBalance)
213
+
214
+ If netBalance == 0:
215
+
216
+ closingDebit = 0
217
+ closingCredit = 0
218
+
219
+ The `netBalance` field should always store the computed value so the system can quickly determine whether the account has a debit or credit balance without recalculating.
220
+
221
+ ---
222
+
223
+ # 5. Month-to-Month Carry Forward Rule
224
+
225
+ When a new month record is created:
226
+
227
+ opening balance = previous month closing balance
228
+
229
+ Example:
230
+
231
+ January closing = 8,000 debit
232
+ February opening = 8,000 debit
233
+
234
+ ---
235
+
236
+ # 6. Summary of Posting Flow
237
+
238
+ For each journal line:
239
+
240
+ 1. Determine account, fiscalYear, and month
241
+ 2. Find balance record
242
+ 3. If record exists → update movement
243
+ 4. If record does not exist
244
+
245
+ - find previous balance record
246
+ - set opening = previous closing (or zero)
247
+ - create new balance record
248
+
249
+ 5. Update movement values
250
+ 6. Recompute closing balance
251
+
252
+ ---
253
+
254
+ # 7. Important Principle
255
+
256
+ Opening balance always represents:
257
+
258
+ balance before the period starts
259
+
260
+ Therefore:
261
+
262
+ opening = previous closing
263
+
264
+ If no previous record exists:
265
+
266
+ opening = 0
267
+
268
+ ---
269
+
270
+ This logic ensures:
271
+
272
+ - continuous balance tracking
273
+ - correct month-to-month carry over
274
+ - efficient financial reporting without recalculating all journal entries
package/dist/index.d.ts CHANGED
@@ -1697,6 +1697,70 @@ declare function useJobSummaryCtrl(): {
1697
1697
  getByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1698
1698
  };
1699
1699
 
1700
+ type TBusinessProfileTaxType = "VAT" | "NON-VAT";
1701
+ declare const taxTypes: string[];
1702
+ type TBusinessProfile = {
1703
+ _id?: ObjectId;
1704
+ org: ObjectId | string;
1705
+ businessName: string;
1706
+ tradeName?: string;
1707
+ TIN: string;
1708
+ registeredAddress: string;
1709
+ taxType: TBusinessProfileTaxType;
1710
+ RDOCode: string;
1711
+ fiscalYearStart: string;
1712
+ fiscalYearEnd: string;
1713
+ currentFiscalYear: string;
1714
+ currentFiscalYearStartDate: Date | string;
1715
+ currentFiscalYearEndDate: Date | string;
1716
+ createdAt?: Date | string;
1717
+ updatedAt?: Date | string;
1718
+ };
1719
+ declare const schemaBusinessProfile: Joi.ObjectSchema<any>;
1720
+ declare const schemaBusinessProfileBusinessName: Joi.ObjectSchema<any>;
1721
+ declare const schemaBusinessProfileTradeName: Joi.ObjectSchema<any>;
1722
+ declare const schemaBusinessProfileRegisteredAddress: Joi.ObjectSchema<any>;
1723
+ declare const schemaBusinessProfileTIN: Joi.ObjectSchema<any>;
1724
+ declare const schemaBusinessProfileRDOCode: Joi.ObjectSchema<any>;
1725
+ declare const schemaBusinessProfileCurrentFiscalYear: Joi.ObjectSchema<any>;
1726
+ declare const schemaBusinessProfileFiscalYear: Joi.ObjectSchema<any>;
1727
+ declare function modelBusinessProfile(data: TBusinessProfile): TBusinessProfile;
1728
+
1729
+ declare function useBusinessProfileRepo(): {
1730
+ createIndexes: () => Promise<void>;
1731
+ add: (data: TBusinessProfile) => Promise<string>;
1732
+ getByOrg: (org: string | ObjectId) => Promise<mongodb.WithId<bson.Document> | TBusinessProfile | null>;
1733
+ updateBusinessNameByOrg: (org: string | ObjectId, value: {
1734
+ businessName: string;
1735
+ taxType: string;
1736
+ }) => Promise<string>;
1737
+ updateTradeNameByOrg: (org: string | ObjectId, value: string) => Promise<string>;
1738
+ updateRegisteredAddressByOrg: (org: string | ObjectId, value: string) => Promise<string>;
1739
+ updateTINByOrg: (org: string | ObjectId, value: string) => Promise<string>;
1740
+ updateRDOCodeByOrg: (org: string | ObjectId, value: string) => Promise<string>;
1741
+ updateFiscalYearByOrg: (org: string | ObjectId, value: {
1742
+ fiscalYearStart: string;
1743
+ fiscalYearEnd: string;
1744
+ }) => Promise<string>;
1745
+ updateCurrentFiscalYearByOrg: (org: string | ObjectId, value: {
1746
+ currentFiscalYear: string;
1747
+ currentFiscalYearStartDate: string;
1748
+ currentFiscalYearEndDate: string;
1749
+ }) => Promise<string>;
1750
+ };
1751
+
1752
+ declare function useBusinessProfileCtrl(): {
1753
+ add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1754
+ getByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1755
+ updateBusinessNameByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1756
+ updateTradeNameByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1757
+ updateRegisteredAddressByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1758
+ updateTINByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1759
+ updateRDOCodeByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1760
+ updateCurrentFiscalYearByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1761
+ updateFiscalYearByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1762
+ };
1763
+
1700
1764
  type TTax = {
1701
1765
  _id?: ObjectId;
1702
1766
  org: ObjectId;
@@ -1827,13 +1891,85 @@ declare function useChartOfAccountController(): {
1827
1891
  updateStatusById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1828
1892
  };
1829
1893
 
1830
- type TJournalGeneralStatus = "draft" | "posted" | "voided";
1831
- declare const JournalGeneralStatuses: TJournalGeneralStatus[];
1832
- type TJournalGeneral = {
1894
+ type TAccountBalance = {
1895
+ _id?: ObjectId;
1896
+ org: ObjectId | string;
1897
+ account: ObjectId | string;
1898
+ accountType: string;
1899
+ period: {
1900
+ fiscalYear: number;
1901
+ month: string;
1902
+ };
1903
+ openingDebit: number;
1904
+ openingCredit: number;
1905
+ movementDebit: number;
1906
+ movementCredit: number;
1907
+ closingDebit: number;
1908
+ closingCredit: number;
1909
+ netBalance: number;
1910
+ createdAt: Date | string;
1911
+ updatedAt: Date | string;
1912
+ };
1913
+ declare const schemaAccountBalance: Joi.ObjectSchema<TAccountBalance>;
1914
+ declare function modelAccountBalance(value: TAccountBalance): {
1915
+ createdAt: string | Date;
1916
+ updatedAt: string | Date;
1917
+ _id?: ObjectId | undefined;
1918
+ org: string | ObjectId;
1919
+ account: string | ObjectId;
1920
+ accountType: string;
1921
+ period: {
1922
+ fiscalYear: number;
1923
+ month: string;
1924
+ };
1925
+ openingDebit: number;
1926
+ openingCredit: number;
1927
+ movementDebit: number;
1928
+ movementCredit: number;
1929
+ closingDebit: number;
1930
+ closingCredit: number;
1931
+ netBalance: number;
1932
+ };
1933
+
1934
+ declare function useAccountBalanceRepo(): {
1935
+ createIndexes: () => Promise<void>;
1936
+ add: (value: TAccountBalance, session?: ClientSession) => Promise<ObjectId>;
1937
+ getAll: (options: {
1938
+ org: ObjectId | string;
1939
+ account?: ObjectId | string;
1940
+ fiscalYear?: number;
1941
+ page?: number;
1942
+ limit?: number;
1943
+ }) => Promise<Record<string, any>>;
1944
+ getById: (_id: string | ObjectId) => Promise<TAccountBalance | null>;
1945
+ getByAccount: (options: {
1946
+ account: ObjectId | string;
1947
+ org: ObjectId | string;
1948
+ fiscalYear: number;
1949
+ month: string;
1950
+ }) => Promise<TAccountBalance | null>;
1951
+ getYearBalancesByAccount: (options: {
1952
+ account: ObjectId | string;
1953
+ org: ObjectId | string;
1954
+ fiscalYear: number;
1955
+ }) => Promise<TAccountBalance[]>;
1956
+ updateById: (account: string | ObjectId, org: string | ObjectId, fiscalYear: number, month: string, options: Partial<Pick<TAccountBalance, "openingDebit" | "openingCredit" | "movementDebit" | "movementCredit" | "closingDebit" | "closingCredit" | "netBalance">>, session?: ClientSession) => Promise<string>;
1957
+ deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
1958
+ };
1959
+
1960
+ type TJournalStatus = "draft" | "posted" | "voided";
1961
+ declare const JournalStatuses: TJournalStatus[];
1962
+ type TJournalType = "general" | "cash-receipts" | "cash-disbursements" | "sales" | "purchases";
1963
+ declare const journalTypes: TJournalType[];
1964
+ type TJournal = {
1833
1965
  _id?: ObjectId;
1834
1966
  id: string;
1835
1967
  org: ObjectId | string;
1836
- type: string;
1968
+ type: TJournalType;
1969
+ transaction: string;
1970
+ invoiceNumber?: string;
1971
+ customer?: ObjectId | string;
1972
+ customerName?: string;
1837
1973
  date: Date | string;
1838
1974
  description: string;
1839
1975
  createdBy: ObjectId | string;
@@ -1843,21 +1979,23 @@ type TJournalGeneral = {
1843
1979
  reversedEntryNumber?: string;
1844
1980
  reversedBy?: ObjectId | string;
1845
1981
  reversedByName?: string;
1846
- status: TJournalGeneralStatus;
1982
+ status: TJournalStatus;
1847
1983
  postedAt?: Date | string;
1848
1984
  reversedAt?: Date | string;
1849
1985
  createdAt?: Date | string;
1850
1986
  updatedAt?: Date | string;
1851
1987
  };
1852
- declare const schemaJournalGeneralCtrl: Joi.ObjectSchema<any>;
1853
- declare const schemaJournalGeneralRepo: Joi.ObjectSchema<any>;
1854
- declare const schemaJournalGeneralRepoUpdate: Joi.ObjectSchema<any>;
1855
- declare const schemaJournalGeneralGetAll: Joi.ObjectSchema<any>;
1856
- declare function modelJournalGeneral(data: TJournalGeneral): TJournalGeneral;
1988
+ declare const schemaJournalCtrl: Joi.ObjectSchema<any>;
1989
+ declare const schemaJournalCtrlUpdate: Joi.ObjectSchema<any>;
1990
+ declare const schemaJournalRepo: Joi.ObjectSchema<any>;
1991
+ declare const schemaJournalRepoUpdate: Joi.ObjectSchema<any>;
1992
+ declare const schemaJournalGetAll: Joi.ObjectSchema<any>;
1993
+ declare function modelJournal(data: TJournal): TJournal;
1857
1994
 
1858
- declare function useJournalGeneralRepo(): {
1995
+ declare function useJournalRepo(): {
1859
1996
  createIndexes: () => Promise<void>;
1860
- add: (value: TJournalGeneral, session?: ClientSession) => Promise<ObjectId>;
1997
+ delCachedData: () => void;
1998
+ add: (value: TJournal, session?: ClientSession) => Promise<ObjectId>;
1861
1999
  getAll: (options: {
1862
2000
  org: ObjectId | string;
1863
2001
  search?: string;
@@ -1866,8 +2004,8 @@ declare function useJournalGeneralRepo(): {
1866
2004
  type: string;
1867
2005
  status?: string;
1868
2006
  }) => Promise<Record<string, any>>;
1869
- getById: (_id: string | ObjectId) => Promise<TJournalGeneral>;
1870
- updateById: (_id: string | ObjectId, options: Partial<TJournalGeneral>, session?: ClientSession) => Promise<string>;
2007
+ getById: (_id: string | ObjectId) => Promise<TJournal>;
2008
+ updateById: (_id: string | ObjectId, options: Partial<TJournal>, session?: ClientSession) => Promise<string>;
1871
2009
  deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
1872
2010
  updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<string>;
1873
2011
  };
@@ -1882,6 +2020,7 @@ type TJournalLine = {
1882
2020
  account: ObjectId | string;
1883
2021
  accountName: string;
1884
2022
  accountCode: string;
2023
+ accountType: string;
1885
2024
  debit: number;
1886
2025
  credit: number;
1887
2026
  postReference?: string;
@@ -1890,82 +2029,23 @@ type TJournalLine = {
1890
2029
  createdAt?: Date | string;
1891
2030
  updatedAt?: Date | string;
1892
2031
  };
2032
+ declare const schemaJournalLineBase: {
2033
+ account: Joi.StringSchema<string>;
2034
+ debit: Joi.NumberSchema<number>;
2035
+ credit: Joi.NumberSchema<number>;
2036
+ };
1893
2037
  declare const schemaJournalLineCtrl: Joi.ObjectSchema<any>;
2038
+ declare const schemaJournalLineCtrlUpdate: Joi.ObjectSchema<any>;
1894
2039
  declare const schemaJournalLineRepo: Joi.ObjectSchema<any>;
1895
2040
  declare function modelJournalLine(data: TJournalLine): TJournalLine;
1896
2041
 
1897
- declare function useJournalGeneralService(): {
1898
- add: (entry: TJournalGeneral, lines: TJournalLine[]) => Promise<string>;
1899
- updateStatusById: (_id: string, status: TJournalGeneralStatus, user: string) => Promise<string>;
1900
- };
1901
-
1902
- declare function useJournalGeneralController(): {
1903
- add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1904
- getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1905
- getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1906
- updateById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1907
- deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1908
- updateStatusById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1909
- };
1910
-
1911
- type TJournalCashReceiptStatus = "draft" | "posted" | "voided";
1912
- declare const JournalCashReceiptStatuses: TJournalCashReceiptStatus[];
1913
- type TJournalCashReceipt = {
1914
- _id?: ObjectId;
1915
- id: string;
1916
- org: ObjectId | string;
1917
- type: string;
1918
- date: Date | string;
1919
- customer: ObjectId | string;
1920
- customerName?: string;
1921
- invoiceNumber: string;
1922
- cash: number;
1923
- discount?: number;
1924
- withholdingTax?: number;
1925
- sales: number;
1926
- description?: string;
1927
- createdBy: ObjectId | string;
1928
- createdByName: string;
1929
- reversalDraft?: ObjectId | string;
1930
- reversedEntry?: ObjectId | string;
1931
- reversedEntryNumber?: string;
1932
- reversedBy?: ObjectId | string;
1933
- reversedByName?: string;
1934
- status: TJournalCashReceiptStatus;
1935
- postedAt?: Date | string;
1936
- reversedAt?: Date | string;
1937
- createdAt?: Date | string;
1938
- updatedAt?: Date | string;
1939
- };
1940
- declare const schemaJournalCashReceiptCtrl: Joi.ObjectSchema<any>;
1941
- declare const schemaJournalCashReceiptRepo: Joi.ObjectSchema<any>;
1942
- declare const schemaJournalCashReceiptRepoUpdate: Joi.ObjectSchema<any>;
1943
- declare const schemaJournalCashReceiptGetAll: Joi.ObjectSchema<any>;
1944
- declare function modelJournalCashReceipt(data: TJournalCashReceipt): TJournalCashReceipt;
1945
-
1946
- declare function useJournalCashReceiptRepo(): {
1947
- createIndexes: () => Promise<void>;
1948
- add: (value: TJournalCashReceipt, session?: ClientSession) => Promise<ObjectId>;
1949
- getAll: (options: {
1950
- org: ObjectId | string;
1951
- search?: string;
1952
- page?: number;
1953
- limit?: number;
1954
- type: string;
1955
- status?: string;
1956
- }) => Promise<Record<string, any>>;
1957
- getById: (_id: string | ObjectId) => Promise<TJournalCashReceipt>;
1958
- updateById: (_id: string | ObjectId, options: Partial<TJournalCashReceipt>, session?: ClientSession) => Promise<string>;
1959
- deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
1960
- updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<string>;
1961
- };
1962
-
1963
- declare function useJournalCashReceiptService(): {
1964
- add: (entry: TJournalCashReceipt, lines: TJournalLine[]) => Promise<string>;
1965
- updateStatusById: (_id: string, status: TJournalCashReceiptStatus, user: string) => Promise<string>;
2042
+ declare function useJournalService(): {
2043
+ add: (entry: TJournal, lines: TJournalLine[]) => Promise<string>;
2044
+ updateStatusById: (_id: string, status: TJournalStatus, user: string) => Promise<string>;
2045
+ updateById: (id: string, entry: TJournal, lines: TJournalLine[], user: string) => Promise<string>;
1966
2046
  };
1967
2047
 
1968
- declare function useJournalCashReceiptController(): {
2048
+ declare function useJournalController(): {
1969
2049
  add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1970
2050
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1971
2051
  getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -1988,7 +2068,7 @@ declare function useJournalLineRepo(): {
1988
2068
  }) => Promise<Record<string, any>>;
1989
2069
  getById: (_id: string | ObjectId) => Promise<TJournalLine | null>;
1990
2070
  getByEntry: (journalEntry: string | ObjectId) => Promise<TJournalLine[]>;
1991
- updateById: (_id: string | ObjectId, options: Partial<TJournalLine>) => Promise<string>;
2071
+ updateById: (_id: string | ObjectId, options: Pick<TJournalLine, "account" | "accountName" | "debit" | "credit">, session?: ClientSession) => Promise<string>;
1992
2072
  deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
1993
2073
  updateStatusByJournal: (journalEntry: string | ObjectId, status: TJournalLineStatus, session?: ClientSession) => Promise<string>;
1994
2074
  };
@@ -2090,4 +2170,4 @@ declare const XENDIT_BASE_URL: string;
2090
2170
  declare const DOMAIN: string;
2091
2171
  declare const APP_ORG: string;
2092
2172
 
2093
- export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, APP_ORG, DEFAULT_JOB_STATUS_SETUP, DEFAULT_USER_EMAIL, DEFAULT_USER_FIRST_NAME, DEFAULT_USER_LAST_NAME, DEFAULT_USER_PASSWORD, DOMAIN, JournalCashReceiptStatuses, JournalGeneralStatuses, MAILER_EMAIL, MAILER_PASSWORD, MAILER_TRANSPORT_HOST, MAILER_TRANSPORT_PORT, MAILER_TRANSPORT_SECURE, MBuilding, MBuildingUnit, MFile, MONGO_DB, MONGO_URI, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PAYPAL_WEBHOOK_ID, PORT, PaypalWebhookHeaders, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REFRESH_TOKEN_EXPIRY, REFRESH_TOKEN_SECRET, SECRET_KEY, SPACES_ACCESS_KEY, SPACES_BUCKET, SPACES_ENDPOINT, SPACES_REGION, SPACES_SECRET_KEY, TApp, TBuilding, TBuildingUnit, TChartOfAccount, TChartOfAccountControlType, TChartOfAccountNormalBalance, TChartOfAccountStatus, TChartOfAccountType, TCounter, TCustomer, TFile, TJobApplication, TJobApplicationMetadata, TJobPost, TJobProfile, TJobProfileAward, TJobProfileCert, TJobProfileEdu, TJobProfileGroup, TJobProfileLang, TJobProfileMilitaryExp, TJobProfilePatent, TJobProfilePublication, TJobProfileSkill, TJobProfileWorkExp, TJobStatusSetup, TJobStatusTrans, TJobSummary, TJobSummaryMetadata, TJournalCashReceipt, TJournalCashReceiptStatus, TJournalGeneral, TJournalGeneralStatus, TJournalLine, TJournalLineStatus, TLedgerBill, TMember, TOption, TOrg, TPermission, TPermissionGroup, TPlan, TPromo, TRole, TSubscribe, TSubscription, TSubscriptionTransaction, TTax, TUser, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, chartOfAccountControlTypes, chartOfAccountNormalBalances, chartOfAccountStatuses, chartOfAccountTypes, currencies, customerStatuses, isDev, jobApplicationStatuses, journalLineStatuses, ledgerBillStatuses, ledgerBillTypes, modelApp, modelChartOfAccount, modelCustomer, modelJobApplication, modelJobPost, modelJobProfile, modelJobProfileCert, modelJobProfileEdu, modelJobProfileLang, modelJobProfileSkill, modelJobProfileWorkExp, modelJobStatusSetup, modelJobStatusTrans, modelJobSummary, modelJournalCashReceipt, modelJournalGeneral, modelJournalLine, modelLedgerBill, modelMember, modelOption, modelOrg, modelPermission, modelPermissionGroup, modelPlan, modelPromo, modelRole, modelSubscription, modelSubscriptionTransaction, modelTax, modelUser, modelVerification, schemaApp, schemaAppUpdate, schemaAward, schemaBuilding, schemaBuildingUnit, schemaCertification, schemaChartOfAccountBase, schemaChartOfAccountStd, schemaChartOfAccountUpdate, schemaCustomer, schemaCustomerUpdate, schemaEducation, schemaGroup, schemaInviteMember, schemaJobApplication, schemaJobPost, schemaJobPostUpdate, schemaJobProfile, schemaJobProfileAdditionalInfo, schemaJobProfileCert, schemaJobProfileCertDel, schemaJobProfileContactInfo, schemaJobProfileEdu, schemaJobProfileEduDel, schemaJobProfileLang, schemaJobProfileLangDel, schemaJobProfilePersonalInfo, schemaJobProfileSkill, schemaJobProfileSkillDel, schemaJobProfileSummary, schemaJobProfileWorkExp, schemaJobProfileWorkExpDel, schemaJobStatusSetup, schemaJobStatusSetupUpdate, schemaJobStatusTrans, schemaJobSummary, schemaJobSummaryInc, schemaJournalCashReceiptCtrl, schemaJournalCashReceiptGetAll, schemaJournalCashReceiptRepo, schemaJournalCashReceiptRepoUpdate, schemaJournalGeneralCtrl, schemaJournalGeneralGetAll, schemaJournalGeneralRepo, schemaJournalGeneralRepoUpdate, schemaJournalLineCtrl, schemaJournalLineRepo, schemaLanguage, schemaLedgerBill, schemaLedgerBillingSummary, schemaMember, schemaMemberRole, schemaMemberStatus, schemaMilitaryExp, schemaOption, schemaOrg, schemaOrgAdd, schemaOrgPilot, schemaOrgUpdate, schemaPatent, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaPlan, schemaPromo, schemaPublication, schemaRole, schemaRoleUpdate, schemaSkill, schemaSubscribe, schemaSubscription, schemaSubscriptionCompute, schemaSubscriptionPromoCode, schemaSubscriptionSeats, schemaSubscriptionTransaction, schemaSubscriptionUpdate, schemaTax, schemaTaxUpdate, schemaUpdateOptions, schemaUser, schemaVerification, schemaVerificationOrgInvite, schemaWorkExp, taxDirections, transactionSchema, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useChartOfAccountController, useChartOfAccountRepo, useCounterModel, useCounterRepo, useCustomerCtrl, useCustomerRepo, useFileController, useFileRepo, useFileService, useGitHubService, useJobApplicationController, useJobApplicationRepo, useJobPostController, useJobPostRepo, useJobPostService, useJobProfileCtrl, useJobProfileRepo, useJobStatusConfigController, useJobStatusConfigRepo, useJobSummaryCtrl, useJobSummaryRepo, useJobSummarySvc, useJournalCashReceiptController, useJournalCashReceiptRepo, useJournalCashReceiptService, useJournalGeneralController, useJournalGeneralRepo, useJournalGeneralService, useJournalLineController, useJournalLineRepo, useLedgerBillingController, useLedgerBillingRepo, useMemberController, useMemberRepo, useOptionCtrl, useOptionRepo, useOrgController, useOrgRepo, useOrgService, usePaypalService, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, usePlanController, usePlanRepo, usePlanService, usePromoController, usePromoRepo, usePromoUsageRepo, useRoleController, useRoleRepo, useRoleService, useSubscriptionController, useSubscriptionRepo, useSubscriptionService, useSubscriptionTransactionController, useSubscriptionTransactionRepo, useTaxController, useTaxRepo, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };
2173
+ export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, APP_ORG, DEFAULT_JOB_STATUS_SETUP, DEFAULT_USER_EMAIL, DEFAULT_USER_FIRST_NAME, DEFAULT_USER_LAST_NAME, DEFAULT_USER_PASSWORD, DOMAIN, JournalStatuses, MAILER_EMAIL, MAILER_PASSWORD, MAILER_TRANSPORT_HOST, MAILER_TRANSPORT_PORT, MAILER_TRANSPORT_SECURE, MBuilding, MBuildingUnit, MFile, MONGO_DB, MONGO_URI, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PAYPAL_WEBHOOK_ID, PORT, PaypalWebhookHeaders, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REFRESH_TOKEN_EXPIRY, REFRESH_TOKEN_SECRET, SECRET_KEY, SPACES_ACCESS_KEY, SPACES_BUCKET, SPACES_ENDPOINT, SPACES_REGION, SPACES_SECRET_KEY, TAccountBalance, TApp, TBuilding, TBuildingUnit, TBusinessProfile, TBusinessProfileTaxType, TChartOfAccount, TChartOfAccountControlType, TChartOfAccountNormalBalance, TChartOfAccountStatus, TChartOfAccountType, TCounter, TCustomer, TFile, TJobApplication, TJobApplicationMetadata, TJobPost, TJobProfile, TJobProfileAward, TJobProfileCert, TJobProfileEdu, TJobProfileGroup, TJobProfileLang, TJobProfileMilitaryExp, TJobProfilePatent, TJobProfilePublication, TJobProfileSkill, TJobProfileWorkExp, TJobStatusSetup, TJobStatusTrans, TJobSummary, TJobSummaryMetadata, TJournal, TJournalLine, TJournalLineStatus, TJournalStatus, TJournalType, TLedgerBill, TMember, TOption, TOrg, TPermission, TPermissionGroup, TPlan, TPromo, TRole, TSubscribe, TSubscription, TSubscriptionTransaction, TTax, TUser, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, chartOfAccountControlTypes, chartOfAccountNormalBalances, chartOfAccountStatuses, chartOfAccountTypes, currencies, customerStatuses, isDev, jobApplicationStatuses, journalLineStatuses, journalTypes, ledgerBillStatuses, ledgerBillTypes, modelAccountBalance, modelApp, modelBusinessProfile, modelChartOfAccount, modelCustomer, modelJobApplication, modelJobPost, modelJobProfile, modelJobProfileCert, modelJobProfileEdu, modelJobProfileLang, modelJobProfileSkill, modelJobProfileWorkExp, modelJobStatusSetup, modelJobStatusTrans, modelJobSummary, modelJournal, modelJournalLine, modelLedgerBill, modelMember, modelOption, modelOrg, modelPermission, modelPermissionGroup, modelPlan, modelPromo, modelRole, modelSubscription, modelSubscriptionTransaction, modelTax, modelUser, modelVerification, schemaAccountBalance, schemaApp, schemaAppUpdate, schemaAward, schemaBuilding, schemaBuildingUnit, schemaBusinessProfile, schemaBusinessProfileBusinessName, schemaBusinessProfileCurrentFiscalYear, schemaBusinessProfileFiscalYear, schemaBusinessProfileRDOCode, schemaBusinessProfileRegisteredAddress, schemaBusinessProfileTIN, schemaBusinessProfileTradeName, schemaCertification, schemaChartOfAccountBase, schemaChartOfAccountStd, schemaChartOfAccountUpdate, schemaCustomer, schemaCustomerUpdate, schemaEducation, schemaGroup, schemaInviteMember, schemaJobApplication, schemaJobPost, schemaJobPostUpdate, schemaJobProfile, schemaJobProfileAdditionalInfo, schemaJobProfileCert, schemaJobProfileCertDel, schemaJobProfileContactInfo, schemaJobProfileEdu, schemaJobProfileEduDel, schemaJobProfileLang, schemaJobProfileLangDel, schemaJobProfilePersonalInfo, schemaJobProfileSkill, schemaJobProfileSkillDel, schemaJobProfileSummary, schemaJobProfileWorkExp, schemaJobProfileWorkExpDel, schemaJobStatusSetup, schemaJobStatusSetupUpdate, schemaJobStatusTrans, schemaJobSummary, schemaJobSummaryInc, schemaJournalCtrl, schemaJournalCtrlUpdate, schemaJournalGetAll, schemaJournalLineBase, schemaJournalLineCtrl, schemaJournalLineCtrlUpdate, schemaJournalLineRepo, schemaJournalRepo, schemaJournalRepoUpdate, schemaLanguage, schemaLedgerBill, schemaLedgerBillingSummary, schemaMember, schemaMemberRole, schemaMemberStatus, schemaMilitaryExp, schemaOption, schemaOrg, schemaOrgAdd, schemaOrgPilot, schemaOrgUpdate, schemaPatent, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaPlan, schemaPromo, schemaPublication, schemaRole, schemaRoleUpdate, schemaSkill, schemaSubscribe, schemaSubscription, schemaSubscriptionCompute, schemaSubscriptionPromoCode, schemaSubscriptionSeats, schemaSubscriptionTransaction, schemaSubscriptionUpdate, schemaTax, schemaTaxUpdate, schemaUpdateOptions, schemaUser, schemaVerification, schemaVerificationOrgInvite, schemaWorkExp, taxDirections, taxTypes, transactionSchema, useAccountBalanceRepo, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useBusinessProfileCtrl, useBusinessProfileRepo, useChartOfAccountController, useChartOfAccountRepo, useCounterModel, useCounterRepo, useCustomerCtrl, useCustomerRepo, useFileController, useFileRepo, useFileService, useGitHubService, useJobApplicationController, useJobApplicationRepo, useJobPostController, useJobPostRepo, useJobPostService, useJobProfileCtrl, useJobProfileRepo, useJobStatusConfigController, useJobStatusConfigRepo, useJobSummaryCtrl, useJobSummaryRepo, useJobSummarySvc, useJournalController, useJournalLineController, useJournalLineRepo, useJournalRepo, useJournalService, useLedgerBillingController, useLedgerBillingRepo, useMemberController, useMemberRepo, useOptionCtrl, useOptionRepo, useOrgController, useOrgRepo, useOrgService, usePaypalService, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, usePlanController, usePlanRepo, usePlanService, usePromoController, usePromoRepo, usePromoUsageRepo, useRoleController, useRoleRepo, useRoleService, useSubscriptionController, useSubscriptionRepo, useSubscriptionService, useSubscriptionTransactionController, useSubscriptionTransactionRepo, useTaxController, useTaxRepo, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };