1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Bug fixes

This commit is contained in:
Hillel Coren 2014-05-25 19:23:07 +03:00
parent 36114d251f
commit d4c31e3bbe
4 changed files with 19 additions and 5 deletions

View File

@ -85,8 +85,7 @@ class InvoiceController extends \BaseController {
public function view($invitationKey)
{
$invitation = Invitation::withTrashed()->with('user', 'invoice.invoice_items', 'invoice.account.country', 'invoice.client.contacts', 'invoice.client.country')
->where('invitation_key', '=', $invitationKey)->firstOrFail();
$invitation = Invitation::withTrashed()->where('invitation_key', '=', $invitationKey)->firstOrFail();
$invoice = $invitation->invoice;
@ -95,6 +94,18 @@ class InvoiceController extends \BaseController {
return View::make('invoices.deleted');
}
if ($invoice->is_quote && $invoice->quote_invoice_id)
{
$invoice = Invoice::scope($invoice->quote_invoice_id, $invoice->account_id)->firstOrFail();
if (!$invoice || $invoice->is_deleted)
{
return View::make('invoices.deleted');
}
}
$invoice->load('user', 'invoice_items', 'account.country', 'client.contacts', 'client.country');
$client = $invoice->client;
if (!$client || $client->is_deleted)

View File

@ -431,9 +431,6 @@ class PaymentController extends \BaseController
$payment->save();
$invoice->invoice_status_id = INVOICE_STATUS_PAID;
$invoice->save();
Event::fire('invoice.paid', $payment);
return $payment;

View File

@ -289,6 +289,7 @@ class Activity extends Eloquent
$invoice = $payment->invoice;
$invoice->balance = $invoice->balance - $payment->amount;
$invoice->invoice_status_id = ($invoice->balance > 0) ? INVOICE_STATUS_PARTIAL : INVOICE_STATUS_PAID;
$invoice->save();
}

View File

@ -7,6 +7,11 @@ class Invoice extends EntityModel
return $this->belongsTo('Account');
}
public function user()
{
return $this->belongsTo('User');
}
public function client()
{
return $this->belongsTo('Client')->withTrashed();