mirror of
https://github.com/frappe/books.git
synced 2025-02-02 20:18:26 +00:00
Dashboard Page: Add YTD Option
Adding the ability to select YTD (Year to Date) slicer on the Dashboard page.
This commit is contained in:
parent
090f309a80
commit
3299be7e36
@ -11,7 +11,7 @@ export default defineComponent({
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
period: 'This Year' as PeriodKey,
|
period: 'This Year' as PeriodKey,
|
||||||
periodOptions: ['This Year', 'This Quarter', 'This Month'] as PeriodKey[],
|
periodOptions: ['This Year', 'YTD', 'This Quarter', 'This Month'] as PeriodKey[],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -72,7 +72,7 @@ export default defineComponent({
|
|||||||
data: () => ({
|
data: () => ({
|
||||||
data: [] as { inflow: number; outflow: number; yearmonth: string }[],
|
data: [] as { inflow: number; outflow: number; yearmonth: string }[],
|
||||||
periodList: [],
|
periodList: [],
|
||||||
periodOptions: ['This Year', 'This Quarter'],
|
periodOptions: ['This Year', 'YTD', 'This Quarter'],
|
||||||
hasData: false,
|
hasData: false,
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<PeriodSelector
|
<PeriodSelector
|
||||||
class="px-3"
|
class="px-3"
|
||||||
:value="period"
|
:value="period"
|
||||||
:options="['This Year', 'This Quarter', 'This Month']"
|
:options="['This Year', 'YTD', 'This Quarter', 'This Month']"
|
||||||
@change="(value) => (period = value)"
|
@change="(value) => (period = value)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -51,7 +51,7 @@ export default defineComponent({
|
|||||||
value: { type: String as PropType<PeriodKey>, default: 'This Year' },
|
value: { type: String as PropType<PeriodKey>, default: 'This Year' },
|
||||||
options: {
|
options: {
|
||||||
type: Array as PropType<PeriodKey[]>,
|
type: Array as PropType<PeriodKey[]>,
|
||||||
default: () => ['This Year', 'This Quarter', 'This Month'],
|
default: () => ['This Year', 'YTD', 'This Quarter', 'This Month'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ['change'],
|
emits: ['change'],
|
||||||
@ -65,6 +65,7 @@ export default defineComponent({
|
|||||||
this.periodSelectorMap = {
|
this.periodSelectorMap = {
|
||||||
'': t`Set Period`,
|
'': t`Set Period`,
|
||||||
'This Year': t`This Year`,
|
'This Year': t`This Year`,
|
||||||
|
'YTD': t`YTD`,
|
||||||
'This Quarter': t`This Quarter`,
|
'This Quarter': t`This Quarter`,
|
||||||
'This Month': t`This Month`,
|
'This Month': t`This Month`,
|
||||||
};
|
};
|
||||||
|
@ -57,7 +57,7 @@ export default defineComponent({
|
|||||||
data: () => ({
|
data: () => ({
|
||||||
data: [] as { yearmonth: string; balance: number }[],
|
data: [] as { yearmonth: string; balance: number }[],
|
||||||
hasData: false,
|
hasData: false,
|
||||||
periodOptions: ['This Year', 'This Quarter'],
|
periodOptions: ['This Year', 'YTD', 'This Quarter'],
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
chartData() {
|
chartData() {
|
||||||
|
@ -24,6 +24,8 @@ export function getDatesAndPeriodList(period: PeriodKey): {
|
|||||||
|
|
||||||
if (period === 'This Year') {
|
if (period === 'This Year') {
|
||||||
fromDate = toDate.minus({ months: 12 });
|
fromDate = toDate.minus({ months: 12 });
|
||||||
|
} else if (period === 'YTD') {
|
||||||
|
fromDate = DateTime.now().startOf('Year');
|
||||||
} else if (period === 'This Quarter') {
|
} else if (period === 'This Quarter') {
|
||||||
fromDate = toDate.minus({ months: 3 });
|
fromDate = toDate.minus({ months: 3 });
|
||||||
} else if (period === 'This Month') {
|
} else if (period === 'This Month') {
|
||||||
@ -39,6 +41,10 @@ export function getDatesAndPeriodList(period: PeriodKey): {
|
|||||||
while (true) {
|
while (true) {
|
||||||
const nextDate = periodList.at(0)!.minus({ months: 1 });
|
const nextDate = periodList.at(0)!.minus({ months: 1 });
|
||||||
if (nextDate.toMillis() < fromDate.toMillis()) {
|
if (nextDate.toMillis() < fromDate.toMillis()) {
|
||||||
|
if (period === 'YTD'){
|
||||||
|
periodList.unshift(nextDate);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ export type DropdownItem = {
|
|||||||
|
|
||||||
export type UIGroupedFields = Map<string, Map<string, Field[]>>;
|
export type UIGroupedFields = Map<string, Map<string, Field[]>>;
|
||||||
export type ExportFormat = 'csv' | 'json';
|
export type ExportFormat = 'csv' | 'json';
|
||||||
export type PeriodKey = 'This Year' | 'This Quarter' | 'This Month';
|
export type PeriodKey = 'This Year'| 'YTD' | 'This Quarter' | 'This Month';
|
||||||
|
|
||||||
export type PrintValues = {
|
export type PrintValues = {
|
||||||
print: Record<string, unknown>;
|
print: Record<string, unknown>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user