2
0
mirror of https://github.com/frappe/books.git synced 2024-11-12 16:36:27 +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.

129 lines
4.4 KiB
TypeScript
Raw Normal View History

2023-08-22 06:48:51 +00:00
import { DefaultCashDenominations } from 'models/inventory/Point of Sale/DefaultCashDenominations';
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';
2023-09-05 12:03:42 +00:00
import { PartyRoleEnum } from '../Party/types';
2022-10-12 08:35:18 +00:00
export class Defaults extends Doc {
// Auto Payments
salesPaymentAccount?: string;
purchasePaymentAccount?: string;
2023-06-06 07:44:26 +00:00
// Auto Stock Transfer
shipmentLocation?: string;
purchaseReceiptLocation?: string;
// Number Series
salesQuoteNumberSeries?: string;
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
salesQuotePrintTemplate?: string;
salesInvoicePrintTemplate?: string;
purchaseInvoicePrintTemplate?: string;
journalEntryPrintTemplate?: string;
paymentPrintTemplate?: string;
shipmentPrintTemplate?: string;
purchaseReceiptPrintTemplate?: string;
stockMovementPrintTemplate?: string;
2023-08-22 06:48:51 +00:00
// Point of Sale
posCashDenominations?: DefaultCashDenominations[];
posCustomer?: string;
2022-11-16 06:44:00 +00:00
static commonFilters = {
// Auto Payments
salesPaymentAccount: () => ({ isGroup: false, accountType: 'Cash' }),
purchasePaymentAccount: () => ({ isGroup: false, accountType: 'Cash' }),
// Number Series
salesQuoteNumberSeries: () => ({
referenceType: ModelNameEnum.SalesQuote,
}),
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
salesQuotePrintTemplate: () => ({ type: ModelNameEnum.SalesQuote }),
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 }),
2023-09-05 12:03:42 +00:00
posCustomer: () => ({ role: PartyRoleEnum.Customer }),
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;
}
2023-08-22 06:48:51 +00:00
getPointOfSaleHidden() {
return () => !this.fyo.singles.InventorySettings?.enablePointOfSale;
}
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(),
2023-08-22 06:48:51 +00:00
posCashDenominations: this.getPointOfSaleHidden(),
posCustomer: this.getPointOfSaleHidden(),
};
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',
[ModelNameEnum.SalesQuote]: 'salesQuoteNumberSeries',
2022-10-12 09:29:43 +00:00
};