Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/project standarization #436

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn
23 changes: 20 additions & 3 deletions app/Domains/Transaction/Services/ReportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,27 @@ public static function generateExpensesByPeriod($teamId, $startDate, $timeUnitDi
}, $resultGroup)->sortBy('date');
}

public static function getAssignedByPeriod($teamId, $startDate, $timeUnitDiff = 2, $timeUnit = 'month', $categories = null)
public static function generateExpensesByPeriodInDate($teamId, $startDate, $endDate, $categories = null)
{
$rangeEndAt = Carbon::createFromFormat('Y-m-d', $startDate)->endOfMonth()->format('Y-m-d');
$rangeStartAt = Carbon::now()->subMonth($timeUnitDiff)->startOfMonth()->format('Y-m-d');
$rangeStartAt = Carbon::createFromFormat('Y-m-d', $startDate)->startOfMonth()->format('Y-m-d');
$rangeEndAt = Carbon::createFromFormat('Y-m-d', $endDate)->endOfMonth()->format('Y-m-d');

$results = self::getExpensesByCategoriesInPeriod($teamId, $rangeStartAt, $rangeEndAt, $categories);
$resultGroup = $results->groupBy('date');

return $resultGroup->map(function ($monthItems) {
return [
'date' => $monthItems->first()->date,
'data' => $monthItems->sortByDesc('total_amount')->values(),
'total' => $monthItems->sum('total_amount'),
];
}, $resultGroup)->sortBy('date');
}

public static function getAssignedByPeriod($teamId, $startDate, $endDate, $categories = null)
{
$rangeStartAt = Carbon::createFromFormat('Y-m-d', $startDate)->startOfMonth()->format('Y-m-d');
$rangeEndAt = Carbon::createFromFormat('Y-m-d', $endDate)->endOfMonth()->format('Y-m-d');

$results = self::getAssignedByCategoriesInPeriod($teamId, $rangeStartAt, $rangeEndAt, $categories);
$resultGroup = $results->groupBy('date');
Expand Down
18 changes: 15 additions & 3 deletions app/Http/Controllers/Finance/FinanceTrendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,19 @@ public function spendingYear()
$excludedAccounts = collect(explode(',', $filters['category']))->map(fn ($id) => "-$id")->all();
}

$endDate = Carbon::createFromFormat('Y-m-d', $startDate)->endOfYear()->format('Y-m-d');
$startDate = Carbon::createFromFormat('Y-m-d', $startDate)->startOfYear()->format('Y-m-d');

$monthlyExpensesInYear = ReportService::generateExpensesByPeriodInDate($teamId, $startDate, $endDate, $excludedAccounts);

return [
'data' => ReportService::generateExpensesByPeriod($teamId, $startDate, 12, 'month', $excludedAccounts),
'data' => $monthlyExpensesInYear,
'metaData' => [
'name' => 'spendingYear',
'title' => 'Expenses',
'title' => 'Expenses this year',
'props' => [
'headerTemplate' => 'grid',
'total' => $monthlyExpensesInYear->sum('total'),
],
],
];
Expand All @@ -233,13 +239,19 @@ public function assignedInYear()
$excludedAccounts = collect(explode(',', $filters['category']))->map(fn ($id) => "-$id")->all();
}

$endDate = Carbon::createFromFormat('Y-m-d', $startDate)->endOfYear()->format('Y-m-d');
$startDate = Carbon::createFromFormat('Y-m-d', $startDate)->startOfYear()->format('Y-m-d');

$assignedInYear = ReportService::getAssignedByPeriod($teamId, $startDate, $endDate, $excludedAccounts);

