Merge branch '1.3-dev' of github.com:akaunting/akaunting into tax-rate

This commit is contained in:
cuneytsenturk 2018-11-07 11:19:52 +03:00
commit 49112ce50f
25 changed files with 290 additions and 92 deletions

View File

@ -26,3 +26,5 @@ MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_NAME=null
MAIL_FROM_ADDRESS=null

View File

@ -0,0 +1,78 @@
<?php
namespace App\Console\Commands;
use App\Models\Module\Module;
use App\Models\Module\ModuleHistory;
use Artisan;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
class ModuleDelete extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'module:delete {alias} {company_id}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete the specified module.';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$alias = $this->argument('alias');
$company_id = $this->argument('company_id');
$model = Module::alias($alias)->companyId($company_id)->first();
if (!$model) {
$this->info("Module [{$alias}] not found.");
return;
}
$module = $this->laravel['modules']->findByAlias($alias);
$module->delete();
$model->status = 0;
$model->save();
// Add history
$data = [
'company_id' => $company_id,
'module_id' => $model->id,
'category' => $module->get('category'),
'version' => $module->get('version'),
'description' => trans('modules.deleted', ['module' => $module->get('name')]),
];
ModuleHistory::create($data);
Artisan::call('cache:clear');
$this->info("Module [{$alias}] deleted.");
}
/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return array(
array('alias', InputArgument::REQUIRED, 'Module alias.'),
array('company_id', InputArgument::REQUIRED, 'Company ID.'),
);
}
}

View File

@ -13,10 +13,11 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
Commands\CompanySeed::class,
Commands\BillReminder::class,
Commands\CompanySeed::class,
Commands\Install::class,
Commands\InvoiceReminder::class,
Commands\ModuleDelete::class,
Commands\ModuleDisable::class,
Commands\ModuleEnable::class,
Commands\ModuleInstall::class,

View File

@ -267,7 +267,7 @@ class Bills extends Controller
$excel->sheet('bills', function ($sheet) use ($bills) {
$sheet->fromModel($bills->makeHidden([
'company_id', 'parent_id', 'created_at', 'updated_at', 'deleted_at', 'attachment', 'discount', 'items', 'histories', 'payments', 'totals', 'media'
'company_id', 'parent_id', 'created_at', 'updated_at', 'deleted_at', 'attachment', 'discount', 'items', 'histories', 'payments', 'totals', 'media', 'paid'
]));
});

View File

@ -279,7 +279,7 @@ class Invoices extends Controller
$excel->sheet('invoices', function ($sheet) use ($invoices) {
$sheet->fromModel($invoices->makeHidden([
'company_id', 'parent_id', 'created_at', 'updated_at', 'deleted_at', 'attachment', 'discount', 'items', 'histories', 'payments', 'totals', 'media'
'company_id', 'parent_id', 'created_at', 'updated_at', 'deleted_at', 'attachment', 'discount', 'items', 'histories', 'payments', 'totals', 'media', 'paid'
]));
});

View File

