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

fix: InvoiceForm

- Currency formatting
- Route to list if doc not found
This commit is contained in:
Faris Ansari 2019-12-03 13:49:58 +05:30
parent bdab355bdf
commit 43d2c93c13

View File

@ -13,6 +13,14 @@
<Button class="text-gray-900 text-xs" @click="openInvoiceSettings"> <Button class="text-gray-900 text-xs" @click="openInvoiceSettings">
{{ _('Customise') }} {{ _('Customise') }}
</Button> </Button>
<Button
v-if="doc.submitted"
class="text-gray-900 text-xs ml-2"
:icon="true"
@click="$router.push(`/print/${doc.doctype}/${doc.name}`)"
>
<feather-icon name="printer" class="w-4 h-4" />
</Button>
<Dropdown <Dropdown
v-if="actions && actions.length" v-if="actions && actions.length"
class="text-xs" class="text-xs"
@ -142,7 +150,7 @@
<div class="w-64"> <div class="w-64">
<div class="flex pl-2 justify-between py-3 border-b"> <div class="flex pl-2 justify-between py-3 border-b">
<div>{{ _('Subtotal') }}</div> <div>{{ _('Subtotal') }}</div>
<div>{{ frappe.format(doc.netTotal, 'Currency') }}</div> <div>{{ formattedValue('netTotal') }}</div>
</div> </div>
<div <div
class="flex pl-2 justify-between py-3" class="flex pl-2 justify-between py-3"
@ -150,13 +158,20 @@
:key="tax.name" :key="tax.name"
> >
<div>{{ tax.account }} ({{ tax.rate }}%)</div> <div>{{ tax.account }} ({{ tax.rate }}%)</div>
<div>{{ frappe.format(tax.amount, 'Currency') }}</div> <div>
{{
frappe.format(tax.amount, {
fieldtype: 'Currency',
currency: doc.currency
})
}}
</div>
</div> </div>
<div <div
class="flex pl-2 justify-between py-3 border-t text-green-600 font-semibold text-base" class="flex pl-2 justify-between py-3 border-t text-green-600 font-semibold text-base"
> >
<div>{{ _('Grand Total') }}</div> <div>{{ _('Grand Total') }}</div>
<div>{{ frappe.format(doc.grandTotal, 'Currency') }}</div> <div>{{ formattedValue('grandTotal') }}</div>
</div> </div>
</div> </div>
</div> </div>
@ -165,6 +180,7 @@
</div> </div>
</template> </template>
<script> <script>
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';
@ -254,7 +270,15 @@ export default {
} }
}, },
async mounted() { async mounted() {
try {
this.doc = await frappe.getDoc(this.doctype, this.name); this.doc = await frappe.getDoc(this.doctype, this.name);
window.d = this.doc;
} catch (error) {
if (error instanceof frappe.errors.NotFoundError) {
this.routeToList();
return;
}
}
this.doc.on('change', ({ changed }) => { this.doc.on('change', ({ changed }) => {
if (changed === this.partyField.fieldname) { if (changed === this.partyField.fieldname) {
this.fetchPartyDoc(); this.fetchPartyDoc();
@ -325,6 +349,13 @@ export default {
}, },
routeToList() { routeToList() {
this.$router.push(`/list/${this.doctype}`); this.$router.push(`/list/${this.doctype}`);
},
formattedValue(fieldname, doc) {
if (!doc) {
doc = this.doc;
}
let df = doc.meta.getField(fieldname);
return frappe.format(doc[fieldname], df, doc);
} }
} }
}; };