Skip to content

Commit

Permalink
Merge pull request #62 from deanblackborough/main
Browse files Browse the repository at this point in the history
v1.07.0
  • Loading branch information
deanblackborough authored Jan 18, 2023
2 parents f5800a1 + b813420 commit a2cc0d4
Show file tree
Hide file tree
Showing 119 changed files with 3,758 additions and 665 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ API_URL_DEV=http://costs.api.app
ITEM_TYPE_ID=VezyrJyMlk
ITEM_SUBTYPE_ID=Q6OV9dk5dE

EXCEPTION_NOTIFICATION_EMAIL
EXCEPTION_NOTIFICATION_EMAIL=

APP_HASH_SALT_FORGOT_PASSWORD=

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Our overview is so clear and simple, a child could manage your budget. We wouldn

Simply input your income and outgoings to see projected balances and savings for the months and years ahead. Handy, right?

![Budget overview](/public/images/readme/budget-projections.png)
![Budget overview](/public/images/readme/view-projections.png)

## Exclusions

We understand that not all expenses are monthly - we provide the tools to set exclusions, ensuring your budget is completely customisable and up-to-date.

![Budget overview](/public/images/readme/budget-item-exclusions.png)
![Budget overview](/public/images/readme/set-exclusions.png)

## Set up

Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Account/ChangePassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class ChangePassword extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Account/DeleteAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class DeleteAccount
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Account/DeleteBudgetAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class DeleteBudgetAccount
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Account/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Reset
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Account/UpdateProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class UpdateProfile extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
abstract class Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Account/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Create extends Action
Expand Down
81 changes: 81 additions & 0 deletions app/Actions/Budget/Account/SetBalances.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);

namespace App\Actions\Budget\Account;

use App\Actions\Action;
use App\Api\Service;
use Illuminate\Support\Facades\Validator;

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class SetBalances extends Action
{
public function __invoke(
Service $api,
string $resource_type_id,
string $resource_id,
array $input
): int
{
$resource = $api->getResource($resource_type_id, $resource_id);
if ($resource['status'] !== 200) {
$this->message = 'Unable to fetch the resource for your Budget, please try again';
return $resource['status'];
}

$rules = [];
$messages = [];

$data = $resource['content']['data'] ?? [];
foreach ($data['accounts'] as $id => $account) {
$rules[$id] = [
'required',
'string',
'regex:/^\d+\.\d{2}$/',
'max:16'
];
$messages[$id . '.required'] = 'Please enter the balance for the account';
$messages[$id . '.regex'] = 'The value should be in the format 0.00';
$messages[$id . '.max'] = 'The balance value is too big';
}

Validator::make(
$input,
$rules,
$messages
)->validate();

foreach ($data['accounts'] as $id => $account) {
$data['accounts'][$id]['balance'] = $input[$id];
}

try {
$data = json_encode($data, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
abort(500, $e->getMessage());
}

$patch_resource_response = $api->patchResource(
$resource_type_id,
$resource_id,
['data' => $data]
);

if ($patch_resource_response['status'] === 204) {
return $patch_resource_response['status'];
}

$this->message = $patch_resource_response['content'];

if ($patch_resource_response['status'] === 422) {
$this->validation_errors = $patch_resource_response['fields'];
return $patch_resource_response['status'];
}

return $patch_resource_response['status'];
}
}
2 changes: 1 addition & 1 deletion app/Actions/Budget/Account/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Update extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/AdoptDemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class AdoptDemo extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Demo extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/Adjust.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Adjust extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Create extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Delete extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/Disable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Disable extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/Enable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Enable extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Reset extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/Restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Restore extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/SetAsNotPaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class SetAsNotPaid extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/SetAsPaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class SetAsPaid extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Item/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Update extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Budget/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Start extends Action
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Helper
Expand Down
2 changes: 1 addition & 1 deletion app/Api/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Http
Expand Down
2 changes: 1 addition & 1 deletion app/Api/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Response
Expand Down
29 changes: 28 additions & 1 deletion app/Api/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough (Costs to Expect) 2018-2022
* @copyright Dean Blackborough (Costs to Expect) 2018-2023
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE
*/
class Service
Expand Down Expand Up @@ -43,6 +43,19 @@ public function authSignIn(string $email, string $password): array
);
}

#[ArrayShape(['status' => "integer", 'content' => "array", 'fields' => "array"])]
public function forgotPassword(array $payload): array
{
$uri = Uri::forgotPassword();

return $this->http->post(
$uri['uri'],
[
'email' => $payload['email']
]
);
}

#[ArrayShape(['status' => "integer", 'content' => "array"])]
public function getAuthUser(): array
{
Expand Down Expand Up @@ -152,6 +165,20 @@ public function createPassword(array $payload): array
);
}

#[ArrayShape(['status' => "integer", 'content' => "array", 'fields' => "array"])]
public function createNewPassword(array $payload): array
{
$uri = Uri::createNewPassword($payload['token'], $payload['email']);

return $this->http->post(
$uri['uri'],
[
'password' => $payload['password'],
'password_confirmation' => $payload['password_confirmation']
]
);
}

#[ArrayShape(['status' => "integer", 'content' => "array"])]
public function createResource(string $resource_type_id): array
{
Expand Down
Loading

0 comments on commit a2cc0d4

Please sign in to comment.