1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

In client/invoices show if invoice is paid or not #1545

This commit is contained in:
Hillel Coren 2017-07-27 19:37:09 +03:00
parent 087845a67e
commit f8cc7a5129
3 changed files with 42 additions and 3 deletions

View File

@ -369,7 +369,7 @@ class ClientPortalController extends BaseController
'client' => $contact->client,
'title' => trans('texts.invoices'),
'entityType' => ENTITY_INVOICE,
'columns' => Utils::trans(['invoice_number', 'invoice_date', 'invoice_total', 'balance_due', 'due_date']),
'columns' => Utils::trans(['invoice_number', 'invoice_date', 'invoice_total', 'balance_due', 'due_date', 'status']),
];
return response()->view('public_list', $data);
@ -497,7 +497,7 @@ class ClientPortalController extends BaseController
'account' => $account,
'title' => trans('texts.quotes'),
'entityType' => ENTITY_QUOTE,
'columns' => Utils::trans(['quote_number', 'quote_date', 'quote_total', 'due_date']),
'columns' => Utils::trans(['quote_number', 'quote_date', 'quote_total', 'due_date', 'status']),
];
return response()->view('public_list', $data);

View File

@ -290,6 +290,9 @@ class InvoiceRepository extends BaseRepository
'invoices.invoice_date',
'invoices.balance as balance',
'invoices.due_date',
'invoices.invoice_status_id',
'invoices.due_date',
'invoices.quote_invoice_id',
'clients.public_id as client_public_id',
DB::raw("COALESCE(NULLIF(clients.name,''), NULLIF(CONCAT(contacts.first_name, ' ', contacts.last_name),''), NULLIF(contacts.email,'')) client_name"),
'invoices.public_id',
@ -324,7 +327,35 @@ class InvoiceRepository extends BaseRepository
return $table->addColumn('due_date', function ($model) {
return Utils::fromSqlDate($model->due_date);
})
->make();
->addColumn('status', function ($model) use ($entityType) {
if ($model->invoice_status_id == INVOICE_STATUS_PAID) {
$label = trans('texts.status_paid');
$class = 'success';
} elseif ($model->invoice_status_id == INVOICE_STATUS_PARTIAL) {
$label = trans('texts.status_partial');
$class = 'info';
} elseif (Invoice::calcIsOverdue($model->balance, $model->due_date)) {
$class = 'danger';
if ($entityType == ENTITY_INVOICE) {
$label = trans('texts.overdue');
} else {
$label = trans('texts.expired');
}
} elseif ($entityType == ENTITY_QUOTE && ($model->invoice_status_id >= INVOICE_STATUS_APPROVED || $model->quote_invoice_id)) {
$label = trans('texts.status_approved');
$class = 'success';
} else {
$class = 'default';
if ($entityType == ENTITY_INVOICE) {
$label = trans('texts.unpaid');
} else {
$label = trans('texts.pending');
}
}
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
})
->make();
}
/**

View File

@ -23,6 +23,14 @@
table.table thead .sorting_asc_disabled:after { content: '' !important }
table.table thead .sorting_desc_disabled:after { content: '' !important }
@for ($i = 0; $i < count($columns); $i++)
table.dataTable td:nth-child({{ $i + 1 }}) {
@if ($columns[$i] == trans('texts.status'))
text-align: center;
@endif
}
@endfor
</style>
<div class="container" id="main-container">