mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
incr: display discount breakdown
This commit is contained in:
parent
ff085d6766
commit
be44333e64
@ -124,9 +124,9 @@
|
|||||||
<div v-if="doc.items?.length ?? 0" class="mt-auto">
|
<div v-if="doc.items?.length ?? 0" class="mt-auto">
|
||||||
<hr />
|
<hr />
|
||||||
<div class="flex justify-between text-base m-4 gap-12">
|
<div class="flex justify-between text-base m-4 gap-12">
|
||||||
<div class="w-1/2 relative">
|
<div class="w-1/2 flex flex-col justify-between">
|
||||||
<!-- Discount Note -->
|
<!-- Discount Note -->
|
||||||
<p v-if="discountNote?.length" class="text-gray-600">
|
<p v-if="discountNote?.length" class="text-gray-600 text-sm">
|
||||||
{{ discountNote }}
|
{{ discountNote }}
|
||||||
</p>
|
</p>
|
||||||
<!-- Form Terms-->
|
<!-- Form Terms-->
|
||||||
@ -135,7 +135,7 @@
|
|||||||
:df="getField('terms')"
|
:df="getField('terms')"
|
||||||
:value="doc.terms"
|
:value="doc.terms"
|
||||||
input-class="bg-gray-100"
|
input-class="bg-gray-100"
|
||||||
class="absolute bottom-0 w-full"
|
class="mt-auto"
|
||||||
@change="(value) => doc.set('terms', value)"
|
@change="(value) => doc.set('terms', value)"
|
||||||
:read-only="doc?.submitted"
|
:read-only="doc?.submitted"
|
||||||
/>
|
/>
|
||||||
@ -150,7 +150,32 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
<!-- Discount Applied Before Taxes -->
|
||||||
|
<div
|
||||||
|
v-if="totalDiscount.float > 0 && !doc.discountAfterTax"
|
||||||
|
class="flex flex-col gap-2"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex justify-between"
|
||||||
|
v-if="itemDiscountAmount.float > 0"
|
||||||
|
>
|
||||||
|
<div>{{ t`Item Discount` }}</div>
|
||||||
|
<div>
|
||||||
|
{{ `- ${fyo.format(itemDiscountAmount, 'Currency')}` }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-between" v-if="discountAmount.float > 0">
|
||||||
|
<div>{{ t`Invoice Discount` }}</div>
|
||||||
|
<div>{{ `- ${fyo.format(discountAmount, 'Currency')}` }}</div>
|
||||||
|
</div>
|
||||||
|
<hr v-if="doc.taxes?.length" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Taxes -->
|
<!-- Taxes -->
|
||||||
|
<div
|
||||||
|
v-if="doc.taxes?.length"
|
||||||
|
class="flex flex-col gap-2 max-h-12 overflow-y-auto"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="flex justify-between"
|
class="flex justify-between"
|
||||||
v-for="tax in doc.taxes"
|
v-for="tax in doc.taxes"
|
||||||
@ -166,8 +191,30 @@
|
|||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<hr v-if="doc.taxes?.length" />
|
<hr v-if="doc.taxes?.length" />
|
||||||
|
|
||||||
|
<!-- Discount Applied After Taxes -->
|
||||||
|
<div
|
||||||
|
v-if="totalDiscount.float > 0 && doc.discountAfterTax"
|
||||||
|
class="flex flex-col gap-2"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex justify-between"
|
||||||
|
v-if="itemDiscountAmount.float > 0"
|
||||||
|
>
|
||||||
|
<div>{{ t`Item Discount` }}</div>
|
||||||
|
<div>
|
||||||
|
{{ `- ${fyo.format(itemDiscountAmount, 'Currency')}` }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-between" v-if="discountAmount.float > 0">
|
||||||
|
<div>{{ t`Invoice Discount` }}</div>
|
||||||
|
<div>{{ `- ${fyo.format(discountAmount, 'Currency')}` }}</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Grand Total -->
|
<!-- Grand Total -->
|
||||||
<div
|
<div
|
||||||
class="
|
class="
|
||||||
@ -183,9 +230,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Outstanding Amount -->
|
<!-- Outstanding Amount -->
|
||||||
<hr v-if="doc.outstandingAmount > 0" />
|
<hr v-if="doc.outstandingAmount?.float > 0" />
|
||||||
<div
|
<div
|
||||||
v-if="doc.outstandingAmount > 0"
|
v-if="doc.outstandingAmount?.float > 0"
|
||||||
class="flex justify-between text-red-600 font-semibold text-base"
|
class="flex justify-between text-red-600 font-semibold text-base"
|
||||||
>
|
>
|
||||||
<div>{{ t`Outstanding Amount` }}</div>
|
<div>{{ t`Outstanding Amount` }}</div>
|
||||||
@ -277,8 +324,7 @@ export default {
|
|||||||
return getDocStatus(this.doc);
|
return getDocStatus(this.doc);
|
||||||
},
|
},
|
||||||
discountNote() {
|
discountNote() {
|
||||||
const zeroInvoiceDiscount =
|
const zeroInvoiceDiscount = this.doc?.discountAmount?.isZero();
|
||||||
this.doc?.discountAmount?.isZero() && this.doc?.discountPercent === 0;
|
|
||||||
|
|
||||||
const zeroItemDiscount = (this.doc?.items ?? []).every(
|
const zeroItemDiscount = (this.doc?.items ?? []).every(
|
||||||
(i) => i?.itemDiscountAmount?.isZero() && i?.itemDiscountPercent === 0
|
(i) => i?.itemDiscountAmount?.isZero() && i?.itemDiscountPercent === 0
|
||||||
@ -298,6 +344,26 @@ export default {
|
|||||||
|
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
|
totalDiscount() {
|
||||||
|
const discountAmount = this.doc?.discountAmount ?? fyo.pesa(0);
|
||||||
|
const itemDiscount = (this.doc?.items ?? []).reduce(
|
||||||
|
(acc, i) => acc.add(i.itemDiscountAmount),
|
||||||
|
fyo.pesa(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
return discountAmount.add(itemDiscount);
|
||||||
|
},
|
||||||
|
discountAmount() {
|
||||||
|
return this.doc?.discountAmount ?? fyo.pesa(0);
|
||||||
|
},
|
||||||
|
itemDiscountAmount() {
|
||||||
|
const itemDiscountAmount = (this.doc?.items ?? []).reduce(
|
||||||
|
(acc, i) => acc.add(i.itemDiscountAmount),
|
||||||
|
fyo.pesa(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
return itemDiscountAmount;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
docsPath.value = docsPathMap[this.schemaName];
|
docsPath.value = docsPathMap[this.schemaName];
|
||||||
|
Loading…
Reference in New Issue
Block a user