@ -104,7 +104,7 @@ class TaxSummary extends Controller
private function setAmount(&$items, &$totals, $rows, $type, $date_field)
{
foreach ($rows as $row) {
if ($row['table'] == 'bill_payments' || $row['table'] == 'invoice_payments') {
if ($row->getTable() == 'bill_payments' || $row->getTable() == 'invoice_payments') {
$type_row = $row->$type;
$row->category_id = $type_row->category_id;
@ -127,7 +127,14 @@ class TaxSummary extends Controller
continue;
}
$amount = $this->convert($row_total->amount, $row->currency_code, $row->currency_rate);
if ($date_field == 'paid_at') {
$rate = ($row->amount * 100) / $type_row->amount;
$row_amount = ($row_total->amount / 100) * $rate;
} else {
$row_amount = $row_total->amount;
}
$amount = $this->convert($row_amount, $row->currency_code, $row->currency_rate);
$items[$row_total->name][$date]['amount'] += $amount;

View File

@ -181,17 +181,17 @@ class Settings extends Controller
protected function oneCompany($key, $value)
{
switch ($key) {
case 'company_name':
Installer::updateEnv(['MAIL_FROM_NAME' => '"' . $value . '"']);
break;
case 'company_email':
Installer::updateEnv(['MAIL_FROM_ADDRESS' => $value]);
break;
case 'default_locale':
// Change default locale
Installer::updateEnv([
'APP_LOCALE' => $value
]);
Installer::updateEnv(['APP_LOCALE' => $value]);
break;
case 'session_handler':
// Change session handler
Installer::updateEnv([
'SESSION_DRIVER' => $value
]);
Installer::updateEnv(['SESSION_DRIVER' => $value]);
break;
}
}

View File

@ -43,11 +43,9 @@ class Reset extends Notification
*/
public function toMail($notifiable)
{
setting(['general.company_name' => config('app.name')]);
return (new MailMessage)
->line(trans('auth.notification.message_1'))
->action(trans('auth.notification.button'), url('auth/reset', $this->token, true))
->action(trans('auth.notification.button'), url('auth/reset', $this->token))
->line(trans('auth.notification.message_2'));
}
}

View File

@ -45,7 +45,7 @@ class Item extends Notification
{
$message = (new MailMessage)
->line(trans('items.notification.message.out_of_stock', ['name' => $this->item->name]))
->action(trans('items.notification.button'), url('items/items', $this->item->id, true));
->action(trans('items.notification.button'), url('items/items', $this->item->id));
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));

View File

@ -45,7 +45,7 @@ class ItemReminder extends Notification
{
$message = (new MailMessage)
->line(trans('items.notification.message.reminder', ['name' => $this->item->name, 'quantity' => $this->item->quantity]))
->action(trans('items.notification.button'), url('items/items', $this->item->id, true));
->action(trans('items.notification.button'), url('items/items', $this->item->id));
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));

View File

@ -62,7 +62,7 @@ class Invoice extends Notification
]);
}
$message->action(trans('customers.notification.button'), url('incomes/invoices', $this->invoice->id, true));
$message->action(trans('customers.notification.button'), url('incomes/invoices', $this->invoice->id));
return $message;
}

View File

@ -48,7 +48,7 @@ class Bill extends Notification
{
$message = (new MailMessage)
->line('You are receiving this email because you have an upcoming ' . money($this->bill->amount, $this->bill->currency_code, true) . ' bill to ' . $this->bill->vendor_name . ' vendor.')
->action('Add Payment', url('expenses/bills', $this->bill->id, true));
->action('Add Payment', url('expenses/bills', $this->bill->id));
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));

View File

@ -60,7 +60,7 @@ class Invoice extends Notification
}
if ($this->invoice->customer->user) {
$message->action(trans('invoices.notification.button'), url('customers/invoices', $this->invoice->id, true));
$message->action(trans('invoices.notification.button'), url('customers/invoices', $this->invoice->id));
}
return $message;

View File

@ -269,16 +269,24 @@ class Installer
$env = explode("\n", $env);
foreach ($data as $data_key => $data_value) {
$updated = false;
foreach ($env as $env_key => $env_value) {
$entry = explode('=', $env_value, 2);
// Check if new or old key
if ($entry[0] == $data_key) {
$env[$env_key] = $data_key . '=' . $data_value;
$updated = true;
} else {
$env[$env_key] = $env_value;
}
}
// Lets create if not available
if (!$updated) {
$env[] = $data_key . '=' . $data_value;
}
}
$env = implode("\n", $env);

102
composer.lock generated
View File

