Skip to content

Commit

Permalink
fixed #262
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Mar 23, 2018
1 parent f358796 commit 4d05971
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
12 changes: 5 additions & 7 deletions app/Http/Controllers/Expenses/Bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,25 +589,23 @@ 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 = $desc_amount . ' ' . trans_choice('general.payments', 1);

// Add invoice history
// Add bill history
BillHistory::create([
'company_id' => $bill->company_id,
'invoice_id' => $bill->id,
'status_code' => $status,
'bill_id' => $bill->id,
'status_code' => $bill->bill_status_code,
'notify' => 0,
'description' => trans('messages.success.deleted', ['type' => $description]),
]);
Expand Down
10 changes: 4 additions & 6 deletions app/Http/Controllers/Incomes/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,12 @@ public function paymentDestroy(InvoicePayment $payment)
{
$invoice = Invoice::find($payment->invoice_id);

$status = 'sent';

if ($invoice->payments()->count() > 1) {
$status = 'partial';
$invoice->invoice_status_code = 'partial';
} else {
$invoice->invoice_status_code = 'sent';
}

$invoice->invoice_status_code = $status;

$invoice->save();

$desc_amount = money((float) $payment->amount, (string) $payment->currency_code, true)->format();
Expand All @@ -740,7 +738,7 @@ public function paymentDestroy(InvoicePayment $payment)
InvoiceHistory::create([
'company_id' => $invoice->company_id,
'invoice_id' => $invoice->id,
'status_code' => $status,
'status_code' => $invoice->invoice_status_code,
'notify' => 0,
'description' => trans('messages.success.deleted', ['type' => $description]),
]);
Expand Down

0 comments on commit 4d05971

Please sign in to comment.