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

Release/alpha7 #435

Merged
merged 3 commits into from
Jul 29, 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
4 changes: 2 additions & 2 deletions app/Domains/Housing/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace App\Domains\Housing\Http\Controllers;

use App\Domains\Housing\Models\Occurrence;
use App\Http\Controllers\Controller;
use App\Domains\Housing\Models\Occurrence;

class ProjectController extends Controller
{
public function __invoke()
{
return inertia('Housing/Index', [
'checks' => Occurrence::where('team_id', auth()->user()->current_team_id)->limit(4)->get(),
'checks' => Occurrence::where('team_id', auth()->user()->current_team_id)->limit(6)->get(),
]);
}
}
22 changes: 6 additions & 16 deletions app/Domains/Integration/Actions/BHD.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,50 +49,40 @@ public function getDescription(): string
return 'Parse an email alert or notification from BHD Leon Bank';
}

/**
* Validate and create a new team for the given user.
*
* @param Google_Calendar_Events $calendarEvents
* @return void
*/

public static function parseAlert(
Automation $automation,
mixed $payload,
AutomationTaskAction $task,
AutomationTaskAction $previousTask,
AutomationTaskAction $trigger
) {

echo "\n Parsing alert \n\n";
return (new BHDAlert())->handle($automation, $payload);
}

/**
* Validate and create a new team for the given user.
*
* @param Google_Calendar_Events $calendarEvents
* @return void
*/

public static function parseNotification(
Automation $automation,
mixed $payload,
AutomationTaskAction $task,
AutomationTaskAction $previousTask,
AutomationTaskAction $trigger
) {

echo "\n Parsing notification";
return (new BHDNotification())->handle($automation, $payload);
}

