mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 05:32:39 +01:00
Merge pull request #6659 from beganovich/v5-647
Statements improvements
This commit is contained in:
commit
3babef48a0
@ -693,13 +693,13 @@ class CompanySettings extends BaseSettings
|
||||
'$invoice.date',
|
||||
'$due_date',
|
||||
'$total',
|
||||
'$outstanding',
|
||||
'$amount',
|
||||
],
|
||||
'statement_payment_columns' => [
|
||||
'$invoice.number',
|
||||
'$payment.date',
|
||||
'$method',
|
||||
'$outstanding',
|
||||
'$amount',
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -110,10 +110,9 @@ class ClientStatementController extends BaseController
|
||||
|
||||
public function statement(CreateStatementRequest $request)
|
||||
{
|
||||
$pdf = $request->client()->service()->statement([
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->end_date,
|
||||
]);
|
||||
$pdf = $request->client()->service()->statement(
|
||||
$request->only(['start_date', 'end_date', 'show_payments_table', 'show_aging_table'])
|
||||
);
|
||||
|
||||
if ($pdf) {
|
||||
return response()->streamDownload(function () use ($pdf) {
|
||||
|
@ -42,6 +42,11 @@ class CreateStatementRequest extends Request
|
||||
$input = $this->decodePrimaryKeys($input);
|
||||
|
||||
$this->replace($input);
|
||||
|
||||
$this->merge([
|
||||
'show_payments_table' => $this->has('show_payments_table') ? \boolval($this->show_payments_table) : false,
|
||||
'show_aging_table' => $this->has('show_aging_table') ? \boolval($this->show_aging_table) : false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function client(): ?Client
|
||||
|
@ -221,6 +221,7 @@ class Statement
|
||||
->where('client_id', $this->client->id)
|
||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID])
|
||||
->whereBetween('date', [$this->options['start_date'], $this->options['end_date']])
|
||||
->orderBy('number', 'ASC')
|
||||
->get();
|
||||
}
|
||||
|
||||
@ -235,6 +236,7 @@ class Statement
|
||||
->where('client_id', $this->client->id)
|
||||
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])
|
||||
->whereBetween('date', [$this->options['start_date'], $this->options['end_date']])
|
||||
->orderBy('number', 'ASC')
|
||||
->get();
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ class Design extends BaseDesign
|
||||
]],
|
||||
['element' => 'tr', 'properties' => [], 'elements' => [
|
||||
['element' => 'th', 'properties' => [], 'content' => '$balance_due_label'],
|
||||
['element' => 'th', 'properties' => [], 'content' => '$balance_due'],
|
||||
['element' => 'th', 'properties' => [], 'content' => Number::formatMoney($this->invoices->sum('balance'), $this->entity->client)],
|
||||
]],
|
||||
];
|
||||
}
|
||||
@ -379,10 +379,10 @@ class Design extends BaseDesign
|
||||
return [];
|
||||
}
|
||||
|
||||
$outstanding = $this->invoices->sum('amount');
|
||||
$outstanding = $this->invoices->sum('balance');
|
||||
|
||||
return [
|
||||
['element' => 'p', 'content' => '$outstanding_label: $outstanding'],
|
||||
['element' => 'p', 'content' => '$outstanding_label: ' . Number::formatMoney($outstanding, $this->entity->client)],
|
||||
];
|
||||
}
|
||||
|
||||
@ -424,7 +424,11 @@ class Design extends BaseDesign
|
||||
|
||||
public function statementPaymentTableTotals(): array
|
||||
{
|
||||
if ($this->type !== self::STATEMENT || !$this->payments->first()) {
|
||||
if (is_null($this->payments) && $this->type !== self::STATEMENT) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (\array_key_exists('show_payments_table', $this->options) && $this->options['show_payments_table'] === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,9 @@ class PdfMaker
|
||||
}
|
||||
|
||||
/**
|
||||
* Return compiled HTML.
|
||||
* Final method to get compiled HTML.
|
||||
*
|
||||
* @param bool $final deprecated
|
||||
* @param bool $final @deprecated
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCompiledHTML($final = false)
|
||||
|
@ -453,6 +453,9 @@ class HtmlEngine
|
||||
$data['$payment.date'] = ['value' => ' ', 'label' => ctrans('texts.payment_date')];
|
||||
$data['$method'] = ['value' => ' ', 'label' => ctrans('texts.method')];
|
||||
|
||||
$data['$amount'] = ['value' => '', 'label' => ctrans('texts.amount')];
|
||||
$data['$statement'] = ['value' => '', 'label' => ctrans('texts.statement')];
|
||||
|
||||
$arrKeysLength = array_map('strlen', array_keys($data));
|
||||
array_multisort($arrKeysLength, SORT_DESC, $data);
|
||||
|
||||
|
@ -257,6 +257,11 @@
|
||||
max-height: 160px;
|
||||
}
|
||||
|
||||
#statement-invoice-table-totals > p {
|
||||
margin-right: 2rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
/** Useful snippets, uncomment to enable. **/
|
||||
|
||||
/** Hide company logo **/
|
||||
|
@ -345,6 +345,12 @@
|
||||
? document.getElementById(tableIdentifier).style.display = 'none'
|
||||
: '';
|
||||
});
|
||||
|
||||
// If we have elements in these tables, we can change label to "Statement" & hide entity details.
|
||||
if (document.querySelectorAll('#statement-payment-table > tbody, #statement-payment-table > tbody, #statement-aging-table-totals > tbody').length > 0) {
|
||||
document.querySelector('.entity-label').innerText = '$statement_label';
|
||||
document.querySelector('.entity-details-wrapper').style.display = 'none';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
@ -54,8 +54,12 @@
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.company-logo {
|
||||
height: 100%;
|
||||
.company-logo-wrapper {
|
||||
padding-bottom: 60px;
|
||||
}
|
||||
|
||||
.company-logo-wrapper {
|
||||
height: 5rem;
|
||||
}
|
||||
|
||||
.header-invoice-number {
|
||||
@ -266,8 +270,10 @@
|
||||
</div>
|
||||
|
||||
<div class="logo-and-partial-entity-info">
|
||||
<div class="company-logo-wrapper">
|
||||
<img class="company-logo" src="$company.logo"
|
||||
alt="$company.name logo">
|
||||
</div>
|
||||
<div class="top-right-side-section">
|
||||
<div dir="$dir">
|
||||
<span class="header-payment-due-label">$payment_due_label:</span>
|
||||
|
Loading…
Reference in New Issue
Block a user