mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
feat: add route to paid or unpaid invoices
This commit is contained in:
parent
080eaa5e4f
commit
2310b6acec
@ -4,14 +4,7 @@
|
|||||||
<SectionHeader>
|
<SectionHeader>
|
||||||
<template #title>{{ title }}</template>
|
<template #title>{{ title }}</template>
|
||||||
<template #action>
|
<template #action>
|
||||||
<PeriodSelector
|
<PeriodSelector :value="period" @change="(value) => (period = value)" />
|
||||||
v-if="hasData"
|
|
||||||
:value="period"
|
|
||||||
@change="(value) => (period = value)"
|
|
||||||
/>
|
|
||||||
<Button v-else :icon="true" type="primary" @click="newInvoice()">
|
|
||||||
<feather-icon name="plus" class="w-4 h-4 text-white" />
|
|
||||||
</Button>
|
|
||||||
</template>
|
</template>
|
||||||
</SectionHeader>
|
</SectionHeader>
|
||||||
|
|
||||||
@ -22,7 +15,12 @@
|
|||||||
<!-- Paid -->
|
<!-- Paid -->
|
||||||
<div
|
<div
|
||||||
class="text-sm font-medium"
|
class="text-sm font-medium"
|
||||||
:class="{ 'bg-gray-200 text-gray-200 rounded': !count }"
|
:class="{
|
||||||
|
'bg-gray-200 text-gray-200 rounded': !count,
|
||||||
|
'cursor-pointer': paidCount > 0,
|
||||||
|
}"
|
||||||
|
@click="() => routeToInvoices('paid')"
|
||||||
|
:title="paidCount > 0 ? t`View Paid Invoices` : ''"
|
||||||
>
|
>
|
||||||
{{ fyo.format(paid, 'Currency') }}
|
{{ fyo.format(paid, 'Currency') }}
|
||||||
<span :class="{ 'text-gray-900 font-normal': count }">{{
|
<span :class="{ 'text-gray-900 font-normal': count }">{{
|
||||||
@ -33,7 +31,12 @@
|
|||||||
<!-- Unpaid -->
|
<!-- Unpaid -->
|
||||||
<div
|
<div
|
||||||
class="text-sm font-medium"
|
class="text-sm font-medium"
|
||||||
:class="{ 'bg-gray-200 text-gray-200 rounded': !count }"
|
:class="{
|
||||||
|
'bg-gray-200 text-gray-200 rounded': !count,
|
||||||
|
'cursor-pointer': unpaidCount > 0,
|
||||||
|
}"
|
||||||
|
@click="() => routeToInvoices('unpaid')"
|
||||||
|
:title="unpaidCount > 0 ? t`View Unpaid Invoices` : ''"
|
||||||
>
|
>
|
||||||
{{ fyo.format(unpaid, 'Currency') }}
|
{{ fyo.format(unpaid, 'Currency') }}
|
||||||
<span :class="{ 'text-gray-900 font-normal': count }">{{
|
<span :class="{ 'text-gray-900 font-normal': count }">{{
|
||||||
@ -79,7 +82,6 @@
|
|||||||
import { t } from 'fyo';
|
import { t } from 'fyo';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { ModelNameEnum } from 'models/types';
|
import { ModelNameEnum } from 'models/types';
|
||||||
import Button from 'src/components/Button.vue';
|
|
||||||
import MouseFollower from 'src/components/MouseFollower.vue';
|
import MouseFollower from 'src/components/MouseFollower.vue';
|
||||||
import { fyo } from 'src/initFyo';
|
import { fyo } from 'src/initFyo';
|
||||||
import { uicolors } from 'src/utils/colors';
|
import { uicolors } from 'src/utils/colors';
|
||||||
@ -98,7 +100,6 @@ export default defineComponent({
|
|||||||
components: {
|
components: {
|
||||||
PeriodSelector,
|
PeriodSelector,
|
||||||
SectionHeader,
|
SectionHeader,
|
||||||
Button,
|
|
||||||
MouseFollower,
|
MouseFollower,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -158,10 +159,32 @@ export default defineComponent({
|
|||||||
barWidth: number;
|
barWidth: number;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
activated() {
|
async activated() {
|
||||||
this.setData();
|
await this.setData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async routeToInvoices(type: 'paid' | 'unpaid') {
|
||||||
|
if (type === 'paid' && !this.paidCount) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'unpaid' && !this.unpaidCount) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const zero = this.fyo.pesa(0).store;
|
||||||
|
const filters = { outstandingAmount: ['=', zero] };
|
||||||
|
const schemaLabel = fyo.schemaMap[this.schemaName]?.label ?? '';
|
||||||
|
let label = t`Paid ${schemaLabel}`;
|
||||||
|
if (type === 'unpaid') {
|
||||||
|
filters.outstandingAmount[0] = '!=';
|
||||||
|
label = t`Unpaid ${schemaLabel}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = `/list/${this.schemaName}/${label}`;
|
||||||
|
const query = { filters: JSON.stringify(filters) };
|
||||||
|
await routeTo({ path, query });
|
||||||
|
},
|
||||||
async setData() {
|
async setData() {
|
||||||
const { fromDate, toDate } = getDatesAndPeriodList(this.period);
|
const { fromDate, toDate } = getDatesAndPeriodList(this.period);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user