@ -66,16 +66,16 @@
},
{
"name": "akaunting/money",
"version": "1.0.6",
"version": "1.0.7",
"source": {
"type": "git",
"url": "https://github.com/akaunting/money.git",
"reference": "d56221b2cbf4771c50da0c2e0273869cc659ed2e"
"reference": "e5d038fe38f6400261dfff6f7ed0e0a8245719af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/akaunting/money/zipball/d56221b2cbf4771c50da0c2e0273869cc659ed2e",
"reference": "d56221b2cbf4771c50da0c2e0273869cc659ed2e",
"url": "https://api.github.com/repos/akaunting/money/zipball/e5d038fe38f6400261dfff6f7ed0e0a8245719af",
"reference": "e5d038fe38f6400261dfff6f7ed0e0a8245719af",
"shasum": ""
},
"require": {
@ -123,7 +123,7 @@
"laravel",
"money"
],
"time": "2018-09-01T11:56:07+00:00"
"time": "2018-11-04T07:12:33+00:00"
},
{
"name": "akaunting/setting",
@ -2764,16 +2764,16 @@
},
{
"name": "monolog/monolog",
"version": "1.23.0",
"version": "1.24.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4"
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
"reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"shasum": ""
},
"require": {
@ -2838,7 +2838,7 @@
"logging",
"psr-3"
],
"time": "2017-06-19T01:22:40+00:00"
"time": "2018-11-05T09:00:11+00:00"
},
{
"name": "mtdowling/cron-expression",
@ -4209,16 +4209,16 @@
},
{
"name": "symfony/class-loader",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/class-loader.git",
"reference": "f31333bdff54c7595f834d510a6d2325573ddb36"
"reference": "5605edec7b8f034ead2497ff4aab17bb70d558c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/class-loader/zipball/f31333bdff54c7595f834d510a6d2325573ddb36",
"reference": "f31333bdff54c7595f834d510a6d2325573ddb36",
"url": "https://api.github.com/repos/symfony/class-loader/zipball/5605edec7b8f034ead2497ff4aab17bb70d558c1",
"reference": "5605edec7b8f034ead2497ff4aab17bb70d558c1",
"shasum": ""
},
"require": {
@ -4261,20 +4261,20 @@
],
"description": "Symfony ClassLoader Component",
"homepage": "https://symfony.com",
"time": "2018-10-02T12:28:39+00:00"
"time": "2018-10-31T09:06:03+00:00"
},
{
"name": "symfony/console",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b"
"reference": "1d228fb4602047d7b26a0554e0d3efd567da5803"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b",
"reference": "3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b",
"url": "https://api.github.com/repos/symfony/console/zipball/1d228fb4602047d7b26a0554e0d3efd567da5803",
"reference": "1d228fb4602047d7b26a0554e0d3efd567da5803",
"shasum": ""
},
"require": {
@ -4330,11 +4330,11 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-10-02T16:33:53+00:00"
"time": "2018-10-30T16:50:50+00:00"
},
{
"name": "symfony/css-selector",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
@ -4387,16 +4387,16 @@
},
{
"name": "symfony/debug",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "0a612e9dfbd2ccce03eb174365f31ecdca930ff6"
"reference": "fe9793af008b651c5441bdeab21ede8172dab097"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/0a612e9dfbd2ccce03eb174365f31ecdca930ff6",
"reference": "0a612e9dfbd2ccce03eb174365f31ecdca930ff6",
"url": "https://api.github.com/repos/symfony/debug/zipball/fe9793af008b651c5441bdeab21ede8172dab097",
"reference": "fe9793af008b651c5441bdeab21ede8172dab097",
"shasum": ""
},
"require": {
@ -4439,20 +4439,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2018-10-02T16:33:53+00:00"
"time": "2018-10-31T09:06:03+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb"
"reference": "db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb",
"reference": "b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14",
"reference": "db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14",
"shasum": ""
},
"require": {
@ -4502,11 +4502,11 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2018-07-26T09:06:28+00:00"
"time": "2018-10-30T16:50:50+00:00"
},
{
"name": "symfony/finder",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
@ -4555,16 +4555,16 @@
},
{
"name": "symfony/http-foundation",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "3a4498236ade473c52b92d509303e5fd1b211ab1"
"reference": "5aea7a86ca3203dd7a257e765b4b9c9cfd01c6c0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/3a4498236ade473c52b92d509303e5fd1b211ab1",
"reference": "3a4498236ade473c52b92d509303e5fd1b211ab1",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/5aea7a86ca3203dd7a257e765b4b9c9cfd01c6c0",
"reference": "5aea7a86ca3203dd7a257e765b4b9c9cfd01c6c0",
"shasum": ""
},
"require": {
@ -4605,20 +4605,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2018-10-03T08:48:18+00:00"
"time": "2018-10-31T08:57:11+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "a0944a9a1d8845da724236cde9a310964acadb1c"
"reference": "4bf0be7c7fe63eff6a5eae2f21c83e77e31a56fb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/a0944a9a1d8845da724236cde9a310964acadb1c",
"reference": "a0944a9a1d8845da724236cde9a310964acadb1c",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/4bf0be7c7fe63eff6a5eae2f21c83e77e31a56fb",
"reference": "4bf0be7c7fe63eff6a5eae2f21c83e77e31a56fb",
"shasum": ""
},
"require": {
@ -4694,7 +4694,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2018-10-03T12:03:34+00:00"
"time": "2018-11-03T10:03:02+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -4982,16 +4982,16 @@
},
{
"name": "symfony/process",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "1dc2977afa7d70f90f3fefbcd84152813558910e"
"reference": "35c2914a9f50519bd207164c353ae4d59182c2cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/1dc2977afa7d70f90f3fefbcd84152813558910e",
"reference": "1dc2977afa7d70f90f3fefbcd84152813558910e",
"url": "https://api.github.com/repos/symfony/process/zipball/35c2914a9f50519bd207164c353ae4d59182c2cb",
"reference": "35c2914a9f50519bd207164c353ae4d59182c2cb",
"shasum": ""
},
"require": {
@ -5027,11 +5027,11 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2018-10-02T12:28:39+00:00"
"time": "2018-10-14T17:33:21+00:00"
},
{
"name": "symfony/routing",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
@ -5108,7 +5108,7 @@
},
{
"name": "symfony/translation",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
@ -5176,7 +5176,7 @@
},
{
"name": "symfony/var-dumper",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
@ -6608,7 +6608,7 @@
},
{
"name": "symfony/yaml",
"version": "v3.4.17",
"version": "v3.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",

View File

@ -14,11 +14,11 @@ return [
'build' => '',
'status' => 'RC 2',
'status' => 'RC 3',
'date' => '02-November-2018',
'date' => '06-November-2018',
'time' => '18:30',
'time' => '10:30',
'zone' => 'GMT +3',

13
public/css/app.css vendored
View File

@ -770,12 +770,13 @@ input[type="number"] {
border-radius: 0;
}
#tax-add-new {
padding: 6px 12px;
}
#items .select2-search__field {
padding-left: 15px;
margin-top: 6px;
}
#tax-add-new {
padding: 6px 12px;
}
.stepwizard-step p {
@ -866,6 +867,10 @@ input[type="number"] {
min-height: 30px !important;
}
.box-filter .select2-search__field {
font-size: 12px !important;
}
/* App Detail Page Sliders Start */
.row.module #description .img-fluid.d-block.w-100 {
height: 420px;

View File

@ -48,6 +48,7 @@
</thead>
<tbody>
@foreach($bills as $item)
@php $paid = $item->paid; @endphp
<tr>
<td><a href="{{ url('expenses/bills/' . $item->id . ' ') }}">{{ $item->bill_number }}</a></td>
<td>{{ $item->vendor_name }}</td>
@ -62,7 +63,7 @@
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="{{ url('expenses/bills/' . $item->id) }}">{{ trans('general.show') }}</a></li>
@if ($item->paid && !$item->reconciled)
@if (!$item->reconciled)
<li><a href="{{ url('expenses/bills/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
@endif
@permission('create-expenses-bills')

View File

@ -47,6 +47,7 @@
</thead>
<tbody>
@foreach($invoices as $item)
@php $paid = $item->paid; @endphp
<tr>
<td><a href="{{ url('incomes/invoices/' . $item->id . ' ') }}">{{ $item->invoice_number }}</a></td>
<td>{{ $item->customer_name }}</td>
@ -61,7 +62,7 @@
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="{{ url('incomes/invoices/' . $item->id) }}">{{ trans('general.show') }}</a></li>
@if ($item->paid && !$item->reconciled)
@if (!$item->reconciled)
<li><a href="{{ url('incomes/invoices/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
@endif
@permission('create-incomes-invoices')

View File

@ -2,7 +2,7 @@
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ setting('general.company_name', config('app.name')) }}
{{ setting('general.company_name', config('mail.from.name', config('app.name'))) }}
@endcomponent
@endslot
@ -21,7 +21,7 @@
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
&copy; {{ date('Y') }} {{ setting('general.company_name', config('app.name')) }}. All rights reserved.
&copy; {{ date('Y') }} {{ setting('general.company_name', config('mail.from.name', config('app.name'))) }}. All rights reserved.
@endcomponent
@endslot
@endcomponent

