From f9fbefad0e2bedaa806d46a9707f2ed639cd8ed8 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Mon, 6 Mar 2023 15:13:54 +0530 Subject: [PATCH] incr: add Print button to common form - remove template setting from print settings - allow setting default templates --- models/baseModels/Defaults/Defaults.ts | 27 ++++++++++++++ schemas/app/Defaults.json | 49 ++++++++++++++++++++++++++ schemas/app/PrintSettings.json | 34 ------------------ src/pages/CommonForm/CommonForm.vue | 13 +++++++ src/pages/PrintView/PrintView.vue | 17 +++++++-- src/utils/ui.ts | 7 ++++ 6 files changed, 111 insertions(+), 36 deletions(-) diff --git a/models/baseModels/Defaults/Defaults.ts b/models/baseModels/Defaults/Defaults.ts index e78c7f28..e6436a2b 100644 --- a/models/baseModels/Defaults/Defaults.ts +++ b/models/baseModels/Defaults/Defaults.ts @@ -3,6 +3,7 @@ import { FiltersMap, HiddenMap } from 'fyo/model/types'; import { ModelNameEnum } from 'models/types'; export class Defaults extends Doc { + // Number Series salesInvoiceNumberSeries?: string; purchaseInvoiceNumberSeries?: string; journalEntryNumberSeries?: string; @@ -11,12 +12,23 @@ export class Defaults extends Doc { shipmentNumberSeries?: string; purchaseReceiptNumberSeries?: string; + // Terms salesInvoiceTerms?: string; purchaseInvoiceTerms?: string; shipmentTerms?: string; purchaseReceiptTerms?: string; + // Print Templates + salesInvoicePrintTemplate?: string; + purchaseInvoicePrintTemplate?: string; + journalEntryPrintTemplate?: string; + paymentPrintTemplate?: string; + shipmentPrintTemplate?: string; + purchaseReceiptPrintTemplate?: string; + stockMovementPrintTemplate?: string; + static commonFilters = { + // Number Series salesInvoiceNumberSeries: () => ({ referenceType: ModelNameEnum.SalesInvoice, }), @@ -38,6 +50,18 @@ export class Defaults extends Doc { purchaseReceiptNumberSeries: () => ({ referenceType: ModelNameEnum.PurchaseReceipt, }), + // 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 }), }; static filters: FiltersMap = this.commonFilters; @@ -53,6 +77,9 @@ export class Defaults extends Doc { purchaseReceiptNumberSeries: this.getInventoryHidden(), shipmentTerms: this.getInventoryHidden(), purchaseReceiptTerms: this.getInventoryHidden(), + shipmentPrintTemplate: this.getInventoryHidden(), + purchaseReceiptPrintTemplate: this.getInventoryHidden(), + stockMovementPrintTemplate: this.getInventoryHidden(), }; } diff --git a/schemas/app/Defaults.json b/schemas/app/Defaults.json index d68c6c79..6bd9d1c3 100644 --- a/schemas/app/Defaults.json +++ b/schemas/app/Defaults.json @@ -83,6 +83,55 @@ "label": "Purchase Receipt Terms", "fieldtype": "Text", "section": "Terms" + }, + { + "fieldname": "salesInvoicePrintTemplate", + "label": "Sales Invoice Print Template", + "fieldtype": "Link", + "target": "PrintTemplate", + "section": "Print Templates" + }, + { + "fieldname": "purchaseInvoicePrintTemplate", + "label": "Purchase Invoice Print Template", + "fieldtype": "Link", + "target": "PrintTemplate", + "section": "Print Templates" + }, + { + "fieldname": "journalEntryPrintTemplate", + "label": "Journal Entry Print Template", + "fieldtype": "Link", + "target": "PrintTemplate", + "section": "Print Templates" + }, + { + "fieldname": "paymentPrintTemplate", + "label": "Payment Print Template", + "fieldtype": "Link", + "target": "PrintTemplate", + "section": "Print Templates" + }, + { + "fieldname": "shipmentPrintTemplate", + "label": "Shipment Print Template", + "fieldtype": "Link", + "target": "PrintTemplate", + "section": "Print Templates" + }, + { + "fieldname": "purchaseReceiptPrintTemplate", + "label": "Purchase Receipt Print Template", + "fieldtype": "Link", + "target": "PrintTemplate", + "section": "Print Templates" + }, + { + "fieldname": "stockMovementPrintTemplate", + "label": "Stock Movement Print Template", + "fieldtype": "Link", + "target": "PrintTemplate", + "section": "Print Templates" } ] } diff --git a/schemas/app/PrintSettings.json b/schemas/app/PrintSettings.json index c65cebdc..8bfbc25f 100644 --- a/schemas/app/PrintSettings.json +++ b/schemas/app/PrintSettings.json @@ -37,28 +37,6 @@ "create": true, "section": "Contacts" }, - { - "fieldname": "template", - "label": "Template", - "placeholder": "Template", - "fieldtype": "Select", - "options": [ - { - "value": "Basic", - "label": "Basic" - }, - { - "value": "Minimal", - "label": "Minimal" - }, - { - "value": "Business", - "label": "Business" - } - ], - "default": "Basic", - "section": "Customizations" - }, { "fieldname": "color", "label": "Color", @@ -149,17 +127,5 @@ "fieldtype": "Check", "section": "Customizations" } - ], - "quickEditFields": [ - "logo", - "displayLogo", - "displayTaxInvoice", - "displayBatch", - "template", - "color", - "font", - "email", - "phone", - "address" ] } diff --git a/src/pages/CommonForm/CommonForm.vue b/src/pages/CommonForm/CommonForm.vue index c14ecfdf..cbfb2434 100644 --- a/src/pages/CommonForm/CommonForm.vue +++ b/src/pages/CommonForm/CommonForm.vue @@ -4,6 +4,13 @@