Allowed ledger dates to be blank
X-Lovable-Edit-ID: edt-0dd4d5c3-540f-41de-bdc2-6b39603e5f91 Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import { formatCurrency } from "@/lib/format";
|
||||
|
||||
export interface EditableEntry {
|
||||
id: string;
|
||||
entry_date: string;
|
||||
entry_date: string | null;
|
||||
description: string | null;
|
||||
account: string | null;
|
||||
assess: number;
|
||||
@@ -63,6 +63,8 @@ export function SortableLedgerRow({ entry, onPatch, onRemove }: Props) {
|
||||
const commit = (key: keyof EditableEntry, raw: string | number) => {
|
||||
let val: any = raw;
|
||||
if (NUM_COLS.some((c) => c.key === key)) val = raw === "" ? 0 : Number(raw) || 0;
|
||||
// Allow blank dates / blank text fields
|
||||
if (key === "entry_date" && raw === "") val = null;
|
||||
if (val === (entry as any)[key]) return;
|
||||
setDraft((d) => ({ ...d, [key]: val }));
|
||||
onPatch(entry.id, { [key]: val } as any);
|
||||
@@ -84,9 +86,9 @@ export function SortableLedgerRow({ entry, onPatch, onRemove }: Props) {
|
||||
<td className="px-1 py-1">
|
||||
<input
|
||||
type="date"
|
||||
value={draft.entry_date}
|
||||
onChange={(e) => setDraft((d) => ({ ...d, entry_date: e.target.value }))}
|
||||
onBlur={(e) => commit("entry_date", e.target.value)}
|
||||
value={draft.entry_date ?? ""}
|
||||
onChange={(e) => setDraft((d) => ({ ...d, entry_date: e.target.value || null }))}
|
||||
onBlur={(e) => commit("entry_date", e.target.value || (null as any))}
|
||||
className="w-full bg-transparent border border-transparent hover:border-border focus:border-ring rounded px-1.5 py-1 text-xs outline-none"
|
||||
/>
|
||||
</td>
|
||||
|
||||
@@ -666,7 +666,7 @@ export type Database = {
|
||||
credit: number
|
||||
debit: number
|
||||
description: string | null
|
||||
entry_date: string
|
||||
entry_date: string | null
|
||||
id: string
|
||||
interest: number
|
||||
late: number
|
||||
@@ -688,7 +688,7 @@ export type Database = {
|
||||
credit?: number
|
||||
debit?: number
|
||||
description?: string | null
|
||||
entry_date?: string
|
||||
entry_date?: string | null
|
||||
id?: string
|
||||
interest?: number
|
||||
late?: number
|
||||
@@ -710,7 +710,7 @@ export type Database = {
|
||||
credit?: number
|
||||
debit?: number
|
||||
description?: string | null
|
||||
entry_date?: string
|
||||
entry_date?: string | null
|
||||
id?: string
|
||||
interest?: number
|
||||
late?: number
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ export const BUCKET_SHORT: Record<Bucket, string> = {
|
||||
export interface LedgerEntry {
|
||||
id: string;
|
||||
collection_id: string;
|
||||
entry_date: string;
|
||||
entry_date: string | null;
|
||||
description: string | null;
|
||||
account: string | null;
|
||||
assess: number;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE public.collection_ledger_entries
|
||||
ALTER COLUMN entry_date DROP NOT NULL,
|
||||
ALTER COLUMN entry_date DROP DEFAULT;
|
||||
Reference in New Issue
Block a user