public static function getMessageType($mail)
{
try {
$body = new Crawler($mail['message']);
$tdValues = $body->filter('[class*=table_trans_body] td')->each(function (Crawler $node) {
$tdValues = $body->filter('[class*=alert_div] td')->each(function (Crawler $node) {
return $node->text();
});

return empty($tdValues) ? 'notification' : 'alert';
} catch (Exception) {
} catch (Exception $e) {
return 'notification';
}
}
Expand Down
41 changes: 23 additions & 18 deletions app/Domains/Integration/Actions/BHDAlert.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace App\Domains\Integration\Actions;

use Exception;
use Symfony\Component\DomCrawler\Crawler;
use App\Domains\Automation\Models\Automation;
use App\Domains\Transaction\Services\YNABService;
use App\Domains\Integration\Concerns\MailToTransaction;
use App\Domains\Integration\Concerns\TransactionDataDTO;

Expand All @@ -13,25 +15,28 @@ class BHDAlert implements MailToTransaction

public function handle(Automation $automation, mixed $mail, int $index = 0): TransactionDataDTO
{
try {
$body = new Crawler($mail['message']);
$product = $body->filter('[class*=titleA] + p')->first()->text();
$tdValues = $body->filter('[class*=table_trans] tbody td')->each(function (Crawler $node) {
return $node->text();
});

$body = new Crawler($mail['message']);
$product = $body->filter('[class*=titleA] + p')->first()->text();
$tdValues = $body->filter('[class*=table_trans_body] td')->each(function (Crawler $node) {
return $node->text();
});
$total = YNABService::extractMoneyCurrency($tdValues[2]);
$type = BHD::parseTypes(strtolower($tdValues[5])) ?? 1;

$total = (int) str_replace(',', '', $tdValues[2]);
$type = BHD::parseTypes(strtolower($tdValues[5])) ?? 1;

return new TransactionDataDTO([
'id' => (int) $mail['id'],
'date' => date('Y-m-d', strtotime($mail['date'])),
'payee' => $tdValues[3],
'category' => '',
'categoryGroup' => '',
'description' => $product,
'amount' => $total * $type,
'currencyCode' => BHD::parseCurrency($tdValues[1]),
]);
return new TransactionDataDTO([
'id' => (int) $mail['id'],
'date' => date('Y-m-d', strtotime($mail['date'])),
'payee' => $tdValues[3],
'category' => '',
'categoryGroup' => '',
'description' => $product,
'amount' => $total->amount * $type,
'currencyCode' => BHD::parseCurrency($tdValues[1]),
]);
} catch (Exception $e) {
throw $e;
}
}
}
38 changes: 20 additions & 18 deletions app/Domains/Integration/Actions/BHDNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,28 @@ public function handle(Automation $automation, mixed $mail, int $index = 0): Tra
'name' => 'type',
],
];
try {
foreach ($tableIds as $fieldName => $field) {
$bhdOutput[$field['name']] = $this->{$field['processor']}($body->filter("[id*=${fieldName}]")->first()->text());
foreach ($tableIds as $fieldName => $field) {
try {
$bhdOutput[$field['name']] = $this->{$field['processor']}($body->filter("[id*=$fieldName]")->first()->text());
} catch (Exception $e) {
echo $e->getMessage() . "\n\n";
Log::error($e->getMessage(), [$e]);
continue;
}

return new TransactionDataDTO([
'id' => (int) $mail['id'],
'date' => $bhdOutput['date'],
'payee' => $bhdOutput['seller'],
'category' => '',
'categoryGroup' => '',
'description' => $bhdOutput['product'].':'.$bhdOutput['description'],
'amount' => $bhdOutput['amount']->amount * 1,
'currencyCode' => $bhdOutput['amount']->currencyCode,
]);
} catch (Exception $e) {
echo $e->getMessage();
Log::error($e->getMessage(), [$e]);
return null;
}

print_r([$bhdOutput['amount']]);

return new TransactionDataDTO([
'id' => (int) $mail['id'],
'date' => $bhdOutput['date'],
'payee' => $bhdOutput['seller'],
'category' => '',
'categoryGroup' => '',
'description' => $bhdOutput['product'].':'.$bhdOutput['description'],
'amount' => $bhdOutput['amount']->amount * 1,
'currencyCode' => $bhdOutput['amount']->currencyCode,
]);
}

public function processResult($value)
Expand Down
1 change: 1 addition & 0 deletions app/Domains/Integration/Actions/GmailReceived.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static function handle(Automation $automation, $lastData = null, $task =
if ($taskIndex !== 0) {
$actionEntity = $task->entity;
try {
echo "\n starting workflow-task:$task->id:$task->name";
$payload = $actionEntity::handle($automation, $payload, $task, $previousTask, $tasks[0]);
$previousTask = $task;
} catch (\Exception $e) {
Expand Down
3 changes: 2 additions & 1 deletion app/Domains/Integration/Actions/TransactionCreateEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ public static function handle(
$transactionService = new TransactionService();

if ($transaction = $transactionService->findIfDuplicated($transactionData)) {
print_r($transaction);
return $transaction;
}

print_r([$transaction, "new transaction"]);

$transaction = Transaction::createTransaction($transactionData);
User::find($automation->user_id)->notify(new EntryGenerated($transaction));

Expand Down
3 changes: 2 additions & 1 deletion app/Domains/Transaction/Models/BillingCycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public static function checkPayments($payable)
}

public function linkPayment(Transaction $transaction, $formData) {
if ($this->debt <= 0) {
$paid = $this->payments;
if ($paid >= $this->total) {
throw new Exception("The document {$this->concept} is already paid");
}

Expand Down
4 changes: 2 additions & 2 deletions app/Domains/Transaction/Services/ReportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function getIncomeVsExpenses($teamId, $timeUnitDiff = 2, $startDat



$income = self::getIncomeByPayeeInPeriod($teamId, $startDate, $endDate);
$income = self::getTransactionsByPayeeInPeriod($teamId, $startDate, $endDate);
$incomeCategories = $income->groupBy($timeUnit);

$dates = $expensesGroup->keys();
Expand Down Expand Up @@ -155,7 +155,7 @@ public static function getExpensesByYear($year, $teamId)
->get();
}

public static function getIncomeByPayeeInPeriod($teamId, $startDate, $endDate)
public static function getTransactionsByPayeeInPeriod($teamId, $startDate, $endDate)
{
return TransactionLine::byTeam($teamId)
->balance()
Expand Down
4 changes: 2 additions & 2 deletions app/Domains/Transaction/Services/TransactionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public static function getIncomeVsExpenses($teamId, $timeUnitDiff = 2, $timeUnit
return ["{$item->group_name}:{$item->name}" => $item];
});

$income = self::getIncomeByPayeeInPeriod($teamId, $startDate, $endDate);
$income = self::getTransactionsByPayeeInPeriod($teamId, $startDate, $endDate);
$incomeCategories = $income->unique('id')->sortBy('index_field')->values();
$incomeCategoriesGroup = $income->sortBy('index_field')->mapToGroups(function ($item) {
return [$item->name => $item];
Expand Down Expand Up @@ -418,7 +418,7 @@ public static function getForExport($teamId)
->toArray();
}

public static function getIncomeByPayeeInPeriod($teamId, $startDate, $endDate, $direction = Transaction::DIRECTION_DEBIT)
public static function getTransactionsByPayeeInPeriod($teamId, $startDate, $endDate, $direction = Transaction::DIRECTION_DEBIT)
{
return DB::table('payees')
->selectRaw('sum(COALESCE(total,0)) as total, date_format(transactions.date, "%Y-%m-01") as date, payees.name, payees.id')
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Finance/FinanceTrendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public function payee(Request $request)

$teamId = $request->user()->current_team_id;

$data = TransactionService::getIncomeByPayeeInPeriod($teamId, $startDate, $endDate, $direction);
$data = TransactionService::getTransactionsByPayeeInPeriod($teamId, $startDate, $endDate, $direction);

return [
'data' => $data,
'data' => $data->sortByDesc('total')->values(),
'metaData' => [
'title' => 'Payee Trends',
'name' => 'payee'
Expand Down
11 changes: 11 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,29 @@ 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']
IMdiBankTransferIn: typeof import('~icons/mdi/bank-transfer-in')['default']
IMdiBankTransferOut: typeof import('~icons/mdi/bank-transfer-out')['default']
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']
IMdiEllipsisVertical: typeof import('~icons/mdi/ellipsis-vertical')['default']
IMdiEmailCheck: typeof import('~icons/mdi/email-check')['default']
IMdiExport: typeof import('~icons/mdi/export')['default']
IMdiFile: typeof import('~icons/mdi/file')['default']
IMdiFilter: typeof import('~icons/mdi/filter')['default']
IMdiHistory: typeof import('~icons/mdi/history')['default']
IMdiLink: typeof import('~icons/mdi/link')['default']
IMdiLock: typeof import('~icons/mdi/lock')['default']
IMdiMinus: typeof import('~icons/mdi/minus')['default']
IMdiMoney: typeof import('~icons/mdi/money')['default']
IMdiStar: typeof import('~icons/mdi/star')['default']
IMdiStarOutline: typeof import('~icons/mdi/star-outline')['default']
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
"@iconify-json/fluent": "^1.1.59",
"@iconify-json/ic": "^1.1.17",
"@iconify-json/ion": "^1.1.18",
"@iconify-json/material-symbols": "^1.1.82",
"@iconify-json/material-symbols": "^1.1.85",
"@iconify-json/mdi": "^1.1.67",
"@inertiajs/vue3": "^1.2.0",
"@mertasan/tailwindcss-variables": "^2.7.0",
"@tailwindcss/typography": "^0.5.13",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/server-renderer": "^3.4.27",
"@vitejs/plugin-vue": "^5.1.1",
"@vue/server-renderer": "^3.4.34",
"@vueuse/core": "^10.11.0",
"atmosphere-ui": "^1.3.5",
"autoprefixer": "^10.4.19",
Expand All @@ -55,24 +55,24 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-html": "^8.1.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vue": "^9.26.0",
"eslint-plugin-vue": "^9.27.0",
"exact-math": "^2.2.3",
"firebase": "^10.8.0",
"firebase": "^10.12.4",
"laravel-vite-plugin": "^1.0.5",
"lodash": "^4.17.21",
"naive-ui": "^2.39.0",
"postcss": "^8.4.39",
"postcss": "^8.4.40",
"prettier": "^3.3.3",
"sass": "^1.77.8",
"slug": "^9.1.0",
"tailwindcss": "^3.4.4",
"typescript": "^5.4.5",
"unplugin-icons": "^0.18.5",
"tailwindcss": "^3.4.7",
"typescript": "^5.5.4",
"unplugin-icons": "^0.19.0",
"unplugin-vue-components": "^0.27.3",
"uuid": "^10.0.0",
"vite": "^5.3.4",
"vite-plugin-pwa": "^0.20.0",
"vitepress": "^1.2.3",
"vite": "^5.3.5",
"vite-plugin-pwa": "^0.20.1",
"vitepress": "^1.3.1",
"vue": "^3.4.33",
"vue-multiselect": "^3.0.0",
"vue3-apexcharts": "^1.5.3",
Expand All @@ -83,11 +83,11 @@
"@originjs/vite-plugin-federation": "^1.3.5",
"@vueuse/components": "^10.11.0",
"chart.js": "^4.4.3",
"element-plus": "^2.7.7",
"element-plus": "^2.7.8",
"floating-vue": "^5.2.2",
"fuse.js": "^7.0.0",
"luxon": "^3.4.4",
"pinia": "^2.1.7",
"pinia": "^2.2.0",
"randomcolor": "^0.6.2",
"vanilla-icon-picker": "^1.3.0",
"vue-chartjs": "^5.3.1",
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Components/widgets/ChoreWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defineProps<{

<template>
<div class="pb-10" :class="cardShadow">
<RandomMealCard class="rounded-b-none border-b mt-4" title="Get random chore" />
<RandomMealCard class="rounded-b-none border-b mt-4" title="Boards" />
<div class="px-4 py-2 space-y-4 rounded-b-md cursor-pointer min-h-min bg-base-lvl-3">
<div class="text-center">
<SectionTitle type="secondary"> {{ $t('Chores for today') }}</SectionTitle>
Expand Down
8 changes: 3 additions & 5 deletions resources/js/Pages/Housing/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import CategoryItem from '@/domains/transactions/components/CategoryItem.vue';
import MealTypeCell from '@/domains/meal/components/MealTypeCell.vue';

import { IOccurrenceCheck } from "@/domains/housing/models";
import WeatherWidget from '@/Components/widgets/WeatherWidget.vue';

defineProps<{
checks: IOccurrenceCheck
Expand All @@ -32,20 +31,19 @@ defineProps<{
<main
class="px-5 mx-auto mt-12 space-y-10 md:space-y-0 md:space-x-10 md:flex max-w-screen-2xl sm:px-6 lg:px-8"
>
<div class="mt-6 md:w-9/12 space-y-4">
<div class="mt-6 md:w-6/12 space-y-4">
<section class="flex flex-col md:flex-row md:space-x-4">
<WelcomeCard message="Loger profiles" class="md:w-8/12 w-full order-1">
<WelcomeCard message="Loger profiles" class="w-full order-1">
<section class="mt-2 md:mt-0 flex flex-col items-center mx-auto">
<h4 class="text-lg font-bold text-body-1"> There are not profiles created</h4>
<p class="max-w-lg my-3">
Lorem ipsum dolor sit amet consectetur adipiscing elit maecenas.
</p>
</section>
</WelcomeCard>
<WeatherWidget class="md:w-4/12 md:order-1" />
</section>
</div>
<div class="py-6 space-y-4 md:w-3/12">
<div class="py-6 space-y-4 md:w-6/12">
<OccurrenceWidget :checks="checks" />
<ChoreWidget :chores="[]">
<div class="mt-2">
Expand Down
Loading
Loading