2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00

feat: Customer/Supplier doctype based on Party

This commit is contained in:
Faris Ansari 2019-10-06 03:12:08 +05:30
parent eb348c7210
commit 0f89720770
11 changed files with 74 additions and 43 deletions

View File

@ -0,0 +1,8 @@
module.exports = {
name: 'Customer',
label: 'Customer',
basedOn: 'Party',
filters: {
customer: 1
}
};

View File

@ -1,10 +1,7 @@
import { _ } from 'frappejs/utils'; import { _ } from 'frappejs/utils';
export default { export default {
doctype: 'Party', doctype: 'Customer',
title: _('Customer'), title: _('Customer'),
columns: ['name', 'defaultAccount', 'address'], columns: ['name', 'defaultAccount', 'address']
filters: {
customer: 1
}
}; };

View File

@ -51,6 +51,12 @@ module.exports = {
} }
], ],
quickEditFields: [
'address',
'defaultAccount',
'currency'
],
getFormTitle(doc) { getFormTitle(doc) {
if (doc.customer) return 'Customer'; if (doc.customer) return 'Customer';
return 'Supplier'; return 'Supplier';

View File

@ -0,0 +1,8 @@
module.exports = {
name: 'Supplier',
label: 'Supplier',
basedOn: 'Party',
filters: {
supplier: 1
}
};

View File

@ -1,10 +1,7 @@
import { _ } from 'frappejs/utils'; import { _ } from 'frappejs/utils';
export default { export default {
doctype: 'Party', doctype: 'Supplier',
title: _('Supplier'), title: _('Supplier'),
columns: ['name', 'defaultAccount', 'address'], columns: ['name', 'defaultAccount', 'address']
filters: {
supplier: 1
}
}; };

View File

@ -10,6 +10,8 @@ module.exports = {
CompanySettings: require('./doctype/CompanySettings/CompanySettings'), CompanySettings: require('./doctype/CompanySettings/CompanySettings'),
AccountingLedgerEntry: require('./doctype/AccountingLedgerEntry/AccountingLedgerEntry.js'), AccountingLedgerEntry: require('./doctype/AccountingLedgerEntry/AccountingLedgerEntry.js'),
Party: require('./doctype/Party/Party.js'), Party: require('./doctype/Party/Party.js'),
Customer: require('./doctype/Party/Customer'),
Supplier: require('./doctype/Party/Supplier'),
Payment: require('./doctype/Payment/Payment.js'), Payment: require('./doctype/Payment/Payment.js'),
PaymentFor: require('./doctype/PaymentFor/PaymentFor.js'), PaymentFor: require('./doctype/PaymentFor/PaymentFor.js'),

View File

@ -0,0 +1,11 @@
<template>
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path
d="M7 13A6 6 0 107 1a6 6 0 000 12zm8 2l-3.758-3.758"
fill="none"
fill-rule="evenodd"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>

View File

@ -1,25 +1,8 @@
<template> <template>
<div class="mt-4 px-8 flex justify-between"> <div class="mt-4 px-8 flex justify-between">
<h1 class="text-xl font-bold" v-if="title">{{ title }}</h1> <slot name="title" />
<div class="flex"> <div class="flex items-center">
<Button type="primary"> <slot name="actions" />
<Add class="w-3 h-3 stroke-current text-white" />
</Button>
<SearchBar class="ml-2" />
</div> </div>
</div> </div>
</template> </template>
<script>
import Button from './Button';
import Add from './Icons/Add';
import SearchBar from './SearchBar';
export default {
props: ['title', 'breadcrumbs'],
components: {
Button,
Add,
SearchBar
}
};
</script>

View File

@ -1,12 +1,12 @@
<template> <template>
<div v-on-outside-click="clearInput" class="relative"> <div v-on-outside-click="clearInput" class="relative">
<div class="rounded-lg relative flex items-center overflow-hidden"> <div class="rounded-lg relative flex items-center overflow-hidden">
<div class="absolute ml-3"> <div class="absolute flex justify-center w-8">
<feather-icon class="text-gray-500" name="search"></feather-icon> <SearchIcon class="w-3 h-3 stroke-current text-gray-600" />
</div> </div>
<input <input
type="search" type="search"
class="bg-gray-200 text-sm p-2 pl-10 focus:outline-none" class="bg-gray-200 text-sm p-1 pl-8 focus:outline-none"
@click="focus(0)" @click="focus(0)"
@keydown.down="navigate('down')" @keydown.down="navigate('down')"
@keydown.up="navigate('up')" @keydown.up="navigate('up')"
@ -37,6 +37,7 @@
import frappe from 'frappejs'; import frappe from 'frappejs';
import ListRow from '../pages/ListView/ListRow'; import ListRow from '../pages/ListView/ListRow';
import ListCell from '../pages/ListView/ListCell'; import ListCell from '../pages/ListView/ListCell';
import SearchIcon from '@/components/Icons/Search';
export default { export default {
data() { data() {
@ -48,7 +49,8 @@ export default {
}, },
components: { components: {
ListRow, ListRow,
ListCell ListCell,
SearchIcon
}, },
methods: { methods: {
focus(key) { focus(key) {

View File

@ -1,13 +1,21 @@
<template> <template>
<div class="flex"> <div class="flex">
<div class="flex flex-col flex-1"> <div class="flex flex-col flex-1">
<PageHeader :title="title" /> <PageHeader>
<h1 slot="title" class="text-xl font-bold" v-if="title">{{ title }}</h1>
<template slot="actions">
<Button type="primary" @click="openNewForm">
<Add class="w-3 h-3 stroke-current text-white" />
</Button>
<SearchBar class="ml-2" />
</template>
</PageHeader>
<div class="flex-1"> <div class="flex-1">
<List :listConfig="listConfig" :filters="filters" /> <List :listConfig="listConfig" :filters="filters" />
</div> </div>
</div> </div>
<div class="flex"> <div class="flex">
<router-view class="w-64 flex-1" /> <router-view class="w-80 flex-1" />
</div> </div>
</div> </div>
</template> </template>
@ -15,6 +23,9 @@
import frappe from 'frappejs'; import frappe from 'frappejs';
import Observable from 'frappejs/utils/observable'; import Observable from 'frappejs/utils/observable';
import PageHeader from '@/components/PageHeader'; import PageHeader from '@/components/PageHeader';
import Button from '@/components/Button';
import Add from '@/components/Icons/Add';
import SearchBar from '@/components/SearchBar';
import List from './List'; import List from './List';
import listConfigs from './listConfig'; import listConfigs from './listConfig';
@ -23,7 +34,10 @@ export default {
props: ['listName', 'filters'], props: ['listName', 'filters'],
components: { components: {
PageHeader, PageHeader,
List List,
Button,
Add,
SearchBar
}, },
created() { created() {
frappe.listView = new Observable(); frappe.listView = new Observable();
@ -38,9 +52,9 @@ export default {
if (this.filters) { if (this.filters) {
doc.set(this.filters); doc.set(this.filters);
} }
this.$router.push(`/edit/${doctype}/${doc.name}`); this.$router.push(`/list/${this.listName}/${doc.name}`);
doc.on('afterInsert', () => { doc.on('afterInsert', () => {
this.$router.push(`/edit/${doctype}/${doc.name}`); this.$router.push(`/list/${this.listName}/${doc.name}`);
}); });
} }
}, },
@ -60,11 +74,12 @@ export default {
} }
}, },
title() { title() {
try { if (this.listConfig) {
return this.listConfig.title(this.filters); return typeof this.listConfig.title === 'function'
} catch (e) { ? this.listConfig.title(this.filters)
return this.listConfig.title; : this.listConfig.title;
} }
return this.listName;
} }
} }
}; };

View File

@ -2,6 +2,7 @@ import SalesInvoice from '../../../models/doctype/SalesInvoice/SalesInvoiceList'
import PurchaseInvoice from '../../../models/doctype/PurchaseInvoice/PurchaseInvoiceList'; import PurchaseInvoice from '../../../models/doctype/PurchaseInvoice/PurchaseInvoiceList';
import Customer from '../../../models/doctype/Party/CustomerList'; import Customer from '../../../models/doctype/Party/CustomerList';
import Supplier from '../../../models/doctype/Party/SupplierList'; import Supplier from '../../../models/doctype/Party/SupplierList';
import Party from '../../../models/doctype/Party/PartyList';
import Item from '../../../models/doctype/Item/ItemList'; import Item from '../../../models/doctype/Item/ItemList';
import Payment from '../../../models/doctype/Payment/PaymentList'; import Payment from '../../../models/doctype/Payment/PaymentList';
import Tax from '../../../models/doctype/Tax/TaxList'; import Tax from '../../../models/doctype/Tax/TaxList';
@ -14,6 +15,7 @@ export default {
PurchaseInvoice, PurchaseInvoice,
Customer, Customer,
Supplier, Supplier,
Party,
Item, Item,
Payment, Payment,
Tax, Tax,