diff --git a/fyo/utils/format.ts b/fyo/utils/format.ts index 918d61a9..d5c80df1 100644 --- a/fyo/utils/format.ts +++ b/fyo/utils/format.ts @@ -9,7 +9,7 @@ import { DEFAULT_CURRENCY, DEFAULT_DATE_FORMAT, DEFAULT_DISPLAY_PRECISION, - DEFAULT_LOCALE + DEFAULT_LOCALE, } from './consts'; export function format( @@ -66,6 +66,10 @@ function toDatetime(value: DocValue) { } function formatDatetime(value: DocValue, fyo: Fyo): string { + if (value == null) { + return ''; + } + const dateFormat = (fyo.singles.SystemSettings?.dateFormat as string) ?? DEFAULT_DATE_FORMAT; const formattedDatetime = toDatetime(value).toFormat( @@ -80,6 +84,10 @@ function formatDatetime(value: DocValue, fyo: Fyo): string { } function formatDate(value: DocValue, fyo: Fyo): string { + if (value == null) { + return ''; + } + const dateFormat = (fyo.singles.SystemSettings?.dateFormat as string) ?? DEFAULT_DATE_FORMAT; diff --git a/models/baseModels/Invoice/Invoice.ts b/models/baseModels/Invoice/Invoice.ts index a749f848..252d1de5 100644 --- a/models/baseModels/Invoice/Invoice.ts +++ b/models/baseModels/Invoice/Invoice.ts @@ -436,7 +436,7 @@ export abstract class Invoice extends Transactional { return defaults?.purchaseInvoiceTerms ?? ''; }, - date: () => new Date().toISOString().slice(0, 10), + date: () => new Date(), }; static filters: FiltersMap = { diff --git a/models/baseModels/JournalEntry/JournalEntry.ts b/models/baseModels/JournalEntry/JournalEntry.ts index 156e1e00..2d357857 100644 --- a/models/baseModels/JournalEntry/JournalEntry.ts +++ b/models/baseModels/JournalEntry/JournalEntry.ts @@ -40,7 +40,7 @@ export class JournalEntry extends Transactional { static defaults: DefaultMap = { numberSeries: (doc) => getNumberSeries(doc.schemaName, doc.fyo), - date: () => DateTime.local().toISODate(), + date: () => new Date(), }; static filters: FiltersMap = { diff --git a/models/baseModels/Payment/Payment.ts b/models/baseModels/Payment/Payment.ts index 68a4aed8..0f928138 100644 --- a/models/baseModels/Payment/Payment.ts +++ b/models/baseModels/Payment/Payment.ts @@ -381,7 +381,7 @@ export class Payment extends Transactional { static defaults: DefaultMap = { numberSeries: (doc) => getNumberSeries(doc.schemaName, doc.fyo), - date: () => new Date().toISOString(), + date: () => new Date(), }; async _getAccountsMap(): Promise { diff --git a/models/inventory/StockTransfer.ts b/models/inventory/StockTransfer.ts index 76d2f296..5aae9c1f 100644 --- a/models/inventory/StockTransfer.ts +++ b/models/inventory/StockTransfer.ts @@ -43,7 +43,7 @@ export abstract class StockTransfer extends Transfer { return defaults?.purchaseReceiptTerms ?? ''; }, - date: () => new Date().toISOString().slice(0, 10), + date: () => new Date(), }; static filters: FiltersMap = { diff --git a/src/components/Controls/Date.vue b/src/components/Controls/Date.vue index e2dd39a3..415cc7d5 100644 --- a/src/components/Controls/Date.vue +++ b/src/components/Controls/Date.vue @@ -1,42 +1,11 @@ -