2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/models/baseModels/Defaults/Defaults.ts
2022-10-12 14:59:43 +05:30

52 lines
1.5 KiB
TypeScript

import { Doc } from 'fyo/model/doc';
import { FiltersMap } from 'fyo/model/types';
import { ModelNameEnum } from 'models/types';
export class Defaults extends Doc {
salesInvoiceNumberSeries?: string;
purchaseInvoiceNumberSeries?: string;
journalEntryNumberSeries?: string;
paymentNumberSeries?: string;
salesInvoiceTerms?: string;
purchaseInvoiceTerms?: string;
static filters: FiltersMap = {
salesInvoiceNumberSeries: () => ({
referenceType: ModelNameEnum.SalesInvoice,
}),
purchaseInvoiceNumberSeries: () => ({
referenceType: ModelNameEnum.PurchaseInvoice,
}),
journalEntryNumberSeries: () => ({
referenceType: ModelNameEnum.JournalEntry,
}),
paymentNumberSeries: () => ({ referenceType: ModelNameEnum.Payment }),
};
static createFilters: FiltersMap = {
salesInvoiceNumberSeries: () => ({
referenceType: ModelNameEnum.SalesInvoice,
}),
purchaseInvoiceNumberSeries: () => ({
referenceType: ModelNameEnum.PurchaseInvoice,
}),
journalEntryNumberSeries: () => ({
referenceType: ModelNameEnum.JournalEntry,
}),
paymentNumberSeries: () => ({
referenceType: ModelNameEnum.Payment,
}),
};
}
export const numberSeriesDefaultsMap: Record<
string,
keyof Defaults | undefined
> = {
[ModelNameEnum.SalesInvoice]: 'salesInvoiceNumberSeries',
[ModelNameEnum.PurchaseInvoice]: 'purchaseInvoiceNumberSeries',
[ModelNameEnum.JournalEntry]: 'journalEntryNumberSeries',
[ModelNameEnum.Payment]: 'paymentNumberSeries',
};