Skip to content

Commit d9c0764

Browse files
committed
akaunting 3.0 (the last dance)
1 parent cead09f commit d9c0764

File tree

3,812 files changed

+127969
-104087
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,812 files changed

+127969
-104087
lines changed

.env.example

+6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ BROADCAST_DRIVER=log
1919
CACHE_DRIVER=file
2020
SESSION_DRIVER=file
2121
QUEUE_CONNECTION=sync
22+
2223
LOG_CHANNEL=stack
24+
LOG_DEPRECATIONS_CHANNEL=null
25+
LOG_LEVEL=debug
2326

2427
MAIL_MAILER=mail
2528
MAIL_HOST=localhost
@@ -33,3 +36,6 @@ MAIL_FROM_ADDRESS=null
3336
FIREWALL_ENABLED=false
3437

3538
MODEL_CACHE_ENABLED=false
39+
40+
DEBUGBAR_EDITOR=vscode
41+
IGNITION_EDITOR=vscode

.git-ftp-ignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.gitignore
2+
.gitattributes
3+
.git-ftp-ignore
4+
.git-ftp-include
5+
.git-ftp-log
6+
.gitlab-ci.yml
7+
.ftpquota
8+
.git/*
9+
.github/*
10+
.public/js/*
11+
.vendor/*
12+
.node_modules/*
13+
14+
composer.lock

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Tests
22

33
on:
4-
push:
4+
push:
55
pull_request:
66
schedule:
77
- cron: '0 0 * * *'
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
php: ['7.3', '7.4']
18+
php: ['8.0', '8.1']
1919

2020
steps:
2121
- name: Checkout code

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ Homestead.json
8585
Homestead.yaml
8686
npm-debug.log
8787
.env
88-
.env.example
8988
robots.txt
9089
_ide_helper.php
9190
_ide_helper_models.php
@@ -95,3 +94,4 @@ _ide_helper_models.php
9594
modules/*
9695
!modules/.gitkeep
9796
.laravelstatsrc
97+
.DS_Store

README.md

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Tests](https://img.shields.io/github/workflow/status/akaunting/akaunting/Tests?label=tests)](https://github.com/akaunting/akaunting/actions)
77
[![License](https://img.shields.io/github/license/akaunting/akaunting?label=license)](LICENSE.txt)
88

9-
Akaunting is a free, open source and online accounting software designed for small businesses and freelancers. It is built with modern technologies such as Laravel, VueJS, Bootstrap 4, RESTful API etc. Thanks to its modular structure, Akaunting provides an awesome App Store for users and developers.
9+
Akaunting is a free, open source and online accounting software designed for small businesses and freelancers. It is built with modern technologies such as Laravel, VueJS, Tailwind, RESTful API etc. Thanks to its modular structure, Akaunting provides an awesome App Store for users and developers.
1010

1111
* [Home](https://akaunting.com) - The house of Akaunting
1212
* [Forum](https://akaunting.com/forum) - Ask for support
@@ -17,7 +17,7 @@ Akaunting is a free, open source and online accounting software designed for sma
1717

1818
## Requirements
1919

20-
* PHP 7.3 or higher
20+
* PHP 8.0 or higher
2121
* Database (eg: MySQL, PostgreSQL, SQLite)
2222
* Web Server (eg: Apache, Nginx, IIS)
2323
* [Other libraries](https://akaunting.com/docs/requirements)
@@ -65,16 +65,6 @@ Please review [our security policy](https://github.com/akaunting/akaunting/secur
6565
* [Cüneyt Şentürk](https://github.com/cuneytsenturk)
6666
* [All Contributors](../../contributors)
6767

68-
## Partners
69-
70-
Each of our partners can help you craft a beautiful, well-architected project. Feel free to get in [contact](https://akaunting.com/contact) with us to become a partner.
71-
72-
* [Creative Tim](https://www.creative-tim.com) is our design partner since Akaunting 2.0 version. They create beautiful UI Kits, Templates, and Dashboards built on top of Bootstrap, Vue.js, React, Angular, Node.js, and Laravel.
73-
74-
## Sponsors
75-
76-
Support Akaunting by becoming a sponsor on [Patreon](https://www.patreon.com/akaunting). Your logo will show up here with a link to your website.
77-
7868
## License
7969

8070
Akaunting is released under the [GPLv3 license](LICENSE.txt).

app/Abstracts/BulkAction.php

+42-16
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,54 @@ abstract class BulkAction
1818
public $model = false;
1919

2020
public $actions = [
21-
'enable' => [
22-
'name' => 'general.enable',
23-
'message' => 'bulk_actions.message.enable',
24-
'permission' => 'update-common-items',
21+
'enable' => [
22+
'name' => 'general.enable',
23+
'message' => 'bulk_actions.message.enable',
24+
'permission' => 'update-common-items',
2525
],
26-
'disable' => [
27-
'name' => 'general.disable',
28-
'message' => 'bulk_actions.message.disable',
29-
'permission' => 'update-common-items',
26+
'disable' => [
27+
'name' => 'general.disable',
28+
'message' => 'bulk_actions.message.disable',
29+
'permission' => 'update-common-items',
3030
],
31-
'delete' => [
32-
'name' => 'general.delete',
33-
'message' => 'bulk_actions.message.delete',
34-
'permission' => 'delete-common-items',
31+
'delete' => [
32+
'name' => 'general.delete',
33+
'message' => 'bulk_actions.message.delete',
34+
'permission' => 'delete-common-items',
3535
],
36-
'export' => [
37-
'name' => 'general.export',
38-
'message' => 'bulk_actions.message.export',
39-
'type' => 'download'
36+
'export' => [
37+
'name' => 'general.export',
38+
'message' => 'bulk_actions.message.export',
39+
'type' => 'download'
4040
],
4141
];
4242

43+
public $icons = [
44+
'enable' => 'check_circle',
45+
'disable' => 'hide_source',
46+
'delete' => 'delete',
47+
'export' => 'file_download',
48+
'reconcile' => 'published_with_changes',
49+
'unreconcile' => 'layers_clear',
50+
'received' => 'call_received',
51+
'cancelled' => 'cancel',
52+
'sent' => 'send',
53+
'approved' => 'approval',
54+
'refused' => 'do_not_disturb_on',
55+
'issued' => 'mark_email_read',
56+
'confirmed' => 'thumb_up_alt',
57+
];
58+
59+
public $messages = [
60+
'general' => 'bulk_actions.success.general',
61+
'enable' => 'messages.success.enabled',
62+
'disable' => 'messages.success.disabled',
63+
'delete' => 'messages.success.deleted',
64+
'duplicate' => 'messages.success.duplicated',
65+
'invite' => 'messages.success.invited',
66+
'end' => 'messages.success.ended',
67+
];
68+
4369
public function getSelectedRecords($request, $relationships = null)
4470
{
4571
if (empty($relationships)) {

app/Abstracts/Factory.php

+35-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Models\Auth\User;
66
use App\Models\Common\Company;
77
use App\Traits\Jobs;
8+
use Closure;
89
use Illuminate\Database\Eloquent\Factories\Factory as BaseFactory;
910
use Illuminate\Database\Eloquent\Model as EloquentModel;
1011

@@ -28,16 +29,46 @@ public function __construct(...$arguments)
2829

2930
config(['mail.default' => 'array']);
3031

32+
// TODO: this location was put to make US | for "gmail.co.uk" issue
33+
$this->faker = \Faker\Factory::create();
34+
35+
$this->setUser();
36+
37+
$this->setCompany();
38+
}
39+
40+
public function getCompanyUsers(): array
41+
{
42+
return $this->company->users()->enabled()->get()->pluck('id')->toArray();
43+
}
44+
45+
public function company(int $id): static
46+
{
47+
return $this->state([
48+
'company_id' => $id,
49+
]);
50+
}
51+
52+
public function setUser(): void
53+
{
3154
$this->user = User::first();
32-
$this->company = $this->user->companies()->first();
55+
}
3356

34-
company($this->company->id)->makeCurrent();
57+
public function setCompany(): void
58+
{
59+
$company_id = $this->getRawAttribute('company_id');
60+
61+
$this->company = !empty($company_id) ? Company::find($company_id) : $this->user->companies()->first();
62+
63+
$this->company->makeCurrent();
3564

3665
app('url')->defaults(['company_id' => company_id()]);
3766
}
3867

39-
public function getCompanyUsers()
68+
public function getRawAttribute($key)
4069
{
41-
return $this->company->users()->enabled()->get()->pluck('id')->toArray();
70+
$raw = $this->state([])->getExpandedAttributes(null);
71+
72+
return $raw[$key] ?? null;
4273
}
4374
}

app/Abstracts/Http/ApiController.php

+147-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
use App\Traits\Jobs;
66
use App\Traits\Permissions;
77
use App\Traits\Relationships;
8-
use Dingo\Api\Exception\ResourceException;
9-
use Dingo\Api\Routing\Helpers;
8+
use App\Exceptions\Http\Resource as ResourceException;
109
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
1110
use Illuminate\Foundation\Validation\ValidatesRequests;
11+
use Illuminate\Http\JsonResponse;
1212
use Illuminate\Http\Request;
13+
use Illuminate\Http\Response;
1314
use Illuminate\Routing\Controller as BaseController;
15+
use Symfony\Component\HttpKernel\Exception\HttpException;
1416

1517
abstract class ApiController extends BaseController
1618
{
17-
use AuthorizesRequests, Jobs, Helpers, Permissions, Relationships, ValidatesRequests;
19+
use AuthorizesRequests, Jobs, Permissions, Relationships, ValidatesRequests;
1820

1921
/**
2022
* Instantiate a new controller instance.
@@ -39,4 +41,146 @@ protected function buildFailedValidationResponse(Request $request, array $errors
3941

4042
return redirect()->to($this->getRedirectUrl())->withInput($request->input())->withErrors($errors, $this->errorBag());
4143
}
44+
45+
/**
46+
* Respond with a location and a created resource.
47+
*
48+
* @param string $location
49+
* @param object $resource
50+
*
51+
* @return \Illuminate\Http\JsonResponse
52+
*/
53+
public function created($location, $resource): JsonResponse
54+
{
55+
return $resource
56+
->response()
57+
->setStatusCode(201)
58+
->header('Location', $location);
59+
}
60+
61+
/**
62+
* Respond with a location and an accepted resource.
63+
*
64+
* @param string $location
65+
* @param object $resource
66+
*
67+
* @return \Illuminate\Http\JsonResponse
68+
*/
69+
public function accepted($location, $resource): JsonResponse
70+
{
71+
return $resource
72+
->response()
73+
->setStatusCode(202)
74+
->header('Location', $location);
75+
}
76+
77+
/**
78+
* Respond with empty content.
79+
*
80+
* @return \Illuminate\Http\Response
81+
*/
82+
public function noContent(): Response
83+
{
84+
return (new Response)
85+
->setStatusCode(204);
86+
}
87+
88+
/**
89+
* Return an error response.
90+
*
91+
* @param string $message
92+
* @param int $statusCode
93+
*
94+
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
95+
*
96+
* @return void
97+
*/
98+
public function error($message, $statusCode)
99+
{
100+
throw new HttpException($statusCode, $message);
101+
}
102+
103+
/**
104+
* Return a 404 not found error.
105+
*
106+
* @param string $message
107+
*
108+
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
109+
*
110+
* @return void
111+
*/
112+
public function errorNotFound($message = 'Not Found')
113+
{
114+
$this->error($message, 404);
115+
}
116+
117+
/**
118+
* Return a 400 bad request error.
119+
*
120+
* @param string $message
121+
*
122+
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
123+
*
124+
* @return void
125+
*/
126+
public function errorBadRequest($message = 'Bad Request')
127+
{
128+
$this->error($message, 400);
129+
}
130+
131+
/**
132+
* Return a 403 forbidden error.
133+
*
134+
* @param string $message
135+
*
136+
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
137+
*
138+
* @return void
139+
*/
140+
public function errorForbidden($message = 'Forbidden')
141+
{
142+
$this->error($message, 403);
143+
}
144+
145+
/**
146+
* Return a 500 internal server error.
147+
*
148+
* @param string $message
149+
*
150+
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
151+
*
152+
* @return void
153+
*/
154+
public function errorInternal($message = 'Internal Error')
155+
{
156+
$this->error($message, 500);
157+
}
158+
159+
/**
160+
* Return a 401 unauthorized error.
161+
*
162+
* @param string $message
163+
*
164+
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
165+
*
166+
* @return void
167+
*/
168+
public function errorUnauthorized($message = 'Unauthorized')
169+
{
170+
$this->error($message, 401);
171+
}
172+
173+
/**
174+
* Return a 405 method not allowed error.
175+
*
176+
* @param string $message
177+
*
178+
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
179+
*
180+
* @return void
181+
*/
182+
public function errorMethodNotAllowed($message = 'Method Not Allowed')
183+
{
184+
$this->error($message, 405);
185+
}
42186
}

0 commit comments

Comments
 (0)