2022-10-12 08:35:18 +00:00
|
|
|
import { Doc } from 'fyo/model/doc';
|
2022-11-16 08:35:38 +00:00
|
|
|
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 {
|
2023-04-20 06:10:23 +00:00
|
|
|
// Quick Payments
|
|
|
|
salesPaymentAccount?: string;
|
|
|
|
purchasePaymentAccount?: string;
|
|
|
|
|
2023-03-06 09:43:54 +00:00
|
|
|
// 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
|
|
|
|
2023-03-06 09:43:54 +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
|
|
|
|
2023-03-06 09:43:54 +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 = {
|
2023-04-20 06:10:23 +00:00
|
|
|
// Quick Payments
|
|
|
|
salesPaymentAccount: () => ({ isGroup: false, accountType: 'Cash' }),
|
|
|
|
purchasePaymentAccount: () => ({ isGroup: false, accountType: 'Cash' }),
|
2023-03-06 09:43:54 +00:00
|
|
|
// 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
|
|
|
}),
|
2023-03-06 09:43:54 +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-16 08:35:38 +00:00
|
|
|
|
2022-11-18 08:44:29 +00:00
|
|
|
getInventoryHidden() {
|
2022-11-30 05:54:05 +00:00
|
|
|
return () => !this.fyo.singles.AccountingSettings?.enableInventory;
|
2022-11-16 08:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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(),
|
2023-03-06 09:43:54 +00:00
|
|
|
shipmentPrintTemplate: this.getInventoryHidden(),
|
|
|
|
purchaseReceiptPrintTemplate: this.getInventoryHidden(),
|
|
|
|
stockMovementPrintTemplate: this.getInventoryHidden(),
|
2022-11-16 08:35:38 +00:00
|
|
|
};
|
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
|
|
|
};
|