2
0
mirror of https://github.com/frappe/books.git synced 2025-04-02 08:11:52 +00:00

Merge pull request #360 from 18alantom/item-segregation

feat: Item segregation by purpose
This commit is contained in:
Alan 2022-03-10 12:25:27 +05:30 committed by GitHub
commit 500c2bb0a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 22 deletions

View File

@ -1,5 +1,11 @@
import frappe, { t } from 'frappe'; import frappe, { t } from 'frappe';
const itemForMap = {
purchases: t`Purchases`,
sales: t`Sales`,
both: t`Both`,
};
export default { export default {
name: 'Item', name: 'Item',
label: t`Item`, label: t`Item`,
@ -42,6 +48,14 @@ export default {
default: 'Product', default: 'Product',
options: ['Product', 'Service'], options: ['Product', 'Service'],
}, },
{
fieldname: 'for',
label: t`For`,
fieldtype: 'Select',
options: Object.keys(itemForMap),
map: itemForMap,
default: 'both',
},
{ {
fieldname: 'incomeAccount', fieldname: 'incomeAccount',
label: t`Income`, label: t`Income`,
@ -115,6 +129,7 @@ export default {
'rate', 'rate',
'unit', 'unit',
'itemType', 'itemType',
'for',
'tax', 'tax',
'description', 'description',
'incomeAccount', 'incomeAccount',

View File

@ -2,6 +2,11 @@ import frappe, { t } from 'frappe';
import utils from '../../../accounting/utils'; import utils from '../../../accounting/utils';
import { DEFAULT_NUMBER_SERIES } from '../../../frappe/utils/consts'; import { DEFAULT_NUMBER_SERIES } from '../../../frappe/utils/consts';
const paymentTypeMap = {
Receive: t`Receive`,
Pay: t`Pay`,
};
export default { export default {
name: 'Payment', name: 'Payment',
label: t`Payment`, label: t`Payment`,
@ -57,7 +62,8 @@ export default {
label: t`Payment Type`, label: t`Payment Type`,
fieldtype: 'Select', fieldtype: 'Select',
placeholder: 'Payment Type', placeholder: 'Payment Type',
options: ['Receive', 'Pay'], options: Object.keys(paymentTypeMap),
map: paymentTypeMap,
required: 1, required: 1,
}, },
{ {

View File

@ -14,11 +14,16 @@ export default {
required: 1, required: 1,
getFilters(_, doc) { getFilters(_, doc) {
let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean); let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean);
if (items.length > 0) {
const baseFilter = { for: ['not in', ['sales']] };
if (items.length <= 0) {
return baseFilter;
}
return { return {
name: ['not in', items], name: ['not in', items],
...baseFilter,
}; };
}
}, },
}, },
{ {

View File

@ -15,11 +15,16 @@ export default {
required: 1, required: 1,
getFilters(_, doc) { getFilters(_, doc) {
let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean); let items = doc.parentdoc.items.map((d) => d.item).filter(Boolean);
if (items.length > 0) {
const baseFilter = { for: ['not in', ['purchases']] };
if (items.length <= 0) {
return baseFilter;
}
return { return {
name: ['not in', items], name: ['not in', items],
...baseFilter,
}; };
}
}, },
}, },
{ {

View File

@ -54,7 +54,7 @@ const routes = [
}, },
}, },
{ {
path: '/list/:doctype', path: '/list/:doctype/:fieldname?/:value?',
name: 'ListView', name: 'ListView',
components: { components: {
default: ListView, default: ListView,
@ -62,7 +62,11 @@ const routes = [
}, },
props: { props: {
default: (route) => { default: (route) => {
const { doctype, filters } = route.params; let { doctype, filters, fieldname, value } = route.params;
if (filters === undefined && fieldname && value) {
filters = { [fieldname]: value };
}
return { return {
doctype, doctype,
filters, filters,

View File

@ -28,11 +28,21 @@ const config = {
route: '/list/SalesInvoice', route: '/list/SalesInvoice',
doctype: 'SalesInvoice', doctype: 'SalesInvoice',
}, },
{
label: t`Payments`,
route: '/list/Payment/paymentType/Receive',
doctype: 'Payment',
},
{ {
label: t`Customers`, label: t`Customers`,
route: '/list/Customer', route: '/list/Customer',
doctype: 'Customer', doctype: 'Customer',
}, },
{
label: t`Sales Items`,
route: '/list/Item/for/sales',
doctype: 'Item',
},
], ],
}, },
{ {
@ -45,33 +55,38 @@ const config = {
route: '/list/PurchaseInvoice', route: '/list/PurchaseInvoice',
doctype: 'PurchaseInvoice', doctype: 'PurchaseInvoice',
}, },
{
label: t`Payments`,
route: '/list/Payment/paymentType/Pay',
doctype: 'Payment',
},
{ {
label: t`Suppliers`, label: t`Suppliers`,
route: '/list/Supplier', route: '/list/Supplier',
doctype: 'Supplier', doctype: 'Supplier',
}, },
{
label: t`Purchase Items`,
route: '/list/Item/for/purchases',
doctype: 'Item',
},
], ],
}, },
{ {
icon: 'common-entries', icon: 'common-entries',
title: t`Common`, title: t`Common`,
route: '/list/Item', route: '/list/JournalEntry',
items: [ items: [
{
label: t`Items`,
route: '/list/Item',
doctype: 'Item',
},
{
label: t`Payments`,
route: '/list/Payment',
doctype: 'Payment',
},
{ {
label: t`Journal Entry`, label: t`Journal Entry`,
route: '/list/JournalEntry', route: '/list/JournalEntry',
doctype: 'JournalEntry', doctype: 'JournalEntry',
}, },
{
label: t`Common Items`,
route: '/list/Item/for/both',
doctype: 'Item',
},
], ],
}, },
{ {