backbone-accounting 0.18.2

GL, journals, ledger, reconciliation (extracted from bersihir)
Documentation
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: ["@id", "@default(uuid)"]
        description: "Unique statement identifier"

      # =======================================================================
      # Statement Identification
      # =======================================================================
      statement_number:
        type: string
        attributes: ["@required", "@max(30)"]
        description: "Statement number (FS-TYPE-YYYYMMDD)"

      statement_type:
        type: StatementType
        attributes: ["@required"]
        description: "Type of financial statement"

      name:
        type: string
        attributes: ["@required", "@max(100)"]
        description: "Statement name"

      # =======================================================================
      # Period Reference
      # =======================================================================
      fiscal_period_id:
        type: uuid?
        attributes: ["@foreign_key(FiscalPeriod.id)"]
        description: "Fiscal period"

      fiscal_year:
        type: int
        attributes: ["@required", "@range(2020, 2100)"]
        description: "Fiscal year"

      fiscal_month:
        type: int?
        attributes: ["@range(1, 12)"]
        description: "Fiscal month"

      # =======================================================================
      # Date Range
      # =======================================================================
      as_of_date:
        type: date
        attributes: ["@required"]
        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: ["@default(false)"]
        description: "Includes comparative period"

      comparative_period_id:
        type: uuid?
        attributes: ["@foreign_key(FiscalPeriod.id)"]
        description: "Comparative period"

      comparative_as_of_date:
        type: date?
        description: "Comparative as of date"

      # =======================================================================
      # Status
      # =======================================================================
      status:
        type: StatementStatus
        attributes: ["@default(draft)"]
        description: "Statement status"

      # =======================================================================
      # Balance Sheet Fields
      # =======================================================================
      # Current Assets
      total_current_assets:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total current assets"

      # Non-Current Assets
      total_non_current_assets:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total non-current assets"

      # Total Assets
      total_assets:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total assets"

      # Current Liabilities
      total_current_liabilities:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total current liabilities"

      # Non-Current Liabilities
      total_non_current_liabilities:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total non-current liabilities"

      # Total Liabilities
      total_liabilities:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total liabilities"

      # Equity
      total_equity:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total equity"

      # Verification: Assets = Liabilities + Equity
      balance_check:
        type: bool
        attributes: ["@default(false)"]
        description: "Balance sheet balances (A = L + E)"

      balance_difference:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Difference if not balanced"

      # =======================================================================
      # Income Statement Fields
      # =======================================================================
      # Revenue
      total_revenue:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total revenue"

      # Cost of Goods Sold
      total_cogs:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total COGS/HPP"

      # Gross Profit
      gross_profit:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Gross profit (Revenue - COGS)"

      gross_profit_margin:
        type: decimal?
        attributes: ["@precision(5,2)"]
        description: "Gross profit margin %"

      # Operating Expenses
      total_operating_expenses:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total operating expenses"

      # Operating Income
      operating_income:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Operating income (Gross profit - Op expenses)"

      operating_margin:
        type: decimal?
        attributes: ["@precision(5,2)"]
        description: "Operating margin %"

      # Other Income/Expenses
      total_other_income:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total other income"

      total_other_expenses:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total other expenses"

      # Income Before Tax
      income_before_tax:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Income before tax"

      # Tax Expense
      tax_expense:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Tax expense"

      # Net Income
      net_income:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Net income"

      net_profit_margin:
        type: decimal?
        attributes: ["@precision(5,2)"]
        description: "Net profit margin %"

      # =======================================================================
      # Cash Flow Statement Fields
      # =======================================================================
      cash_from_operations:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Cash from operating activities"

      cash_from_investing:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Cash from investing activities"

      cash_from_financing:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Cash from financing activities"

      net_cash_change:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Net change in cash"

      beginning_cash:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Beginning cash balance"

      ending_cash:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Ending cash balance"

      # =======================================================================
      # Trial Balance Fields
      # =======================================================================
      total_debits:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total debits (trial balance)"

      total_credits:
        type: decimal?
        attributes: ["@precision(18,2)"]
        description: "Total credits (trial balance)"

      trial_balance_check:
        type: bool
        attributes: ["@default(false)"]
        description: "Trial balance balances"

      # =======================================================================
      # Detailed Line Items
      # =======================================================================
      line_items:
        type: json
        attributes: ["@default('[]')"]
        description: "Detailed line items by account"

      # =======================================================================
      # Comparative Data
      # =======================================================================
      comparative_data:
        type: json
        attributes: ["@default('{}')"]
        description: "Comparative period data"

      variance_data:
        type: json
        attributes: ["@default('{}')"]
        description: "Variance analysis"

      # =======================================================================
      # Notes
      # =======================================================================
      notes:
        type: json
        attributes: ["@default('[]')"]
        description: "Statement notes/footnotes"

      management_notes:
        type: string?
        attributes: ["@max(2000)"]
        description: "Management discussion"

      # =======================================================================
      # Generation
      # =======================================================================
      generated_at:
        type: datetime?
        description: "Generation timestamp"

      generated_by:
        type: uuid?
        description: "Generated by user"

      generation_parameters:
        type: json
        attributes: ["@default('{}')"]
        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: ["@max(500)"]
        description: "PDF export URL"

      excel_url:
        type: string?
        attributes: ["@max(500)"]
        description: "Excel export URL"

      # =======================================================================
      # Metadata
      # =======================================================================
      currency:
        type: string
        attributes: ["@default('IDR')", "@length(3)"]
        description: "Statement currency"

      metadata:
        type: Metadata
        attributes: ["@audit_metadata"]
        description: "Audit metadata (created_at, updated_at, deleted_at, created_by, updated_by, deleted_by)"

    relations:
      generated_by_user:
        type: sapiens.User?
        attributes: ["@one", "@foreign_key(generated_by)"]
        description: "Generated by user"

      reviewed_by_user:
        type: sapiens.User?
        attributes: ["@one", "@foreign_key(reviewed_by)"]
        description: "Reviewed by user"

      approved_by_user:
        type: sapiens.User?
        attributes: ["@one", "@foreign_key(approved_by)"]
        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.