diff --git a/packages/server/src/i18n/en/transaction_type.json b/packages/server/src/i18n/en/transaction_type.json index 5bd909d21..638060ec9 100644 --- a/packages/server/src/i18n/en/transaction_type.json +++ b/packages/server/src/i18n/en/transaction_type.json @@ -20,5 +20,6 @@ "vendor_credit": "Vendor Credit", "refund_credit_note": "Refund Credit Note", "refund_vendor_credit": "Refund Vendor Credit", - "landed_cost": "Landed Cost" + "landed_cost": "Landed Cost", + "payment_made": "Payment made" } \ No newline at end of file diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.controller.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.controller.ts index 883b1ca07..a1b7cf8a2 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.controller.ts @@ -9,14 +9,19 @@ import { ApiTags, } from '@nestjs/swagger'; import { JournalSheetQueryDto } from './JournalSheetQuery.dto'; +import { JournalSheetResponseExample } from './JournalSheet.swagger'; @Controller('/reports/journal') @ApiTags('Reports') export class JournalSheetController { constructor(private readonly journalSheetApp: JournalSheetApplication) {} - @Get('/') - @ApiResponse({ status: 200, description: 'Journal report' }) + @Get() + @ApiResponse({ + status: 200, + description: 'Journal report', + example: JournalSheetResponseExample, + }) @ApiOperation({ summary: 'Journal report' }) @ApiProduces( AcceptType.ApplicationJson, diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.swagger.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.swagger.ts new file mode 100644 index 000000000..7ae007c94 --- /dev/null +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.swagger.ts @@ -0,0 +1,280 @@ +export const JournalSheetResponseExample = { + query: { + from_date: '2025-06-01', + to_date: '2025-06-21', + from_range: null, + to_range: null, + accounts_ids: [], + number_format: { + no_cents: false, + divide_on1000: false, + }, + }, + data: [ + { + date: '2025-05-24T22:00:00.000Z', + date_formatted: '2025 May 25', + transaction_type: 'Expense', + reference_id: 1000, + reference_type_formatted: 'Expense', + entries: [ + { + index: 1, + note: null, + account_name: 'Prepaid Expenses', + account_code: '100010', + transaction_number: null, + formatted_credit: '123,123.00', + formatted_debit: '', + credit: 123123, + debit: 0, + }, + { + index: 2, + note: '', + account_name: 'Exchange Gain or Loss', + account_code: '40005', + transaction_number: null, + formatted_credit: '', + formatted_debit: '123,123.00', + credit: 0, + debit: 123123, + }, + ], + credit: 123123, + debit: 123123, + formatted_credit: '$123,123.00', + formatted_debit: '$123,123.00', + }, + { + date: '2025-06-09T22:00:00.000Z', + date_formatted: '2025 Jun 10', + transaction_type: 'BillPayment', + reference_id: 3, + reference_type_formatted: 'BillPayment', + entries: [ + { + index: 1, + note: null, + contact_name: 'business', + contact_type: 'customer', + account_name: 'Accounts Payable (A/P)', + account_code: '20001', + transaction_number: '', + formatted_credit: '', + formatted_debit: '500.00', + credit: 0, + debit: 500, + }, + { + index: 2, + note: null, + account_name: 'Bank Account', + account_code: '10001', + transaction_number: '', + formatted_credit: '500.00', + formatted_debit: '', + credit: 500, + debit: 0, + }, + ], + credit: 500, + debit: 500, + formatted_credit: '$500.00', + formatted_debit: '$500.00', + }, + { + date: '2025-06-09T22:00:00.000Z', + date_formatted: '2025 Jun 10', + transaction_type: 'VendorCredit', + reference_id: 3, + reference_type_formatted: 'VendorCredit', + entries: [ + { + index: 1, + note: null, + contact_name: 'business', + contact_type: 'customer', + account_name: 'Accounts Payable (A/P)', + account_code: '20001', + transaction_number: 'VC-00001', + formatted_credit: '', + formatted_debit: '100.00', + credit: 0, + debit: 100, + }, + { + index: 2, + note: null, + account_name: 'Cost of Goods Sold', + account_code: '40002', + transaction_number: 'VC-00001', + formatted_credit: '100.00', + formatted_debit: '', + credit: 100, + debit: 0, + }, + ], + credit: 100, + debit: 100, + formatted_credit: '$100.00', + formatted_debit: '$100.00', + }, + { + date: '2025-06-09T22:00:00.000Z', + date_formatted: '2025 Jun 10', + transaction_type: 'VendorCredit', + reference_id: 4, + reference_type_formatted: 'VendorCredit', + entries: [ + { + index: 1, + note: null, + contact_name: 'business', + contact_type: 'customer', + account_name: 'Accounts Payable (A/P)', + account_code: '20001', + transaction_number: 'VC-00001', + formatted_credit: '', + formatted_debit: '100.00', + credit: 0, + debit: 100, + }, + { + index: 2, + note: null, + account_name: 'Cost of Goods Sold', + account_code: '40002', + transaction_number: 'VC-00001', + formatted_credit: '100.00', + formatted_debit: '', + credit: 100, + debit: 0, + }, + ], + credit: 100, + debit: 100, + formatted_credit: '$100.00', + formatted_debit: '$100.00', + }, + { + date: '2025-06-09T22:00:00.000Z', + date_formatted: '2025 Jun 10', + transaction_type: 'Bill', + reference_id: 4, + reference_type_formatted: 'Bill', + entries: [ + { + index: 1, + note: null, + contact_name: 'business', + contact_type: 'customer', + account_name: 'Accounts Payable (A/P)', + account_code: '20001', + transaction_number: null, + formatted_credit: '1,000.00', + formatted_debit: '', + credit: 1000, + debit: 0, + }, + { + index: 1, + note: null, + account_name: 'Cost of Goods Sold', + account_code: '40002', + transaction_number: null, + formatted_credit: '', + formatted_debit: '1,000.00', + credit: 0, + debit: 1000, + }, + ], + credit: 1000, + debit: 1000, + formatted_credit: '$1,000.00', + formatted_debit: '$1,000.00', + }, + { + date: '2025-06-09T22:00:00.000Z', + date_formatted: '2025 Jun 10', + transaction_type: 'Bill', + reference_id: 5, + reference_type_formatted: 'Bill', + entries: [ + { + index: 1, + note: null, + contact_name: 'business', + contact_type: 'customer', + account_name: 'Accounts Payable (A/P)', + account_code: '20001', + transaction_number: null, + formatted_credit: '1,000.00', + formatted_debit: '', + credit: 1000, + debit: 0, + }, + { + index: 1, + note: null, + account_name: 'Inventory Asset', + account_code: '10008', + transaction_number: null, + formatted_credit: '', + formatted_debit: '1,000.00', + credit: 0, + debit: 1000, + }, + ], + credit: 1000, + debit: 1000, + formatted_credit: '$1,000.00', + formatted_debit: '$1,000.00', + }, + { + date: '2025-06-15T22:00:00.000Z', + date_formatted: '2025 Jun 16', + transaction_type: 'Journal', + reference_id: 1017, + reference_type_formatted: 'Journal', + entries: [ + { + index: 1, + note: '', + account_name: 'Loan', + account_code: '20003', + transaction_number: 'REF', + formatted_credit: '', + formatted_debit: '10,000.00', + credit: 0, + debit: 10000, + }, + { + index: 2, + note: '', + account_name: 'Depreciation Expense', + account_code: '40007', + transaction_number: 'REF', + formatted_credit: '10,000.00', + formatted_debit: '', + credit: 10000, + debit: 0, + }, + ], + credit: 10000, + debit: 10000, + formatted_credit: '$10,000.00', + formatted_debit: '$10,000.00', + }, + ], + meta: { + organization_name: 'BIGCAPITAL, INC', + base_currency: 'USD', + date_format: 'DD MMM yyyy', + is_cost_compute_running: false, + sheet_name: '', + formatted_date_range: 'From 2025/06/01 | To 2025/06/21', + formatted_from_date: '2025/06/01', + formatted_to_date: '2025/06/21', + }, +}; diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.ts index 1d4d18ae1..f21011da1 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.ts @@ -118,7 +118,7 @@ export class JournalSheet extends FinancialSheet { */ entriesWalker(entries: ILedgerEntry[]): IJournalReportEntriesGroup[] { return chain(entries) - .groupBy((entry) => `${entry.referenceId}-${entry.referenceType}`) + .groupBy((entry) => `${entry.transactionId}-${entry.transactionType}`) .map((entriesGroup: ILedgerEntry[], key: string) => { const headEntry = head(entriesGroup); return this.entriesGroupsMapper(entriesGroup, headEntry); diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetService.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetService.ts index 86f94cd22..5e702a2cf 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetService.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetService.ts @@ -14,7 +14,7 @@ export class JournalSheetService { private readonly journalSheetMeta: JournalSheetMeta, private readonly journalRepository: JournalSheetRepository, private readonly eventPublisher: EventEmitter2, - private readonly i18n: I18nService + private readonly i18n: I18nService, ) {} /**