smal change in general ledger UI
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Fragment, useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { ArrowLeft, BookOpen } from "lucide-react"
|
import { ArrowLeft, BookOpen } from "lucide-react"
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ export default function GeneralLedgerReportPage() {
|
|||||||
</Link>
|
</Link>
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold text-foreground">General Ledger</h1>
|
<h1 className="text-2xl font-bold text-foreground">General Ledger</h1>
|
||||||
<p className="text-base text-muted-foreground">Every posted movement on every account, with a running balance per account.</p>
|
<p className="text-base text-muted-foreground">Every posted movement, grouped by transaction so every leg of a GRN, Sale, or other journal entry sits together.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -108,37 +108,32 @@ export default function GeneralLedgerReportPage() {
|
|||||||
<Table className="mt-4 text-base">
|
<Table className="mt-4 text-base">
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
<TableHead className="h-11 px-3 text-sm">Account Code</TableHead>
|
||||||
|
<TableHead className="h-11 px-3 text-sm">Account Name</TableHead>
|
||||||
<TableHead className="h-11 px-3 text-sm">Date</TableHead>
|
<TableHead className="h-11 px-3 text-sm">Date</TableHead>
|
||||||
<TableHead className="h-11 px-3 text-sm">Journal No.</TableHead>
|
<TableHead className="h-11 px-3 text-sm">Description</TableHead>
|
||||||
<TableHead className="h-11 px-3 text-sm">Narration</TableHead>
|
|
||||||
<TableHead className="h-11 px-3 text-right text-sm">Debit</TableHead>
|
<TableHead className="h-11 px-3 text-right text-sm">Debit</TableHead>
|
||||||
<TableHead className="h-11 px-3 text-right text-sm">Credit</TableHead>
|
<TableHead className="h-11 px-3 text-right text-sm">Credit</TableHead>
|
||||||
<TableHead className="h-11 px-3 text-right text-sm">Running balance</TableHead>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{rows.map((row, i) => {
|
{/* Grouped by transaction (entryDate, then journalNo) rather than by account, so every
|
||||||
const isNewAccount = i === 0 || row.accountCode !== rows[i - 1].accountCode
|
leg of the same GRN/Sale/journal — the inventory line, the VAT line, the AP line —
|
||||||
return (
|
lands on adjacent rows instead of being scattered under separate account blocks. */}
|
||||||
<Fragment key={i}>
|
{[...rows]
|
||||||
{isNewAccount && (
|
.sort((a, b) => a.entryDate.localeCompare(b.entryDate) || a.journalNo.localeCompare(b.journalNo))
|
||||||
<TableRow className="bg-muted/40 hover:bg-muted/40">
|
.map((row, i) => (
|
||||||
<TableCell colSpan={6} className="px-3 py-2 font-semibold">
|
<TableRow key={i}>
|
||||||
{row.accountCode} — {row.accountName}
|
<TableCell className="px-3 py-2.5 font-medium">{row.accountCode}</TableCell>
|
||||||
</TableCell>
|
<TableCell className="px-3 py-2.5">{row.accountName}</TableCell>
|
||||||
</TableRow>
|
<TableCell className="px-3 py-2.5">{formatReportDate(row.entryDate)}</TableCell>
|
||||||
)}
|
<TableCell className="px-3 py-2.5 text-muted-foreground">{row.narration ?? "—"}</TableCell>
|
||||||
<TableRow>
|
<TableCell className="px-3 py-2.5 text-right tabular-nums">{formatAmount(row.debitAmount, true)}</TableCell>
|
||||||
<TableCell className="px-3 py-2.5">{formatReportDate(row.entryDate)}</TableCell>
|
<TableCell className="px-3 py-2.5 text-right tabular-nums">{formatAmount(row.creditAmount, true)}</TableCell>
|
||||||
<TableCell className="px-3 py-2.5 font-medium">{row.journalNo}</TableCell>
|
|
||||||
<TableCell className="px-3 py-2.5 text-muted-foreground">{row.narration ?? "—"}</TableCell>
|
</TableRow>
|
||||||
<TableCell className="px-3 py-2.5 text-right tabular-nums">{formatAmount(row.debitAmount, true)}</TableCell>
|
))}
|
||||||
<TableCell className="px-3 py-2.5 text-right tabular-nums">{formatAmount(row.creditAmount, true)}</TableCell>
|
|
||||||
<TableCell className="px-3 py-2.5 text-right font-medium tabular-nums">{formatAmount(row.runningBalance)}</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</Fragment>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ export interface GeneralLedgerRow {
|
|||||||
debitAmount: number
|
debitAmount: number
|
||||||
creditAmount: number
|
creditAmount: number
|
||||||
runningBalance: 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). */
|
/** One line inside a Profit & Loss section — inferred shape (see the ProfitAndLossResponse note). */
|
||||||
|
|||||||
Reference in New Issue
Block a user