return [
'data' => ReportService::getAssignedByPeriod($teamId, $startDate, 12, 'month', $excludedAccounts),
'data' => $assignedInYear,
'metaData' => [
'name' => 'assignedYear',
'title' => 'Assigned in year',
'props' => [
'headerTemplate' => 'grid',
'total' => $assignedInYear->sum('total'),
],
],
];
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { extends: ['@commitlint/config-conventional'] };
7 changes: 4 additions & 3 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
IFluentFoodApple20Filled: typeof import('~icons/fluent/food-apple20-filled')['default']
IIonEllipsisVertical: typeof import('~icons/ion/ellipsis-vertical')['default']
IMaterialSymbolsBrightnessAlertOutlineRounded: typeof import('~icons/material-symbols/brightness-alert-outline-rounded')['default']
IMdiBankTransfer: typeof import('~icons/mdi/bank-transfer')['default']
Expand All @@ -16,11 +15,10 @@ declare module 'vue' {
IMdiBell: typeof import('~icons/mdi/bell')['default']
IMdiCallSplit: typeof import('~icons/mdi/call-split')['default']
IMdiCheck: typeof import('~icons/mdi/check')['default']
IMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
IMdiChevronLeft: typeof import('~icons/mdi/chevron-left')['default']
IMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
IMdiChevronUp: typeof import('~icons/mdi/chevron-up')['default']
IMdiClose: typeof import('~icons/mdi/close')['default']
IMdiEdit: typeof import('~icons/mdi/edit')['default']
IMdiEllipsisVertical: typeof import('~icons/mdi/ellipsis-vertical')['default']
IMdiEmailCheck: typeof import('~icons/mdi/email-check')['default']
IMdiExport: typeof import('~icons/mdi/export')['default']
Expand All @@ -31,6 +29,9 @@ declare module 'vue' {
IMdiLock: typeof import('~icons/mdi/lock')['default']
IMdiMinus: typeof import('~icons/mdi/minus')['default']
IMdiMoney: typeof import('~icons/mdi/money')['default']
IMdiPlus: typeof import('~icons/mdi/plus')['default']
IMdiSearch: typeof import('~icons/mdi/search')['default']
IMdiSort: typeof import('~icons/mdi/sort')['default']
IMdiStar: typeof import('~icons/mdi/star')['default']
IMdiStarOutline: typeof import('~icons/mdi/star-outline')['default']
IMdiSync: typeof import('~icons/mdi/sync')['default']
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"release": "commit-and-tag-version"
"release": "commit-and-tag-version",
"prepare": "husky"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@headlessui/vue": "^1.7.22",
"@iconify-json/clarity": "^1.1.13",
"@iconify-json/fluent": "^1.1.59",
Expand All @@ -58,6 +61,7 @@
"eslint-plugin-vue": "^9.27.0",
"exact-math": "^2.2.3",
"firebase": "^10.12.4",
"husky": "^9.1.3",
"laravel-vite-plugin": "^1.0.5",
"lodash": "^4.17.21",
"naive-ui": "^2.39.0",
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Components/molecules/WidgetTitleCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { AtButton } from "atmosphere-ui";

withDefaults(defineProps<{
title: string;
title?: string;
action?: {
label: string,
iconClass?: string,
Expand Down
69 changes: 25 additions & 44 deletions resources/js/Components/widgets/ChartComparison.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,29 @@ import { formatMonth } from "@/utils";
import formatMoney from "@/utils/formatMoney";
import WidgetTitleCard from "../molecules/WidgetTitleCard.vue";

const props = defineProps({
title: {
type: String
},
hideHeader: {
type: Boolean
},
headerTemplate: {
type: String,
default: 'row'
},
type: {
type: String,
default: "bar"
},
data: {
type: Object,
required: true
},
groupTotal: {
type: String,
default: "total"
},
dataItemTotal: {
type: String,
default: "total"
},
dataItemLabel: {
type: Function
},
hideDivider: {
type: Boolean
},
headerLabel: {
type: String,
},
headerTitleDate: {
default: true,
}
const props = withDefaults(defineProps<{
title: string,
hideHeader: boolean
headerTemplate: "row" | "grid",
type: string,
data: Record<string, any>,
groupTotal: string,
dataItemTotal: string,
dataItemLabel: Function
hideDivider: boolean
headerLabel: string
headerTitleDate: boolean
withPadding: boolean
}>(), {
headerTemplate: 'row',
type: "bar",
groupTotal: "total",
dataItemTotal: "total",
headerTitleDate: true,
withPadding: true
});

const emit = defineEmits(['click']);
const emit = defineEmits(['click', 'subitem-clicked', 'action']);

const selectedDate = ref(null)
const currentSeries = computed(() => {
Expand Down Expand Up @@ -110,7 +91,7 @@ const handleSelection = (index: number) => {
:hide-divider="hideDivider"
@action="$emit('action', $event)"
:border="false"
:with-padding="false"
:with-padding="withPadding"
>
<template #icon v-if="selectedDate">
<LogerButtonTab @click="selectedDate=null">
Expand All @@ -123,13 +104,13 @@ const handleSelection = (index: number) => {

<section class="w-full card-text" >
<div
:class="[headerTemplate == 'grid' ? 'md:grid md:grid-cols-4' : 'md:flex']"
class="w-full mb-2 divide-y comparison-header md:px-10 text-body-1/50 md:space-x-2 md:divide-x md:divide-y-0 divide-dashed divide-opacity-20 divide-body-1 bg-base-lvl-2">
:class="[headerTemplate == 'grid' ? 'md:grid md:grid-cols-4' : 'md:flex md:divide-x']"
class="w-full mb-2 divide-y comparison-header md:px-10 text-body-1/50 md:space-x-2 md:divide-y-0 divide-dashed divide-opacity-20 divide-body-1 bg-base-lvl-2">
<div
v-for="header in state.headers"
:key="header.id"
@click="selectedDate = header.id"
class="flex items-center justify-between w-full px-4 py-2 cursor-pointer comparison-header__item md:py-6 md:justify-center md:flex-col previous-period hover:text-body/80"
class="flex items-center justify-between w-full px-4 py-2 cursor-pointer comparison-header__item md:py-6 md:justify-center md:flex-col previous-period hover:text-body/80"
>
<h6 class="period-title">{{ header.label }}</h6>
<span class="mt-2 text-xs period-value">
Expand Down
Loading
Loading