This commit is contained in:
cuneytsenturk 2018-03-13 18:53:18 +03:00
parent e0dd01eb71
commit 7cf3b5d909
8 changed files with 15 additions and 77 deletions

View File

@ -589,26 +589,27 @@ class Bills extends Controller
{
$bill = Bill::find($payment->bill_id);
$status = 'received';
if ($bill->payments()->count() > 1) {
$bill->bill_status_code = 'partial';
} else {
$bill->bill_status_code = 'received';
}
$bill->bill_status_code = $status;
$bill->save();
$desc_amount = money((float) $payment->amount, (string) $payment->currency_code, true)->format();
$description = trans('general.delete') . ' ';
$description .= $desc_amount . ' ' . trans_choice('general.payments', 1);
$description = $desc_amount . ' ' . trans_choice('general.payments', 1);
// Add invoice history
BillHistory::create([
'company_id' => $bill->company_id,
'invoice_id' => $bill->id,
'status_code' => 'delete',
'status_code' => $status,
'notify' => 0,
'description' => $description,
'description' => trans('messages.success.deleted', ['type' => $description]),
]);
$payment->delete();

View File

@ -722,26 +722,27 @@ class Invoices extends Controller
{
$invoice = Invoice::find($payment->invoice_id);
$status = 'sent';
if ($invoice->payments()->count() > 1) {
$invoice->invoice_status_code = 'partial';
} else {
$invoice->invoice_status_code = 'sent';
$status = 'partial';
}
$invoice->invoice_status_code = $status;
$invoice->save();
$desc_amount = money((float) $payment->amount, (string) $payment->currency_code, true)->format();
$description = trans('general.delete') . ' ';
$description .= $desc_amount . ' ' . trans_choice('general.payments', 1);
$description = $desc_amount . ' ' . trans_choice('general.payments', 1);
// Add invoice history
InvoiceHistory::create([
'company_id' => $invoice->company_id,
'invoice_id' => $invoice->id,
'status_code' => 'delete',
'status_code' => $status,
'notify' => 0,
'description' => $description,
'description' => trans('messages.success.deleted', ['type' => $description]),
]);
$payment->delete();

View File

@ -1,51 +0,0 @@
<?php
namespace App\Listeners\Updates;
use App\Events\UpdateFinished;
use App\Models\Company\Company;
use App\Models\Income\InvoiceStatus;
use App\Models\Expense\BillStatus;
use Artisan;
class Version1115 extends Listener
{
const ALIAS = 'core';
const VERSION = '1.1.15';
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
{
// Check if should listen
if (!$this->check($event)) {
return;
}
// Create new bill statuses
$companies = Company::all();
foreach ($companies as $company) {
$invoice = [
'company_id' => $company->id,
'name' => trans('invoices.status.delete'),
'code' => 'delete',
];
InvoiceStatus::create($invoice);
$bill = [
'company_id' => $company->id,
'name' => trans('bills.status.delete'),
'code' => 'delete',
];
BillStatus::create($bill);
}
}
}

View File

@ -22,7 +22,6 @@ class EventServiceProvider extends ServiceProvider
'App\Listeners\Updates\Version112',
'App\Listeners\Updates\Version113',
'App\Listeners\Updates\Version119',
'App\Listeners\Updates\Version1115',
],
'Illuminate\Auth\Events\Login' => [
'App\Listeners\Auth\Login',

View File

@ -43,11 +43,6 @@ class BillStatuses extends Seeder
'name' => trans('bills.status.partial'),
'code' => 'partial',
],
[
'company_id' => $company_id,
'name' => trans('bills.status.delete'),
'code' => 'delete',
],
[
'company_id' => $company_id,
'name' => trans('bills.status.paid'),

View File

@ -53,11 +53,6 @@ class InvoiceStatuses extends Seeder
'name' => trans('invoices.status.partial'),
'code' => 'partial',
],
[
'company_id' => $company_id,
'name' => trans('invoices.status.delete'),
'code' => 'delete',
],
[
'company_id' => $company_id,
'name' => trans('invoices.status.paid'),

View File

@ -31,7 +31,6 @@ return [
'draft' => 'Draft',
'received' => 'Received',
'partial' => 'Partial',
'delete' => 'Delete',
'paid' => 'Paid',
],

View File

@ -33,7 +33,6 @@ return [
'viewed' => 'Viewed',
'approved' => 'Approved',
'partial' => 'Partial',
'delete' => 'Delete',
'paid' => 'Paid',
],