From d9108d51039b51b141eaf68e6301f590fe58eb5c Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Thu, 10 Mar 2022 12:04:02 +0530 Subject: [PATCH 1/4] feat: add field to segregate items by purpose --- models/doctype/Item/Item.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/models/doctype/Item/Item.js b/models/doctype/Item/Item.js index 35634d43..afa494e1 100644 --- a/models/doctype/Item/Item.js +++ b/models/doctype/Item/Item.js @@ -1,5 +1,11 @@ import frappe, { t } from 'frappe'; +const itemForMap = { + purchases: t`Purchases`, + sales: t`Sales`, + both: t`Both`, +}; + export default { name: 'Item', label: t`Item`, @@ -42,6 +48,14 @@ export default { default: 'Product', options: ['Product', 'Service'], }, + { + fieldname: 'for', + label: t`For`, + fieldtype: 'Select', + options: Object.keys(itemForMap), + map: itemForMap, + default: 'both', + }, { fieldname: 'incomeAccount', label: t`Income`, @@ -115,6 +129,7 @@ export default { 'rate', 'unit', 'itemType', + 'for', 'tax', 'description', 'incomeAccount', From fd73c643b527bffb7f8ff19e2b27be9606ef5cc7 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Thu, 10 Mar 2022 12:06:37 +0530 Subject: [PATCH 2/4] feat: add item segregation in sidebar --- src/router.js | 8 ++++++-- src/sidebarConfig.js | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/router.js b/src/router.js index 906bb636..4de8ba4e 100644 --- a/src/router.js +++ b/src/router.js @@ -54,7 +54,7 @@ const routes = [ }, }, { - path: '/list/:doctype', + path: '/list/:doctype/:fieldname?/:value?', name: 'ListView', components: { default: ListView, @@ -62,7 +62,11 @@ const routes = [ }, props: { default: (route) => { - const { doctype, filters } = route.params; + let { doctype, filters, fieldname, value } = route.params; + if (filters === undefined && fieldname && value) { + filters = { [fieldname]: value }; + } + return { doctype, filters, diff --git a/src/sidebarConfig.js b/src/sidebarConfig.js index cbeb148f..5b975b8f 100644 --- a/src/sidebarConfig.js +++ b/src/sidebarConfig.js @@ -33,6 +33,11 @@ const config = { route: '/list/Customer', doctype: 'Customer', }, + { + label: t`Sales Items`, + route: '/list/Item/for/sales', + doctype: 'Item', + }, ], }, { @@ -50,18 +55,18 @@ const config = { route: '/list/Supplier', doctype: 'Supplier', }, + { + label: t`Purchase Items`, + route: '/list/Item/for/purchases', + doctype: 'Item', + }, ], }, { icon: 'common-entries', title: t`Common`, - route: '/list/Item', + route: '/list/Payment', items: [ - { - label: t`Items`, - route: '/list/Item', - doctype: 'Item', - }, { label: t`Payments`, route: '/list/Payment', @@ -72,6 +77,11 @@ const config = { route: '/list/JournalEntry', doctype: 'JournalEntry', }, + { + label: t`Common Items`, + route: '/list/Item/for/both', + doctype: 'Item', + }, ], }, { From fbb1c4db665646c656b32f6eef35130340ad009b Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Thu, 10 Mar 2022 12:12:02 +0530 Subject: [PATCH 3/4] feat: segregate payment by type in sidebar --- models/doctype/Payment/Payment.js | 8 +++++++- src/sidebarConfig.js | 17 +++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/models/doctype/Payment/Payment.js b/models/doctype/Payment/Payment.js index c376c585..5bf5e83b 100644 --- a/models/doctype/Payment/Payment.js +++ b/models/doctype/Payment/Payment.js @@ -2,6 +2,11 @@ import frappe, { t } from 'frappe'; import utils from '../../../accounting/utils'; import { DEFAULT_NUMBER_SERIES } from '../../../frappe/utils/consts'; +const paymentTypeMap = { + Receive: t`Receive`, + Pay: t`Pay`, +}; + export default { name: 'Payment', label: t`Payment`, @@ -57,7 +62,8 @@ export default { label: t`Payment Type`, fieldtype: 'Select', placeholder: 'Payment Type', - options: ['Receive', 'Pay'], + options: Object.keys(paymentTypeMap), + map: paymentTypeMap, required: 1, }, { diff --git a/src/sidebarConfig.js b/src/sidebarConfig.js index 5b975b8f..dcb7e02e 100644 --- a/src/sidebarConfig.js +++ b/src/sidebarConfig.js @@ -28,6 +28,11 @@ const config = { route: '/list/SalesInvoice', doctype: 'SalesInvoice', }, + { + label: t`Payments`, + route: '/list/Payment/paymentType/Receive', + doctype: 'Payment', + }, { label: t`Customers`, route: '/list/Customer', @@ -50,6 +55,11 @@ const config = { route: '/list/PurchaseInvoice', doctype: 'PurchaseInvoice', }, + { + label: t`Payments`, + route: '/list/Payment/paymentType/Pay', + doctype: 'Payment', + }, { label: t`Suppliers`, route: '/list/Supplier', @@ -65,13 +75,8 @@ const config = { { icon: 'common-entries', title: t`Common`, - route: '/list/Payment', + route: '/list/JournalEntry', items: [ - { - label: t`Payments`, - route: '/list/Payment', - doctype: 'Payment', - }, { label: t`Journal Entry`, route: '/list/JournalEntry', From 17663b2dbedc922d0aa11789ad875899ae4406d2 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Thu, 10 Mar 2022 12:23:28 +0530 Subject: [PATCH 4/4] feat: filter items in invoices --- .../PurchaseInvoiceItem/PurchaseInvoiceItem.js | 13 +++++++++---- models/doctype/SalesInvoiceItem/SalesInvoiceItem.js | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js b/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js index 9d146cec..ef8d5da1 100644 --- a/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js +++ b/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js @@ -14,11 +14,16 @@ export default { required: 1, getFilters(_, doc) { let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean); - if (items.length > 0) { - return { - name: ['not in', items], - }; + + const baseFilter = { for: ['not in', ['sales']] }; + if (items.length <= 0) { + return baseFilter; } + + return { + name: ['not in', items], + ...baseFilter, + }; }, }, { diff --git a/models/doctype/SalesInvoiceItem/SalesInvoiceItem.js b/models/doctype/SalesInvoiceItem/SalesInvoiceItem.js index 0cc16535..bc548f9d 100644 --- a/models/doctype/SalesInvoiceItem/SalesInvoiceItem.js +++ b/models/doctype/SalesInvoiceItem/SalesInvoiceItem.js @@ -15,11 +15,16 @@ export default { required: 1, getFilters(_, doc) { let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean); - if (items.length > 0) { - return { - name: ['not in', items], - }; + + const baseFilter = { for: ['not in', ['purchases']] }; + if (items.length <= 0) { + return baseFilter; } + + return { + name: ['not in', items], + ...baseFilter, + }; }, }, {