@eeplatform/basic-edu 1.10.39 → 1.10.40
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/.github/workflows/publish.yml +7 -8
- package/CHANGELOG.md +6 -0
- package/CLAUDE.md +1 -169
- package/package.json +2 -2
|
@@ -17,23 +17,22 @@ jobs:
|
|
|
17
17
|
runs-on: ubuntu-latest
|
|
18
18
|
steps:
|
|
19
19
|
- uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
20
22
|
|
|
21
23
|
- uses: actions/setup-node@v4
|
|
22
24
|
with:
|
|
23
25
|
node-version: 20.x
|
|
24
|
-
cache: "yarn"
|
|
25
|
-
cache-dependency-path: yarn.lock
|
|
26
|
-
|
|
27
|
-
- run: yarn install --immutable # Install dependencies with immutable lockfile
|
|
26
|
+
cache: "yarn"
|
|
27
|
+
cache-dependency-path: yarn.lock
|
|
28
28
|
|
|
29
|
-
-
|
|
30
|
-
run: |
|
|
31
|
-
echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}' > ~/.npmrc
|
|
29
|
+
- run: yarn install --immutable
|
|
32
30
|
|
|
33
31
|
- name: Create Release Pull Request or Publish
|
|
34
32
|
id: changesets
|
|
35
33
|
uses: changesets/action@v1
|
|
36
34
|
with:
|
|
37
|
-
publish: yarn release
|
|
35
|
+
publish: yarn release
|
|
38
36
|
env:
|
|
39
37
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
38
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/CHANGELOG.md
CHANGED
package/CLAUDE.md
CHANGED
|
@@ -63,7 +63,7 @@ Multi-word resource names use dot notation in file names: `finance.journal.confi
|
|
|
63
63
|
|
|
64
64
|
## Error Handling
|
|
65
65
|
|
|
66
|
-
Always use the typed error classes from `@
|
|
66
|
+
Always use the typed error classes from `@eeplatform/nodejs-utils` — never throw a generic `new Error()`.
|
|
67
67
|
|
|
68
68
|
- `BadRequestError` — invalid input or a violated business rule
|
|
69
69
|
- `NotFoundError` — resource does not exist
|
|
@@ -104,171 +104,3 @@ Transactions belong in the service layer only — never in a controller or repos
|
|
|
104
104
|
- **No generic `Error` throws** — use the typed error classes above
|
|
105
105
|
- **No Zod** — validation is done with Joi throughout this module
|
|
106
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeplatform/basic-edu",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.10.
|
|
4
|
+
"version": "1.10.40",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@eeplatform/core": "^1.8.7",
|
|
23
|
-
"@eeplatform/nodejs-utils": "^1.2.
|
|
23
|
+
"@eeplatform/nodejs-utils": "^1.2.5",
|
|
24
24
|
"dotenv": "^16.4.5",
|
|
25
25
|
"express": "^4.21.2",
|
|
26
26
|
"handlebars": "^4.7.8",
|