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