1
0
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:
David Bomba 2021-09-21 07:22:34 +10:00 committed by GitHub
commit 3babef48a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 45 additions and 15 deletions

View File

@ -693,13 +693,13 @@ class CompanySettings extends BaseSettings
'$invoice.date', '$invoice.date',
'$due_date', '$due_date',
'$total', '$total',
'$outstanding', '$amount',
], ],
'statement_payment_columns' => [ 'statement_payment_columns' => [
'$invoice.number', '$invoice.number',
'$payment.date', '$payment.date',
'$method', '$method',
'$outstanding', '$amount',
], ],
]; ];

View File

@ -110,10 +110,9 @@ class ClientStatementController extends BaseController
public function statement(CreateStatementRequest $request) public function statement(CreateStatementRequest $request)
{ {
$pdf = $request->client()->service()->statement([ $pdf = $request->client()->service()->statement(
'start_date' => $request->start_date, $request->only(['start_date', 'end_date', 'show_payments_table', 'show_aging_table'])
'end_date' => $request->end_date, );
]);
if ($pdf) { if ($pdf) {
return response()->streamDownload(function () use ($pdf) { return response()->streamDownload(function () use ($pdf) {

View File

@ -42,6 +42,11 @@ class CreateStatementRequest extends Request
$input = $this->decodePrimaryKeys($input); $input = $this->decodePrimaryKeys($input);
$this->replace($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 public function client(): ?Client

View File

@ -221,6 +221,7 @@ class Statement
->where('client_id', $this->client->id) ->where('client_id', $this->client->id)
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID]) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID])
->whereBetween('date', [$this->options['start_date'], $this->options['end_date']]) ->whereBetween('date', [$this->options['start_date'], $this->options['end_date']])
->orderBy('number', 'ASC')
->get(); ->get();
} }
@ -235,6 +236,7 @@ class Statement
->where('client_id', $this->client->id) ->where('client_id', $this->client->id)
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED]) ->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])
->whereBetween('date', [$this->options['start_date'], $this->options['end_date']]) ->whereBetween('date', [$this->options['start_date'], $this->options['end_date']])
->orderBy('number', 'ASC')
->get(); ->get();
} }

View File

@ -232,7 +232,7 @@ class Design extends BaseDesign
]], ]],
['element' => 'tr', 'properties' => [], 'elements' => [ ['element' => 'tr', 'properties' => [], 'elements' => [
['element' => 'th', 'properties' => [], 'content' => '$balance_due_label'], ['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 []; return [];
} }
$outstanding = $this->invoices->sum('amount'); $outstanding = $this->invoices->sum('balance');
return [ return [
['element' => 'p', 'content' => '$outstanding_label: $outstanding'], ['element' => 'p', 'content' => '$outstanding_label: ' . Number::formatMoney($outstanding, $this->entity->client)],
]; ];
} }
@ -424,10 +424,14 @@ class Design extends BaseDesign
public function statementPaymentTableTotals(): array public function statementPaymentTableTotals(): array
{ {
if ($this->type !== self::STATEMENT || !$this->payments->first()) { if (is_null($this->payments) && $this->type !== self::STATEMENT) {
return []; return [];
} }
if (\array_key_exists('show_payments_table', $this->options) && $this->options['show_payments_table'] === false) {
return [];
}
$payment = $this->payments->first(); $payment = $this->payments->first();
return [ return [

View File

@ -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 * @return mixed
*/ */
public function getCompiledHTML($final = false) public function getCompiledHTML($final = false)

View File

@ -453,6 +453,9 @@ class HtmlEngine
$data['$payment.date'] = ['value' => ' ', 'label' => ctrans('texts.payment_date')]; $data['$payment.date'] = ['value' => ' ', 'label' => ctrans('texts.payment_date')];
$data['$method'] = ['value' => ' ', 'label' => ctrans('texts.method')]; $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)); $arrKeysLength = array_map('strlen', array_keys($data));
array_multisort($arrKeysLength, SORT_DESC, $data); array_multisort($arrKeysLength, SORT_DESC, $data);

View File

@ -257,6 +257,11 @@
max-height: 160px; max-height: 160px;
} }
#statement-invoice-table-totals > p {
margin-right: 2rem;
margin-top: 1rem;
}
/** Useful snippets, uncomment to enable. **/ /** Useful snippets, uncomment to enable. **/
/** Hide company logo **/ /** Hide company logo **/

View File

@ -345,6 +345,12 @@
? document.getElementById(tableIdentifier).style.display = 'none' ? 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> </script>
</div> </div>

View File

@ -54,8 +54,12 @@
height: 120px; height: 120px;
} }
.company-logo { .company-logo-wrapper {
height: 100%; padding-bottom: 60px;
}
.company-logo-wrapper {
height: 5rem;
} }
.header-invoice-number { .header-invoice-number {
@ -266,8 +270,10 @@
</div> </div>
<div class="logo-and-partial-entity-info"> <div class="logo-and-partial-entity-info">
<img class="company-logo" src="$company.logo" <div class="company-logo-wrapper">
<img class="company-logo" src="$company.logo"
alt="$company.name logo"> alt="$company.name logo">
</div>
<div class="top-right-side-section"> <div class="top-right-side-section">
<div dir="$dir"> <div dir="$dir">
<span class="header-payment-due-label">$payment_due_label:</span> <span class="header-payment-due-label">$payment_due_label:</span>