From 0c9d9612725a26ba93e9b633ff651a8a278c8a07 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Sun, 11 May 2025 17:26:55 +0200 Subject: [PATCH] fix: financial reports i18n --- packages/server/src/i18n/en/ability.json | 41 ++++++++++++++++++ packages/server/src/i18n/en/account.json | 17 ++++++++ .../server/src/i18n/en/balance_sheet.json | 21 ++++++++++ .../src/i18n/en/cash_flow_statement.json | 13 ++++++ packages/server/src/i18n/en/expense.json | 18 ++++++++ .../server/src/i18n/en/financial_sheet.json | 9 ++++ packages/server/src/i18n/en/invoice.json | 42 +++++++++++++++++++ packages/server/src/i18n/en/item.json | 22 ++++++++++ .../server/src/i18n/en/item_category.json | 6 +++ .../server/src/i18n/en/manual_journal.json | 12 ++++++ .../server/src/i18n/en/profit_loss_sheet.json | 16 +++++++ packages/server/src/i18n/en/receipt.json | 14 +++++++ packages/server/src/i18n/en/role.json | 6 +++ packages/server/src/i18n/en/test.json | 12 +++++- .../src/i18n/en/transactions_locking.json | 9 ++++ .../modules/CashFlowStatement/CashFlow.ts | 9 ++-- .../CashFlowStatement/CashFlowService.ts | 4 +- .../modules/CashFlowStatement/schema.ts | 22 +++++----- .../modules/SalesByItems/utils.ts | 2 + 19 files changed, 277 insertions(+), 18 deletions(-) create mode 100644 packages/server/src/i18n/en/ability.json create mode 100644 packages/server/src/i18n/en/account.json create mode 100644 packages/server/src/i18n/en/balance_sheet.json create mode 100644 packages/server/src/i18n/en/cash_flow_statement.json create mode 100644 packages/server/src/i18n/en/expense.json create mode 100644 packages/server/src/i18n/en/financial_sheet.json create mode 100644 packages/server/src/i18n/en/invoice.json create mode 100644 packages/server/src/i18n/en/item.json create mode 100644 packages/server/src/i18n/en/item_category.json create mode 100644 packages/server/src/i18n/en/manual_journal.json create mode 100644 packages/server/src/i18n/en/profit_loss_sheet.json create mode 100644 packages/server/src/i18n/en/receipt.json create mode 100644 packages/server/src/i18n/en/role.json create mode 100644 packages/server/src/i18n/en/transactions_locking.json diff --git a/packages/server/src/i18n/en/ability.json b/packages/server/src/i18n/en/ability.json new file mode 100644 index 000000000..495e1a624 --- /dev/null +++ b/packages/server/src/i18n/en/ability.json @@ -0,0 +1,41 @@ +{ + "accounts": "Chart of accounts", + "manual_journal": "Manual journals", + "cashflow": "Cash flow", + "inventory_adjustment": "Inventory adjustments", + "customers": "Customers", + "vendors": "vendors", + "sale_estimates": "Sale estimates", + "sale_invoices": "Sale invoices", + "sale_receipts": "Sale receipts", + "expenses": "Expenses", + "payments_receive": "Payments receive", + "purchase_invoices": "Purchase invoices", + "all_reports": "All reports", + "payments_made": "Payments made", + "preferences": "Preferences", + "mutate_system_preferences": "Mutate the system preferences.", + + "items": "Items", + "view": "View", + "create": "Create", + "edit": "Edit", + "delete": "Delete", + "transactions_locking": "Ability to transactions locking.", + + "balance_sheet_report": "Balance sheet.", + "profit_loss_sheet": "Profit/loss sheet", + "journal": "Journal", + "general_ledger": "General ledger", + "cashflow_report": "Cashflow", + "AR_aging_summary_report": "A/R aging summary", + "AP_aging_summary_report": "A/P aging summary", + "purchases_by_items": "Purchases by items", + "sales_by_items_report": "Sales by items", + "customers_transactions_report": "Customers transactions", + "vendors_transactions_report": "Vendors transactions", + "customers_summary_balance_report": "Customers summary balance", + "vendors_summary_balance_report": "Vendors summary balance", + "inventory_valuation_summary": "Inventory valuation summary", + "inventory_items_details": "Inventory items details" +} \ No newline at end of file diff --git a/packages/server/src/i18n/en/account.json b/packages/server/src/i18n/en/account.json new file mode 100644 index 000000000..ccd7d0f00 --- /dev/null +++ b/packages/server/src/i18n/en/account.json @@ -0,0 +1,17 @@ +{ + "field.name": "Account name", + "field.description": "Description", + "field.slug": "Account slug", + "field.code": "Account code", + "field.root_type": "Root type", + "field.normal": "Account normal", + "field.normal.credit": "Credit", + "field.normal.debit": "Debit", + "field.type": "Type", + "field.active": "Active", + "field.currency": "Currency", + "field.balance": "Balance", + "field.bank_balance": "Bank Balance", + "field.parent_account": "Parent Account", + "field.created_at": "Created at" +} diff --git a/packages/server/src/i18n/en/balance_sheet.json b/packages/server/src/i18n/en/balance_sheet.json new file mode 100644 index 000000000..e8fc2ecea --- /dev/null +++ b/packages/server/src/i18n/en/balance_sheet.json @@ -0,0 +1,21 @@ +{ + "assets": "Assets", + "current_asset": "Current Asset", + "cash_and_cash_equivalents": "Cash and cash equivalents", + "accounts_receivable": "Accounts Receivable", + "inventory": "Inventory", + "other_current_assets": "Other current assets", + "fixed_asset": "Fixed Asset", + "non_current_assets": "Non-Current Assets", + "liabilities_and_equity": "Liabilities and Equity", + "liabilities": "Liabilities", + "current_liabilties": "Current Liabilties", + "long_term_liabilities": "Long-Term Liabilities", + "non_current_liabilities": "Non-Current Liabilities", + "equity": "Equity", + "net_income": "Net Income", + "account_name": "Account name", + "total": "Total", + "percentage_of_column": "% of Column", + "percentage_of_row": "% of Row" +} diff --git a/packages/server/src/i18n/en/cash_flow_statement.json b/packages/server/src/i18n/en/cash_flow_statement.json new file mode 100644 index 000000000..e8b772618 --- /dev/null +++ b/packages/server/src/i18n/en/cash_flow_statement.json @@ -0,0 +1,13 @@ +{ + "operating_activities": "OPERATING ACTIVITIES", + "net_income": "Net income", + "operating_accounts": "Adjustments net income by operating activities.", + "net_cash_operating": "Net cash provided by operating activities", + "investment_activities": "INVESTMENT ACTIVITIES", + "net_cash_investing": "Net cash provided by investing activities", + "financial_activities": "FINANCIAL ACTIVITIES", + "net_cash_financing": "Net cash provided by financing activities", + "cash_beginning_period": "Cash at beginning of period", + "net_cash_increase": "NET CASH INCREASE FOR PERIOD", + "cash_end_period": "CASH AT END OF PERIOD" +} diff --git a/packages/server/src/i18n/en/expense.json b/packages/server/src/i18n/en/expense.json new file mode 100644 index 000000000..84dbba51c --- /dev/null +++ b/packages/server/src/i18n/en/expense.json @@ -0,0 +1,18 @@ +{ + "field.payment_date": "Payment Date", + "field.payment_account": "Payment Account", + "field.amount": "Amount", + "field.currency_code": "Currency", + "field.exchange_rate": "Exchange Rate", + "field.reference_no": "Reference No.", + "field.description": "Description", + "field.line_description": "Line Description", + "field.published": "Published", + "field.categories": "Categories", + "field.expense_account": "Expense Account", + "field.publish": "Publish", + "field.status": "Status", + "field.status.draft": "Draft", + "field.status.published": "Published", + "field.created_at": "Created at" +} diff --git a/packages/server/src/i18n/en/financial_sheet.json b/packages/server/src/i18n/en/financial_sheet.json new file mode 100644 index 000000000..5e42ecaaa --- /dev/null +++ b/packages/server/src/i18n/en/financial_sheet.json @@ -0,0 +1,9 @@ +{ + "previoud_period_date": "{{date}} (PP)", + "fianncial_sheet.previous_period_change": "Change (PP)", + "previous_period_percentage": "% Change (PP)", + "previous_year_date": "{{date}} (PY)", + "previous_year_change": "Change (PY)", + "previous_year_percentage": "% Change (PY)", + "total_row": "Total {{value}}" +} diff --git a/packages/server/src/i18n/en/invoice.json b/packages/server/src/i18n/en/invoice.json new file mode 100644 index 000000000..09b2a0f4a --- /dev/null +++ b/packages/server/src/i18n/en/invoice.json @@ -0,0 +1,42 @@ +{ + "paper.invoice": "Invoice", + "paper.invoice_amount": "Invoice amount", + "paper.due_amount": "Due amount", + "paper.billed_to": "Billed to", + "paper.invoice_date": "Invoice date", + "paper.invoice_number": "Invoice No.", + "paper.due_date": "Due date", + "paper.conditions_title": "Conditions & terms", + "paper.notes_title": "Notes", + "paper.total": "Total", + "paper.subtotal": "Subtotal", + "paper.payment_amount": "Payment Amount", + "paper.balance_due": "Balance Due", + + "field.customer": "Customer", + "field.invoice_date": "Invoice date", + "field.due_date": "Due date", + "field.invoice_no": "Invoice No.", + "field.reference_no": "Reference No.", + "field.invoice_message": "Invoice message", + "field.terms_conditions": "Terms & conditions", + "field.amount": "Amount", + "field.exchange_rate": "Exchange Rate", + "field.payment_amount": "Payment amount", + "field.due_amount": "Due amount", + "field.delivered": "Delivered", + "field.item_name": "Item Name", + "field.rate": "Rate", + "field.quantity": "Quantity", + "field.description": "Description", + "field.status": "Status", + "field.status.paid": "Paid", + "field.status.partially-paid": "Partially paid", + "field.status.overdue": "Overdue", + "field.status.unpaid": "Unpaid", + "field.status.delivered": "Delivered", + "field.status.draft": "Draft", + "field.created_at": "Created at", + "field.currency": "Currency", + "field.entries": "Entries" +} diff --git a/packages/server/src/i18n/en/item.json b/packages/server/src/i18n/en/item.json new file mode 100644 index 000000000..d7ee3cba5 --- /dev/null +++ b/packages/server/src/i18n/en/item.json @@ -0,0 +1,22 @@ +{ + "field.type": "Item Type", + "field.type.inventory": "Inventory", + "field.type.service": "Service", + "field.type.non-inventory": "Non Inventory", + "field.name": "Item Name", + "field.code": "Item Code", + "field.sellable": "Sellable", + "field.purchasable": "Purchasable", + "field.cost_price": "Cost Price", + "field.sell_price": "Sell Price", + "field.cost_account": "Cost Account", + "field.sell_account": "Sell Account", + "field.sell_description": "Sell Description", + "field.inventory_account": "Inventory Account", + "field.purchase_description": "Purchase Description", + "field.quantity_on_hand": "Quantity on Hand", + "field.note": "Note", + "field.category": "Category", + "field.active": "Active", + "field.created_at": "Created At" +} diff --git a/packages/server/src/i18n/en/item_category.json b/packages/server/src/i18n/en/item_category.json new file mode 100644 index 000000000..fc11f51b6 --- /dev/null +++ b/packages/server/src/i18n/en/item_category.json @@ -0,0 +1,6 @@ +{ + "field.name": "Name", + "field.description": "Description", + "field.count": "Count", + "field.created_at": "Created at" +} diff --git a/packages/server/src/i18n/en/manual_journal.json b/packages/server/src/i18n/en/manual_journal.json new file mode 100644 index 000000000..6df959081 --- /dev/null +++ b/packages/server/src/i18n/en/manual_journal.json @@ -0,0 +1,12 @@ +{ + "field.date": "Date", + "field.journal_number": "Journal No.", + "field.reference": "Reference No.", + "field.journal_type": "Journal Type", + "field.amount": "Amount", + "field.description": "Description", + "field.currency": "Currency", + "field.exchange_rate": "Exchange Rate", + "field.status": "Status", + "field.created_at": "Created at" +} diff --git a/packages/server/src/i18n/en/profit_loss_sheet.json b/packages/server/src/i18n/en/profit_loss_sheet.json new file mode 100644 index 000000000..bb5383a53 --- /dev/null +++ b/packages/server/src/i18n/en/profit_loss_sheet.json @@ -0,0 +1,16 @@ +{ + "income": "Income", + "cost_of_sales": "Cost of sales", + "gross_profit": "GROSS PROFIT", + "expenses": "Expenses", + "net_operating_income": "NET OPERATING INCOME", + "other_income": "Other income", + "other_expenses": "Other expenses", + "net_income": "NET INCOME", + "account_name": "Account name", + "total": "Total", + "percentage_of_income": "% of Income", + "percentage_of_expenses": "% of Expenses", + "percentage_of_column": "% of Column", + "percentage_of_row": "% of Row" +} diff --git a/packages/server/src/i18n/en/receipt.json b/packages/server/src/i18n/en/receipt.json new file mode 100644 index 000000000..3ad84d0b9 --- /dev/null +++ b/packages/server/src/i18n/en/receipt.json @@ -0,0 +1,14 @@ +{ + "paper.receipt": "Receipt", + "paper.billed_to": "Billed to", + "paper.receipt_date": "Receipt date", + "paper.receipt_number": "Receipt number", + "paper.expiration_date": "Expiration date", + "paper.conditions_title": "Conditions & terms", + "paper.notes": "Notes", + "paper.statement": "Statement", + "paper.receipt_amount": "Receipt amount", + "paper.total": "Total", + "paper.balance_due": "Balance Due", + "paper.payment_amount": "Payment Amount" +} \ No newline at end of file diff --git a/packages/server/src/i18n/en/role.json b/packages/server/src/i18n/en/role.json new file mode 100644 index 000000000..f72dce017 --- /dev/null +++ b/packages/server/src/i18n/en/role.json @@ -0,0 +1,6 @@ +{ + "admin.name": "Admin", + "admin.desc": "Unrestricted access to all modules.", + "staff.name": "Staff", + "staff.desc": "Access to all modules except reports, settings and accountant." +} \ No newline at end of file diff --git a/packages/server/src/i18n/en/test.json b/packages/server/src/i18n/en/test.json index 4936b38ec..e5e09db59 100644 --- a/packages/server/src/i18n/en/test.json +++ b/packages/server/src/i18n/en/test.json @@ -17,5 +17,15 @@ "other": "Every {count} days", "zero": "Never" }, - "nested": "We go shopping: $t(test.day_interval, {{\"count\": {count} }})" + "nested": "We go shopping: $t(test.day_interval, {{\"count\": {count} }})", + + "financial_sheet.previoud_period_date": "{{date}} (PP)", + "fianncial_sheet.previous_period_change": "Change (PP)", + "financial_sheet.previous_period_percentage": "% Change (PP)", + + "financial_sheet.previous_year_date": "{{date}} (PY)", + "financial_sheet.previous_year_change": "Change (PY)", + "financial_sheet.previous_year_percentage": "% Change (PY)", + "financial_sheet.total_row": "Total {{value}}" } + diff --git a/packages/server/src/i18n/en/transactions_locking.json b/packages/server/src/i18n/en/transactions_locking.json new file mode 100644 index 000000000..58285736f --- /dev/null +++ b/packages/server/src/i18n/en/transactions_locking.json @@ -0,0 +1,9 @@ +{ + "module.sales.label": "Sales", + "module.purchases.label": "Purchases", + "module.financial.label": "Financial", + "module.all_transactions": "All transactions", + "module.sales.desc": "Sale invoices, Receipts, credit notes, customers payment receive and customers opening balances.", + "module.purchases.desc": "Purchase invoices, vendors payments, vendor credit notes and vendors opening balances.", + "module.financial.desc": "Manual journal, expenses and inventory adjustments." +} \ No newline at end of file diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlow.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlow.ts index 336e6650e..f4f4e2619 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlow.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlow.ts @@ -83,7 +83,6 @@ export class CashFlowStatement extends R.pipe( this.initDateRangeCollection(); } - // -------------------------------------------- // # NET INCOME NODE // -------------------------------------------- @@ -228,11 +227,13 @@ export class CashFlowStatement extends R.pipe( const accountsTotal = this.getAccountsMetaTotal(accounts); const total = this.getTotalAmountMeta(accountsTotal); + console.log(sectionSchema.label, 'label'); + const node = { sectionType: ICashFlowStatementSectionType.ACCOUNTS, id: sectionSchema.id, - label: this.i18n.t(sectionSchema.label), - footerLabel: this.i18n.t(sectionSchema.footerLabel), + label: sectionSchema.label, + footerLabel: sectionSchema.footerLabel, children: accounts, total, }; @@ -254,7 +255,7 @@ export class CashFlowStatement extends R.pipe( (type: string, section: ICashFlowSchemaSection): boolean => { return type === section.sectionType; }, -); + ); // -------------------------------------------- // # AGGREGATE NODE diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowService.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowService.ts index a4c515457..6131f3f75 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowService.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowService.ts @@ -1,17 +1,17 @@ +import { Injectable } from '@nestjs/common'; import { ModelObject } from 'objection'; import * as R from 'ramda'; +import { I18nService } from 'nestjs-i18n'; import { ICashFlowStatementQuery, ICashFlowStatementDOO, } from './Cashflow.types'; import { CashFlowStatement } from './CashFlow'; import { CashflowSheetMeta } from './CashflowSheetMeta'; -import { Injectable } from '@nestjs/common'; import { CashFlowRepository } from './CashFlowRepository'; import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service'; import { Ledger } from '@/modules/Ledger/Ledger'; import { AccountTransaction } from '@/modules/Accounts/models/AccountTransaction.model'; -import { I18nService } from 'nestjs-i18n'; import { getDefaultCashflowQuery } from './constants'; @Injectable() diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/schema.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/schema.ts index 67be33743..4bd25641d 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/schema.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/schema.ts @@ -8,17 +8,17 @@ import { export const CASH_FLOW_SCHEMA = [ { id: CASH_FLOW_SECTION_ID.OPERATING, - label: 'OPERATING ACTIVITIES', + label: 'cash_flow_statement.operating_activities', sectionType: ICashFlowStatementSectionType.AGGREGATE, children: [ { id: CASH_FLOW_SECTION_ID.NET_INCOME, - label: 'Net income', + label: 'cash_flow_statement.net_income', sectionType: ICashFlowStatementSectionType.NET_INCOME, }, { id: CASH_FLOW_SECTION_ID.OPERATING_ACCOUNTS, - label: 'Adjustments net income by operating activities.', + label: 'cash_flow_statement.operating_accounts', sectionType: ICashFlowStatementSectionType.ACCOUNTS, accountsRelations: [ { type: ACCOUNT_TYPE.ACCOUNTS_RECEIVABLE, direction: 'mines' }, @@ -34,29 +34,29 @@ export const CASH_FLOW_SCHEMA = [ showAlways: true, }, ], - footerLabel: 'Net cash provided by operating activities', + footerLabel: 'cash_flow_statement.net_cash_operating', }, { id: CASH_FLOW_SECTION_ID.INVESTMENT, sectionType: ICashFlowStatementSectionType.ACCOUNTS, - label: 'INVESTMENT ACTIVITIES', + label: 'cash_flow_statement.investment_activities', accountsRelations: [{ type: ACCOUNT_TYPE.FIXED_ASSET, direction: 'mines' }], - footerLabel: 'Net cash provided by investing activities', + footerLabel: 'cash_flow_statement.net_cash_investing', }, { id: CASH_FLOW_SECTION_ID.FINANCIAL, - label: 'FINANCIAL ACTIVITIES', + label: 'cash_flow_statement.financial_activities', sectionType: ICashFlowStatementSectionType.ACCOUNTS, accountsRelations: [ { type: ACCOUNT_TYPE.LOGN_TERM_LIABILITY, direction: 'plus' }, { type: ACCOUNT_TYPE.EQUITY, direction: 'plus' }, ], - footerLabel: 'Net cash provided by financing activities', + footerLabel: 'cash_flow_statement.net_cash_financing', }, { id: CASH_FLOW_SECTION_ID.CASH_BEGINNING_PERIOD, sectionType: ICashFlowStatementSectionType.CASH_AT_BEGINNING, - label: 'Cash at beginning of period', + label: 'cash_flow_statement.cash_beginning_period', accountsRelations: [ { type: ACCOUNT_TYPE.CASH, direction: 'plus' }, { type: ACCOUNT_TYPE.BANK, direction: 'plus' }, @@ -66,11 +66,11 @@ export const CASH_FLOW_SCHEMA = [ id: CASH_FLOW_SECTION_ID.NET_CASH_INCREASE, sectionType: ICashFlowStatementSectionType.TOTAL, equation: 'OPERATING + INVESTMENT + FINANCIAL', - label: 'NET CASH INCREASE FOR PERIOD', + label: 'cash_flow_statement.net_cash_increase', }, { id: CASH_FLOW_SECTION_ID.CASH_END_PERIOD, - label: 'CASH AT END OF PERIOD', + label: 'cash_flow_statement.cash_end_period', sectionType: ICashFlowStatementSectionType.TOTAL, equation: 'NET_CASH_INCREASE + CASH_BEGINNING_PERIOD', }, diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/utils.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/utils.ts index b041c5d27..d1c91b0e4 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/utils.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/utils.ts @@ -1,3 +1,5 @@ +import * as moment from 'moment'; + export const getSalesByItemsDefaultQuery = () => { return { fromDate: moment().startOf('month').format('YYYY-MM-DD'),