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
25 changed files with 290 additions and 92 deletions

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);