diff --git a/src/components/DynamicReportComponent.vue b/src/components/DynamicReportComponent.vue
index ffe025a..b71d18d 100644
--- a/src/components/DynamicReportComponent.vue
+++ b/src/components/DynamicReportComponent.vue
@@ -22,6 +22,8 @@
{{ report.title }}
+
+
diff --git a/src/display.ts b/src/display.ts
index f23ee36..de319ee 100644
--- a/src/display.ts
+++ b/src/display.ts
@@ -53,7 +53,7 @@ export function ppBracketed(quantity: number, link?: string): string {
if (link) {
// Put the space outside of the hyperlink so it is not underlined
- return '' + text + '' + space;
+ return '' + text + '' + space;
} else {
return text + space;
}
diff --git a/src/main.ts b/src/main.ts
index 8a64a16..8397aaf 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -33,6 +33,7 @@ async function initApp() {
{ path: '/balance-assertions', name: 'balance-assertions', component: () => import('./pages/BalanceAssertionsView.vue') },
{ path: '/balance-assertions/edit/:id', name: 'balance-assertions-edit', component: () => import('./pages/EditBalanceAssertionView.vue') },
{ path: '/balance-assertions/new', name: 'balance-assertions-new', component: () => import('./pages/NewBalanceAssertionView.vue') },
+ { path: '/balance-sheet', name: 'balance-sheet', component: () => import('./reports/BalanceSheetReport.vue') },
{ path: '/chart-of-accounts', name: 'chart-of-accounts', component: () => import('./pages/ChartOfAccountsView.vue') },
{ path: '/general-ledger', name: 'general-ledger', component: () => import('./pages/GeneralLedgerView.vue') },
{ path: '/income-statement', name: 'income-statement', component: () => import('./reports/IncomeStatementReport.vue') },
diff --git a/src/pages/HomeView.vue b/src/pages/HomeView.vue
index e35ca6b..96aa095 100644
--- a/src/pages/HomeView.vue
+++ b/src/pages/HomeView.vue
@@ -33,7 +33,7 @@
- General ledger
- Trial balance
-
+ - Balance sheet
- Income statement
diff --git a/src/reporting.ts b/src/reporting.ts
index 5feafcd..18fbb29 100644
--- a/src/reporting.ts
+++ b/src/reporting.ts
@@ -22,6 +22,7 @@ import { asCost } from './amounts.ts';
import { DT_FORMAT, JoinedTransactionPosting, StatementLine, Transaction, db, getAccountsForKind, joinedToTransactions, totalBalances, totalBalancesAtDate } from './db.ts';
import { ExtendedDatabase } from './dbutil.ts';
+import { BalanceSheetReport } from './reports/BalanceSheetReport.vue';
import { DrcrReport } from './reports/base.ts';
import TrialBalanceReport from './reports/TrialBalanceReport.ts';
import { IncomeStatementReport } from './reports/IncomeStatementReport.vue';
@@ -46,9 +47,9 @@ export enum ReportingStage {
//IncomeStatement = 600,
// Final balance sheet
- //BalanceSheet = 700,
+ BalanceSheet = 700,
- FINAL_STAGE = InterimIncomeStatement
+ FINAL_STAGE = BalanceSheet
}
export class ReportingWorkflow {
@@ -203,10 +204,20 @@ export class ReportingWorkflow {
// ---------------
// InterimIncomeStatement
+ let incomeStatementReport;
{
- const incomeStatementReport = new IncomeStatementReport();
+ incomeStatementReport = new IncomeStatementReport();
await incomeStatementReport.generate(balances);
- this.reportsForStage.set(ReportingStage.InterimIncomeStatement, [incomeStatementReport, new TrialBalanceReport(balances)]);
+ this.reportsForStage.set(ReportingStage.InterimIncomeStatement, [incomeStatementReport]);
+ }
+
+ // ------------
+ // BalanceSheet
+
+ {
+ const balanceSheetReport = new BalanceSheetReport();
+ await balanceSheetReport.generate(balances, incomeStatementReport);
+ this.reportsForStage.set(ReportingStage.BalanceSheet, [balanceSheetReport]);
}
}
@@ -218,11 +229,24 @@ export class ReportingWorkflow {
}
const report = reportsForTheStage.find((r) => r instanceof reportType);
- if (!report) {
- throw new Error('Report does not exist');
+ if (report) {
+ return report;
}
- return report;
+ // Recurse earlier stages
+ const stages = [...this.reportsForStage.keys()];
+ stages.reverse();
+ for (const earlierStage of stages) {
+ if (earlierStage >= stage) {
+ continue;
+ }
+ const report = this.reportsForStage.get(earlierStage)!.find((r) => r instanceof reportType);
+ if (report) {
+ return report;
+ }
+ }
+
+ throw new Error('Report does not exist at requested stage or any earlier stage');
}
getTransactionsAtStage(stage: ReportingStage): Transaction[] {
diff --git a/src/reports/BalanceSheetReport.vue b/src/reports/BalanceSheetReport.vue
new file mode 100644
index 0000000..21ef25c
--- /dev/null
+++ b/src/reports/BalanceSheetReport.vue
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Total assets do not equal total liabilities and equity. This may occur if not all accounts have been classified in the chart of accounts.
+
+
+
+
+
+
+
diff --git a/src/reports/base.ts b/src/reports/base.ts
index fde0487..a472750 100644
--- a/src/reports/base.ts
+++ b/src/reports/base.ts
@@ -71,6 +71,10 @@ export class DynamicReport implements DrcrReport {
entries.push(new Entry(
account,
negate ? -quantity : quantity,
+ null /* id */,
+ true /* visible */,
+ false /* autoHide */,
+ '/transactions/' + account
));
}
}
@@ -171,7 +175,7 @@ export class Subtotal extends Entry {
this.quantity = 0;
for (const entry of parent.entries) {
- if (entry instanceof Entry) {
+ if (entry instanceof Entry && entry !== this) {
this.quantity += entry.quantity;
}
}