1
2
3
4
5
6
7
8
9
10
11
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# =============================================================================
# Module: Accounting
# Entity: FinancialStatement
# Description: Generated financial statements (Balance Sheet, Income Statement)
# =============================================================================
# Financial statements provide a summary of the financial position and
# performance for a given period.
#
# Main Statements:
# 1. Balance Sheet (Neraca) - Assets = Liabilities + Equity
# 2. Income Statement (Laba Rugi) - Revenue - Expenses = Net Income
# 3. Cash Flow Statement - Operating, Investing, Financing activities
# 4. Trial Balance - Verify debits = credits
# =============================================================================
# =============================================================================
# Enums
# =============================================================================
enums:
- name: StatementType
description: "Type of financial statement"
variants:
- name: balance_sheet
description: "Balance Sheet (Neraca)"
default: true
- name: income_statement
description: "Income Statement (Laba Rugi)"
- name: cash_flow
description: "Cash Flow Statement"
- name: trial_balance
description: "Trial Balance"
- name: equity_statement
description: "Statement of Changes in Equity"
- name: StatementStatus
description: "Statement status"
variants:
- name: draft
description: "Draft"
default: true
- name: generated
description: "Generated"
- name: reviewed
description: "Reviewed"
- name: approved
description: "Approved"
- name: published
description: "Published"
- name: archived
description: "Archived"
# =============================================================================
# Models
# =============================================================================
models:
# Tenancy: none, by design (ADR-0029). Tenant-agnostic and reusable; a composing
# service's tenancy decorator owns org scoping for this table, including the
# org-scoped per-unit statement-number unique.
- name: FinancialStatement
collection: financial_statements
description: "Generated financial statement"
fields:
id:
type: uuid
attributes:
description: "Unique statement identifier"
# =======================================================================
# Statement Identification
# =======================================================================
statement_number:
type: string
attributes:
description: "Statement number (FS-TYPE-YYYYMMDD)"
statement_type:
type: StatementType
attributes:
description: "Type of financial statement"
name:
type: string
attributes:
description: "Statement name"
# =======================================================================
# Period Reference
# =======================================================================
fiscal_period_id:
type: uuid?
attributes:
description: "Fiscal period"
fiscal_year:
type: int
attributes:
description: "Fiscal year"
fiscal_month:
type: int?
attributes:
description: "Fiscal month"
# =======================================================================
# Date Range
# =======================================================================
as_of_date:
type: date
attributes:
description: "Statement as of date"
period_start:
type: date?
description: "Period start (for income statement)"
period_end:
type: date?
description: "Period end (for income statement)"
# =======================================================================
# Comparative
# =======================================================================
is_comparative:
type: bool
attributes:
description: "Includes comparative period"
comparative_period_id:
type: uuid?
attributes:
description: "Comparative period"
comparative_as_of_date:
type: date?
description: "Comparative as of date"
# =======================================================================
# Status
# =======================================================================
status:
type: StatementStatus
attributes:
description: "Statement status"
# =======================================================================
# Balance Sheet Fields
# =======================================================================
# Current Assets
total_current_assets:
type: decimal?
attributes:
description: "Total current assets"
# Non-Current Assets
total_non_current_assets:
type: decimal?
attributes:
description: "Total non-current assets"
# Total Assets
total_assets:
type: decimal?
attributes:
description: "Total assets"
# Current Liabilities
total_current_liabilities:
type: decimal?
attributes:
description: "Total current liabilities"
# Non-Current Liabilities
total_non_current_liabilities:
type: decimal?
attributes:
description: "Total non-current liabilities"
# Total Liabilities
total_liabilities:
type: decimal?
attributes:
description: "Total liabilities"
# Equity
total_equity:
type: decimal?
attributes:
description: "Total equity"
# Verification: Assets = Liabilities + Equity
balance_check:
type: bool
attributes:
description: "Balance sheet balances (A = L + E)"
balance_difference:
type: decimal?
attributes:
description: "Difference if not balanced"
# =======================================================================
# Income Statement Fields
# =======================================================================
# Revenue
total_revenue:
type: decimal?
attributes:
description: "Total revenue"
# Cost of Goods Sold
total_cogs:
type: decimal?
attributes:
description: "Total COGS/HPP"
# Gross Profit
gross_profit:
type: decimal?
attributes:
description: "Gross profit (Revenue - COGS)"
gross_profit_margin:
type: decimal?
attributes:
description: "Gross profit margin %"
# Operating Expenses
total_operating_expenses:
type: decimal?
attributes:
description: "Total operating expenses"
# Operating Income
operating_income:
type: decimal?
attributes:
description: "Operating income (Gross profit - Op expenses)"
operating_margin:
type: decimal?
attributes:
description: "Operating margin %"
# Other Income/Expenses
total_other_income:
type: decimal?
attributes:
description: "Total other income"
total_other_expenses:
type: decimal?
attributes:
description: "Total other expenses"
# Income Before Tax
income_before_tax:
type: decimal?
attributes:
description: "Income before tax"
# Tax Expense
tax_expense:
type: decimal?
attributes:
description: "Tax expense"
# Net Income
net_income:
type: decimal?
attributes:
description: "Net income"
net_profit_margin:
type: decimal?
attributes:
description: "Net profit margin %"
# =======================================================================
# Cash Flow Statement Fields
# =======================================================================
cash_from_operations:
type: decimal?
attributes:
description: "Cash from operating activities"
cash_from_investing:
type: decimal?
attributes:
description: "Cash from investing activities"
cash_from_financing:
type: decimal?
attributes:
description: "Cash from financing activities"
net_cash_change:
type: decimal?
attributes:
description: "Net change in cash"
beginning_cash:
type: decimal?
attributes:
description: "Beginning cash balance"
ending_cash:
type: decimal?
attributes:
description: "Ending cash balance"
# =======================================================================
# Trial Balance Fields
# =======================================================================
total_debits:
type: decimal?
attributes:
description: "Total debits (trial balance)"
total_credits:
type: decimal?
attributes:
description: "Total credits (trial balance)"
trial_balance_check:
type: bool
attributes:
description: "Trial balance balances"
# =======================================================================
# Detailed Line Items
# =======================================================================
line_items:
type: json
attributes:
description: "Detailed line items by account"
# =======================================================================
# Comparative Data
# =======================================================================
comparative_data:
type: json
attributes:
description: "Comparative period data"
variance_data:
type: json
attributes:
description: "Variance analysis"
# =======================================================================
# Notes
# =======================================================================
notes:
type: json
attributes:
description: "Statement notes/footnotes"
management_notes:
type: string?
attributes:
description: "Management discussion"
# =======================================================================
# Generation
# =======================================================================
generated_at:
type: datetime?
description: "Generation timestamp"
generated_by:
type: uuid?
description: "Generated by user"
generation_parameters:
type: json
attributes:
description: "Parameters used for generation"
# =======================================================================
# Review/Approval
# =======================================================================
reviewed_at:
type: datetime?
description: "Review timestamp"
reviewed_by:
type: uuid?
description: "Reviewed by user"
approved_at:
type: datetime?
description: "Approval timestamp"
approved_by:
type: uuid?
description: "Approved by user"
published_at:
type: datetime?
description: "Published timestamp"
# =======================================================================
# Export
# =======================================================================
pdf_url:
type: string?
attributes:
description: "PDF export URL"
excel_url:
type: string?
attributes:
description: "Excel export URL"
# =======================================================================
# Metadata
# =======================================================================
currency:
type: string
attributes:
description: "Statement currency"
metadata:
type: Metadata
attributes:
description: "Audit metadata (created_at, updated_at, deleted_at, created_by, updated_by, deleted_by)"
relations:
generated_by_user:
type: sapiens.User?
attributes:
description: "Generated by user"
reviewed_by_user:
type: sapiens.User?
attributes:
description: "Reviewed by user"
approved_by_user:
type: sapiens.User?
attributes:
description: "Approved by user"
indexes:
# No tenancy indexes (ADR-0029): the module is tenant-agnostic. The per-unit
# statement-number unique — one live number per org unit among live rows — is
# installed by the composing service's tenancy decorator (org_unit_id-leading),
# not declared here.