2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +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';
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',

View File

@ -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,
},
{

View File

@ -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) {
const baseFilter = { for: ['not in', ['sales']] };
if (items.length <= 0) {
return baseFilter;
}
return {
name: ['not in', items],
...baseFilter,
};
}
},
},
{

View File

@ -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) {
const baseFilter = { for: ['not in', ['purchases']] };
if (items.length <= 0) {
return baseFilter;
}
return {
name: ['not in', items],
...baseFilter,
};
}
},
},
{

View File

@ -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,

View File

@ -28,11 +28,21 @@ const config = {
route: '/list/SalesInvoice',
doctype: 'SalesInvoice',
},
{
label: t`Payments`,
route: '/list/Payment/paymentType/Receive',
doctype: 'Payment',
},
{
label: t`Customers`,
route: '/list/Customer',
doctype: 'Customer',
},
{
label: t`Sales Items`,
route: '/list/Item/for/sales',
doctype: 'Item',
},
],
},
{
@ -45,33 +55,38 @@ const config = {
route: '/list/PurchaseInvoice',
doctype: 'PurchaseInvoice',
},
{
label: t`Payments`,
route: '/list/Payment/paymentType/Pay',
doctype: 'Payment',
},
{
label: t`Suppliers`,
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/JournalEntry',
items: [
{
label: t`Items`,
route: '/list/Item',
doctype: 'Item',
},
{
label: t`Payments`,
route: '/list/Payment',
doctype: 'Payment',
},
{
label: t`Journal Entry`,
route: '/list/JournalEntry',
doctype: 'JournalEntry',
},
{
label: t`Common Items`,
route: '/list/Item/for/both',
doctype: 'Item',
},
],
},
{