2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 01:14:03 +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.

105 lines
3.5 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 {
// Quick Payments
salesPaymentAccount?: string;
purchasePaymentAccount?: string;
// Number Series
2022-10-12 08:35:18 +00:00
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
// Terms
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
// Print Templates
salesInvoicePrintTemplate?: string;
purchaseInvoicePrintTemplate?: string;
journalEntryPrintTemplate?: string;
paymentPrintTemplate?: string;
shipmentPrintTemplate?: string;
purchaseReceiptPrintTemplate?: string;
stockMovementPrintTemplate?: string;
2022-11-16 06:44:00 +00:00
static commonFilters = {
// Quick Payments
salesPaymentAccount: () => ({ isGroup: false, accountType: 'Cash' }),
purchasePaymentAccount: () => ({ isGroup: false, accountType: 'Cash' }),
// Number Series
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
}),
// Print Templates
salesInvoicePrintTemplate: () => ({ type: ModelNameEnum.SalesInvoice }),
purchaseInvoicePrintTemplate: () => ({
type: ModelNameEnum.PurchaseInvoice,
}),
journalEntryPrintTemplate: () => ({ type: ModelNameEnum.JournalEntry }),
paymentPrintTemplate: () => ({ type: ModelNameEnum.Payment }),
shipmentPrintTemplate: () => ({ type: ModelNameEnum.Shipment }),
purchaseReceiptPrintTemplate: () => ({
type: ModelNameEnum.PurchaseReceipt,
}),
stockMovementPrintTemplate: () => ({ type: ModelNameEnum.StockMovement }),
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(),
shipmentPrintTemplate: this.getInventoryHidden(),
purchaseReceiptPrintTemplate: this.getInventoryHidden(),
stockMovementPrintTemplate: 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
};