mirror of
https://github.com/frappe/books.git
synced 2025-02-13 09:29:18 +00:00
fix: Invoice
- Sales Invoices -> Invoices - Purchase Invoice -> Bills - Set default quantity as 1 - Actions for Supplier
This commit is contained in:
parent
dd4fdb2343
commit
6ad61976b8
@ -1,8 +1,45 @@
|
|||||||
|
const { _ } = require('frappejs/utils');
|
||||||
|
const router = require('@/router').default;
|
||||||
|
const frappe = require('frappejs');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'Supplier',
|
name: 'Supplier',
|
||||||
label: 'Supplier',
|
label: 'Supplier',
|
||||||
basedOn: 'Party',
|
basedOn: 'Party',
|
||||||
filters: {
|
filters: {
|
||||||
supplier: 1
|
supplier: 1
|
||||||
|
},
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: _('Create Bill'),
|
||||||
|
condition: doc => !doc.isNew(),
|
||||||
|
action: async supplier => {
|
||||||
|
let doc = await frappe.getNewDoc('PurchaseInvoice');
|
||||||
|
router.push({
|
||||||
|
path: `/edit/PurchaseInvoice/${doc.name}`,
|
||||||
|
query: {
|
||||||
|
doctype: 'PurchaseInvoice',
|
||||||
|
values: {
|
||||||
|
supplier: supplier.name
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: _('View Bills'),
|
||||||
|
condition: doc => !doc.isNew(),
|
||||||
|
action: supplier => {
|
||||||
|
router.push({
|
||||||
|
name: 'ListView',
|
||||||
|
params: {
|
||||||
|
doctype: 'PurchaseInvoice',
|
||||||
|
filters: {
|
||||||
|
supplier: supplier.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@ import { getStatusColumn } from '../Transaction/Transaction';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
doctype: 'PurchaseInvoice',
|
doctype: 'PurchaseInvoice',
|
||||||
title: _('Purchase Invoice'),
|
title: _('Bills'),
|
||||||
formRoute: name => `/edit/PurchaseInvoice/${name}`,
|
formRoute: name => `/edit/PurchaseInvoice/${name}`,
|
||||||
columns: [
|
columns: [
|
||||||
'supplier',
|
'supplier',
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'PurchaseInvoiceItem',
|
name: 'PurchaseInvoiceItem',
|
||||||
label: 'Purchase Invoice Item',
|
|
||||||
doctype: 'DocType',
|
doctype: 'DocType',
|
||||||
isSingle: 0,
|
|
||||||
isChild: 1,
|
isChild: 1,
|
||||||
keywordFields: [],
|
keywordFields: [],
|
||||||
layout: 'ratio',
|
|
||||||
tableFields: ['item', 'tax', 'quantity', 'rate', 'amount'],
|
tableFields: ['item', 'tax', 'quantity', 'rate', 'amount'],
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@ -26,7 +23,8 @@ module.exports = {
|
|||||||
fieldname: 'quantity',
|
fieldname: 'quantity',
|
||||||
label: 'Quantity',
|
label: 'Quantity',
|
||||||
fieldtype: 'Float',
|
fieldtype: 'Float',
|
||||||
required: 1
|
required: 1,
|
||||||
|
formula: () => 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'rate',
|
fieldname: 'rate',
|
||||||
@ -69,7 +67,7 @@ module.exports = {
|
|||||||
label: 'Amount',
|
label: 'Amount',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
readOnly: 1,
|
readOnly: 1,
|
||||||
formula: (row, doc) => row.quantity * row.rate,
|
formula: row => row.quantity * row.rate,
|
||||||
getCurrency: (row, doc) => doc.currency
|
getCurrency: (row, doc) => doc.currency
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ import { getStatusColumn } from '../Transaction/Transaction';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
doctype: 'SalesInvoice',
|
doctype: 'SalesInvoice',
|
||||||
title: _('Sales Invoices'),
|
title: _('Invoices'),
|
||||||
formRoute: name => `/edit/SalesInvoice/${name}`,
|
formRoute: name => `/edit/SalesInvoice/${name}`,
|
||||||
columns: [
|
columns: [
|
||||||
'customer',
|
'customer',
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'SalesInvoiceItem',
|
name: 'SalesInvoiceItem',
|
||||||
doctype: 'DocType',
|
doctype: 'DocType',
|
||||||
isSingle: 0,
|
|
||||||
isChild: 1,
|
isChild: 1,
|
||||||
keywordFields: [],
|
keywordFields: [],
|
||||||
layout: 'ratio',
|
|
||||||
tableFields: ['item', 'tax', 'quantity', 'rate', 'amount'],
|
tableFields: ['item', 'tax', 'quantity', 'rate', 'amount'],
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@ -25,7 +23,8 @@ module.exports = {
|
|||||||
fieldname: 'quantity',
|
fieldname: 'quantity',
|
||||||
label: 'Quantity',
|
label: 'Quantity',
|
||||||
fieldtype: 'Float',
|
fieldtype: 'Float',
|
||||||
required: 1
|
required: 1,
|
||||||
|
formula: () => 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'rate',
|
fieldname: 'rate',
|
||||||
@ -69,7 +68,7 @@ module.exports = {
|
|||||||
label: 'Amount',
|
label: 'Amount',
|
||||||
fieldtype: 'Currency',
|
fieldtype: 'Currency',
|
||||||
readOnly: 1,
|
readOnly: 1,
|
||||||
formula: (row, doc) => row.quantity * row.rate,
|
formula: row => row.quantity * row.rate,
|
||||||
getCurrency: (row, doc) => doc.currency
|
getCurrency: (row, doc) => doc.currency
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-8 px-6">
|
<div class="mt-8 px-6">
|
||||||
<h1 class="text-2xl font-semibold">
|
<h1 class="text-2xl font-semibold">
|
||||||
{{ doc._notInserted ? _('New Invoice') : doc.name }}
|
{{
|
||||||
|
doc._notInserted
|
||||||
|
? doc.doctype === 'SalesInvoice'
|
||||||
|
? _('New Invoice')
|
||||||
|
: _('New Bill')
|
||||||
|
: doc.name
|
||||||
|
}}
|
||||||
</h1>
|
</h1>
|
||||||
<div class="flex justify-between mt-2">
|
<div class="flex justify-between mt-2">
|
||||||
<div class="w-1/3">
|
<div class="w-1/3">
|
||||||
@ -165,7 +171,6 @@ import frappe from 'frappejs';
|
|||||||
import PageHeader from '@/components/PageHeader';
|
import PageHeader from '@/components/PageHeader';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import FormControl from '@/components/Controls/FormControl';
|
import FormControl from '@/components/Controls/FormControl';
|
||||||
import Row from '@/components/Row';
|
|
||||||
import Dropdown from '@/components/Dropdown';
|
import Dropdown from '@/components/Dropdown';
|
||||||
import BackLink from '@/components/BackLink';
|
import BackLink from '@/components/BackLink';
|
||||||
import { openSettings } from '@/pages/Settings/utils';
|
import { openSettings } from '@/pages/Settings/utils';
|
||||||
@ -178,7 +183,6 @@ export default {
|
|||||||
PageHeader,
|
PageHeader,
|
||||||
Button,
|
Button,
|
||||||
FormControl,
|
FormControl,
|
||||||
Row,
|
|
||||||
Dropdown,
|
Dropdown,
|
||||||
BackLink
|
BackLink
|
||||||
},
|
},
|
||||||
@ -208,7 +212,7 @@ export default {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
itemTableColumnRatio() {
|
itemTableColumnRatio() {
|
||||||
return [0.3].concat(this.itemTableFields.map(_ => 1));
|
return [0.3].concat(this.itemTableFields.map(() => 1));
|
||||||
},
|
},
|
||||||
partyField() {
|
partyField() {
|
||||||
let fieldname = {
|
let fieldname = {
|
||||||
@ -230,13 +234,7 @@ export default {
|
|||||||
template: `<span class="text-red-700">{{ _('Delete') }}</span>`
|
template: `<span class="text-red-700">{{ _('Delete') }}</span>`
|
||||||
},
|
},
|
||||||
condition: doc => !doc.isNew() && !doc.submitted,
|
condition: doc => !doc.isNew() && !doc.submitted,
|
||||||
action: () => {
|
action: this.deleteAction
|
||||||
deleteDocWithPrompt(this.doc).then(res => {
|
|
||||||
if (res) {
|
|
||||||
this.routeToList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let actions = [...(this.meta.actions || []), deleteAction]
|
let actions = [...(this.meta.actions || []), deleteAction]
|
||||||
.filter(d => (d.condition ? d.condition(this.doc) : true))
|
.filter(d => (d.condition ? d.condition(this.doc) : true))
|
||||||
@ -283,6 +281,13 @@ export default {
|
|||||||
);
|
);
|
||||||
return this.doc.insertOrUpdate().catch(this.handleError);
|
return this.doc.insertOrUpdate().catch(this.handleError);
|
||||||
},
|
},
|
||||||
|
deleteAction() {
|
||||||
|
return deleteDocWithPrompt(this.doc).then(res => {
|
||||||
|
if (res) {
|
||||||
|
this.routeToList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
onSubmitClick() {
|
onSubmitClick() {
|
||||||
return this.doc.submit().catch(this.handleError);
|
return this.doc.submit().catch(this.handleError);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user