View File

@ -2,7 +2,7 @@
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ setting('general.company_name', config('app.name')) }}
{{ setting('general.company_name', config('mail.from.name', config('app.name'))) }}
@endcomponent
@endslot
@ -21,7 +21,7 @@
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
© {{ date('Y') }} {{ setting('general.company_name', config('app.name')) }}. All rights reserved.
© {{ date('Y') }} {{ setting('general.company_name', config('mail.from.name', config('app.name'))) }}. All rights reserved.
@endcomponent
@endslot
@endcomponent

View File

@ -45,7 +45,7 @@
@if (! empty($salutation))
{{ $salutation }}
@else
{!! trans('notifications.salutation', ['company_name' => setting('general.company_name', config('app.name'))]) !!}
{!! trans('notifications.salutation', ['company_name' => setting('general.company_name', config('mail.from.name', config('app.name')))]) !!}
@endif
<!-- Subcopy -->

View File

@ -0,0 +1,90 @@
<?php
namespace Tests\Feature\Banking;
use App\Models\Banking\Account;
use Tests\Feature\FeatureTestCase;
class AccountsTest extends FeatureTestCase
{
public function testItShouldSeeAccountListPage()
{
$this->loginAs()
->get(route('accounts.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.accounts', 2));
}
public function testItShouldSeeAccountCreatePage()
{
$this->loginAs()
->get(route('accounts.create'))
->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.accounts', 1)]));
}
public function testItShouldCreateAccount()
{
$this->loginAs()
->post(url('banking/accounts'), $this->getAccountRequest())
->assertStatus(302)
->assertRedirect(url('banking/accounts'));
$this->assertFlashLevel('success');
}
public function testItShouldSeeAccountUpdatePage()
{
$account = Account::create($this->getAccountRequest());
$this->loginAs()
->get(route('accounts.edit', ['account' => $account->id]))
->assertStatus(200)
->assertSee($account->name);
}
public function testItShouldUpdateAccount()
{
$request = $this->getAccountRequest();
$account= Account::create($request);
$request['name'] = $this->faker->text(5);
$this->loginAs()
->patch(url('banking/accounts', $account->id), $request)
->assertStatus(302)
->assertRedirect(url('banking/accounts'));
$this->assertFlashLevel('success');
}
public function testItShouldDeleteAccount()
{
$account = Account::create($this->getAccountRequest());
$this->loginAs()
->delete(route('accounts.destroy', ['account' => $account]))
->assertStatus(302)
->assertRedirect(route('accounts.index'));
$this->assertFlashLevel('success');
}
private function getAccountRequest()
{
return[
'company_id' => $this->company->id,
'name' => $this->faker->text(5),
'number' => '1',
'currency_code' => setting('general.default_currency'),
'opening_balance' => 0,
'bank_name' => $this->faker->text(5),
'bank_phone' => null,
'bank_address' => null,
'default_account' => $this->faker->randomElement(['yes', 'no']),
'enabled' => $this->faker->boolean ? 1 : 0,
];
}
}

