Updated PDF payment layout
X-Lovable-Edit-ID: edt-8639e42d-7f1c-4750-9dfe-f2d9f89872f4 Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
@@ -748,24 +748,34 @@ export function CollectionDetail({
|
||||
withRunning.forEach((e: any) => {
|
||||
const isPayment = num(e.payment) > 0;
|
||||
let desc = e.description || (e.account || "—");
|
||||
if (isPayment && e.allocations) {
|
||||
const allocParts = BUCKETS
|
||||
.filter((b) => num(e.allocations[b]) > 0)
|
||||
.map((b) => `${BUCKET_SHORT[b]} ${formatCurrency(num(e.allocations[b]))}`);
|
||||
if (allocParts.length > 0) {
|
||||
desc = `${desc}\nApplied → ${allocParts.join(", ")}`;
|
||||
// For payments, show the per-bucket allocation in each column,
|
||||
// greyed out + italic + in parentheses (e.g. "(25.00)").
|
||||
const allocCell = (bucket: typeof BUCKETS[number]) => {
|
||||
if (isPayment && e.allocations) {
|
||||
const v = num(e.allocations[bucket]);
|
||||
if (v > 0) {
|
||||
return {
|
||||
content: `(${v.toFixed(2)})`,
|
||||
styles: {
|
||||
textColor: [140, 140, 140] as any,
|
||||
fontStyle: "italic" as const,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
const raw = num(e[bucket]);
|
||||
return raw ? raw.toFixed(2) : "";
|
||||
};
|
||||
body.push([
|
||||
e.entry_date ? formatDate(e.entry_date) : "",
|
||||
desc,
|
||||
num(e.assess) ? num(e.assess).toFixed(2) : "",
|
||||
num(e.late) ? num(e.late).toFixed(2) : "",
|
||||
num(e.admin) ? num(e.admin).toFixed(2) : "",
|
||||
num(e.legal) ? num(e.legal).toFixed(2) : "",
|
||||
num(e.viol) ? num(e.viol).toFixed(2) : "",
|
||||
num(e.interest) ? num(e.interest).toFixed(2) : "",
|
||||
num(e.bank) ? num(e.bank).toFixed(2) : "",
|
||||
allocCell("assess"),
|
||||
allocCell("late"),
|
||||
allocCell("admin"),
|
||||
allocCell("legal"),
|
||||
allocCell("viol"),
|
||||
allocCell("interest"),
|
||||
allocCell("bank"),
|
||||
isPayment
|
||||
? { content: num(e.payment).toFixed(2), styles: { textColor: [0, 130, 0] as any, fontStyle: "bold" } }
|
||||
: "",
|
||||
|
||||
Reference in New Issue
Block a user