2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 17:34:04 +00:00
books/models/baseModels/Defaults/Defaults.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.2 KiB
TypeScript
Raw Normal View History

2022-10-12 08:35:18 +00:00
import { Doc } from 'fyo/model/doc';
import { FiltersMap, HiddenMap } from 'fyo/model/types';
2022-10-12 08:35:18 +00:00
import { ModelNameEnum } from 'models/types';
export class Defaults extends Doc {
salesInvoiceNumberSeries?: string;
purchaseInvoiceNumberSeries?: string;
journalEntryNumberSeries?: string;
paymentNumberSeries?: string;
2022-11-16 06:44:00 +00:00
stockMovementNumberSeries?: string;
shipmentNumberSeries?: string;
purchaseReceiptNumberSeries?: string;
2022-10-12 08:35:18 +00:00
salesInvoiceTerms?: string;
purchaseInvoiceTerms?: string;
2022-11-16 06:44:00 +00:00
shipmentTerms?: string;
purchaseReceiptTerms?: string;
2022-10-12 08:35:18 +00:00
2022-11-16 06:44:00 +00:00
static commonFilters = {
2022-10-12 08:35:18 +00:00
salesInvoiceNumberSeries: () => ({
referenceType: ModelNameEnum.SalesInvoice,
}),
purchaseInvoiceNumberSeries: () => ({
referenceType: ModelNameEnum.PurchaseInvoice,
}),
journalEntryNumberSeries: () => ({
referenceType: ModelNameEnum.JournalEntry,
}),
2022-11-16 06:44:00 +00:00
paymentNumberSeries: () => ({
referenceType: ModelNameEnum.Payment,
2022-10-12 08:35:18 +00:00
}),
2022-11-16 06:44:00 +00:00
stockMovementNumberSeries: () => ({
referenceType: ModelNameEnum.StockMovement,
2022-10-12 08:35:18 +00:00
}),
2022-11-16 06:44:00 +00:00
shipmentNumberSeries: () => ({
referenceType: ModelNameEnum.Shipment,
2022-10-12 08:35:18 +00:00
}),
2022-11-16 06:44:00 +00:00
purchaseReceiptNumberSeries: () => ({
referenceType: ModelNameEnum.PurchaseReceipt,
2022-10-12 08:35:18 +00:00
}),
};
2022-11-16 06:44:00 +00:00
static filters: FiltersMap = this.commonFilters;
static createFilters: FiltersMap = this.commonFilters;
2022-11-18 08:44:29 +00:00
getInventoryHidden() {
2022-11-30 05:54:05 +00:00
return () => !this.fyo.singles.AccountingSettings?.enableInventory;
}
hidden: HiddenMap = {
2022-11-18 08:44:29 +00:00
stockMovementNumberSeries: this.getInventoryHidden(),
shipmentNumberSeries: this.getInventoryHidden(),
purchaseReceiptNumberSeries: this.getInventoryHidden(),
shipmentTerms: this.getInventoryHidden(),
purchaseReceiptTerms: this.getInventoryHidden(),
};
2022-10-12 08:35:18 +00:00
}
2022-10-12 09:29:43 +00:00
export const numberSeriesDefaultsMap: Record<
string,
keyof Defaults | undefined
> = {
[ModelNameEnum.SalesInvoice]: 'salesInvoiceNumberSeries',
[ModelNameEnum.PurchaseInvoice]: 'purchaseInvoiceNumberSeries',
[ModelNameEnum.JournalEntry]: 'journalEntryNumberSeries',
[ModelNameEnum.Payment]: 'paymentNumberSeries',
2022-11-16 06:44:00 +00:00
[ModelNameEnum.StockMovement]: 'stockMovementNumberSeries',
[ModelNameEnum.Shipment]: 'shipmentNumberSeries',
[ModelNameEnum.PurchaseReceipt]: 'purchaseReceiptNumberSeries',
2022-10-12 09:29:43 +00:00
};