Skip to content

Commit

Permalink
refs #252
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Mar 13, 2018
1 parent e0dd01e commit 7cf3b5d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 77 deletions.
13 changes: 7 additions & 6 deletions app/Http/Controllers/Expenses/Bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,26 +589,27 @@ public function paymentDestroy(BillPayment $payment)
{
$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();
Expand Down
15 changes: 8 additions & 7 deletions app/Http/Controllers/Incomes/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,26 +722,27 @@ public function paymentDestroy(InvoicePayment $payment)
{
$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();
Expand Down
51 changes: 0 additions & 51 deletions app/Listeners/Updates/Version1115.php

This file was deleted.

1 change: 0 additions & 1 deletion app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 0 additions & 5 deletions database/seeds/BillStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ private function create()
'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'),
Expand Down
5 changes: 0 additions & 5 deletions database/seeds/InvoiceStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ private function create()
'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'),
Expand Down
1 change: 0 additions & 1 deletion resources/lang/en-GB/bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
'draft' => 'Draft',
'received' => 'Received',
'partial' => 'Partial',
'delete' => 'Delete',
'paid' => 'Paid',
],

Expand Down
1 change: 0 additions & 1 deletion resources/lang/en-GB/invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
'viewed' => 'Viewed',
'approved' => 'Approved',
'partial' => 'Partial',
'delete' => 'Delete',
'paid' => 'Paid',
],

Expand Down

0 comments on commit 7cf3b5d

Please sign in to comment.