View File

@ -87,7 +87,7 @@ class BillsTest extends FeatureTestCase
{
$amount = $this->faker->randomFloat(2, 2);
$items = [['name' => 'urun', 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD', 'tax_id' => null]];
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD', 'tax_id' => null]];
$data = [
'vendor_id' => '0',

View File

@ -58,6 +58,7 @@ class InvoicesTest extends FeatureTestCase
->assertStatus(302);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteInvoice()
@ -70,20 +71,24 @@ class InvoicesTest extends FeatureTestCase
->assertRedirect(url('incomes/invoices'));
$this->assertFlashLevel('success');
}
private function getInvoiceRequest($recurring = 0)
{
$amount = $this->faker->randomFloat(2, 2);
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];
$data = [
'company_id' => $this->company->id,
'customer_id' => '0',
'currency_code' => setting('general.default_currency'),
'currency_rate' => '1',
'invoiced_at' => $this->faker->date(),
'due_at' => $this->faker->date(),
'invoice_number' => $this->faker->lexify('INV ???'),
'order_number' => $this->faker->randomDigit,
'invoice_number' => '1',
'order_number' => '1',
'currency_code' => setting('general.default_currency'),
'currency_rate' => '1',
'item' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
@ -95,6 +100,7 @@ class InvoicesTest extends FeatureTestCase
'customer_address' => $this->faker->address,
'invoice_status_code' => 'draft',
'amount' => $amount,
'company_id' => $this->company->id,
];
if ($recurring) {
@ -103,6 +109,7 @@ class InvoicesTest extends FeatureTestCase
$data['recurring_custom_frequency'] = $this->faker->randomElement(['monthly', 'weekly']);
$data['recurring_count'] = '1';
}
return $data;
}
}