diff --git a/Frontend/erp-system/app/dashboard/ledgers/general-ledger/page.tsx b/Frontend/erp-system/app/dashboard/ledgers/general-ledger/page.tsx index 5b6f70b..8156326 100644 --- a/Frontend/erp-system/app/dashboard/ledgers/general-ledger/page.tsx +++ b/Frontend/erp-system/app/dashboard/ledgers/general-ledger/page.tsx @@ -1,6 +1,6 @@ "use client" -import { Fragment, useEffect, useState } from "react" +import { useEffect, useState } from "react" import Link from "next/link" import { ArrowLeft, BookOpen } from "lucide-react" @@ -62,7 +62,7 @@ export default function GeneralLedgerReportPage() {

General Ledger

-

Every posted movement on every account, with a running balance per account.

+

Every posted movement, grouped by transaction so every leg of a GRN, Sale, or other journal entry sits together.

@@ -108,37 +108,32 @@ export default function GeneralLedgerReportPage() { + Account Code + Account Name Date - Journal No. - Narration + Description Debit Credit - Running balance + - {rows.map((row, i) => { - const isNewAccount = i === 0 || row.accountCode !== rows[i - 1].accountCode - return ( - - {isNewAccount && ( - - - {row.accountCode} — {row.accountName} - - - )} - - {formatReportDate(row.entryDate)} - {row.journalNo} - {row.narration ?? "—"} - {formatAmount(row.debitAmount, true)} - {formatAmount(row.creditAmount, true)} - {formatAmount(row.runningBalance)} - - - ) - })} + {/* Grouped by transaction (entryDate, then journalNo) rather than by account, so every + leg of the same GRN/Sale/journal — the inventory line, the VAT line, the AP line — + lands on adjacent rows instead of being scattered under separate account blocks. */} + {[...rows] + .sort((a, b) => a.entryDate.localeCompare(b.entryDate) || a.journalNo.localeCompare(b.journalNo)) + .map((row, i) => ( + + {row.accountCode} + {row.accountName} + {formatReportDate(row.entryDate)} + {row.narration ?? "—"} + {formatAmount(row.debitAmount, true)} + {formatAmount(row.creditAmount, true)} + + + ))}
diff --git a/Frontend/erp-system/types/general-ledger.ts b/Frontend/erp-system/types/general-ledger.ts index a148d6f..00ee861 100644 --- a/Frontend/erp-system/types/general-ledger.ts +++ b/Frontend/erp-system/types/general-ledger.ts @@ -112,6 +112,8 @@ export interface GeneralLedgerRow { debitAmount: number creditAmount: number runningBalance: number + /** Which module posted this journal (GRN, Sales, ManualLedgerEntry, Acc_Account, ...) — shown as the "Controller" column. */ + sourceModule: string | null } /** One line inside a Profit & Loss section — inferred shape (see the ProfitAndLossResponse note). */