mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Working on statements
This commit is contained in:
parent
e51baa4058
commit
898a64288c
@ -26,7 +26,7 @@ class GenerateStatementData
|
||||
$client = $this->client;
|
||||
$client->load('contacts');
|
||||
$account = $client->account;
|
||||
|
||||
|
||||
$invoice = new Invoice();
|
||||
$invoice->account = $account;
|
||||
$invoice->client = $client;
|
||||
@ -35,7 +35,8 @@ class GenerateStatementData
|
||||
$invoice->invoice_items = $this->getInvoices();
|
||||
|
||||
if ($this->options['show_payments']) {
|
||||
$invoice->invoice_items = $invoice->invoice_items->merge($this->getPayments());
|
||||
$payments = $this->getPayments($invoice->invoice_items);
|
||||
$invoice->invoice_items = $invoice->invoice_items->merge($payments);
|
||||
}
|
||||
|
||||
return json_encode($invoice);
|
||||
@ -75,6 +76,7 @@ class GenerateStatementData
|
||||
for ($i=0; $i<$invoices->count(); $i++) {
|
||||
$invoice = $invoices[$i];
|
||||
$item = new InvoiceItem();
|
||||
$item->id = $invoice->id;
|
||||
$item->product_key = $invoice->invoice_number;
|
||||
$item->custom_value1 = $invoice->invoice_date;
|
||||
$item->custom_value2 = $invoice->due_date;
|
||||
@ -93,7 +95,7 @@ class GenerateStatementData
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getPayments()
|
||||
private function getPayments($invoices)
|
||||
{
|
||||
$payments = Payment::with('invoice', 'payment_type')
|
||||
->withArchived()
|
||||
@ -101,6 +103,10 @@ class GenerateStatementData
|
||||
->where('payment_date', '>=', $this->options['start_date'])
|
||||
->where('payment_date', '<=', $this->options['end_date']);
|
||||
|
||||
if ($this->contact) {
|
||||
$payments->whereIn('invoice_id', $invoices->pluck('id'));
|
||||
}
|
||||
|
||||
$payments = $payments->get();
|
||||
$data = collect();
|
||||
|
||||
@ -109,7 +115,7 @@ class GenerateStatementData
|
||||
$item = new InvoiceItem();
|
||||
$item->product_key = $payment->invoice->invoice_number;
|
||||
$item->custom_value1 = $payment->payment_date;
|
||||
$item->custom_value2 = $payment->payment_type->name;
|
||||
$item->custom_value2 = $payment->present()->payment_type;
|
||||
$item->cost = $payment->getCompletedAmount();
|
||||
$item->invoice_item_type_id = 3;
|
||||
$data->push($item);
|
||||
|
@ -37,6 +37,11 @@ class PaymentPresenter extends EntityPresenter
|
||||
return Carbon::parse($this->entity->payment_date)->format('Y m');
|
||||
}
|
||||
|
||||
public function payment_type()
|
||||
{
|
||||
return $this->entity->payment_type ? $this->entity->payment_type->name : trans('texts.manual_entry');
|
||||
}
|
||||
|
||||
public function method()
|
||||
{
|
||||
if ($this->entity->account_gateway) {
|
||||
|
@ -87,15 +87,14 @@
|
||||
$('#reportrange').css('color', '#000');
|
||||
$('#reportrange').css('pointer-events', 'auto');
|
||||
}
|
||||
console.log("{{ request()->path() }}");
|
||||
var url = '/{{ request()->path() . '/' . $client->public_id }}' +
|
||||
|
||||
var url = '/{{ request()->path() }}' +
|
||||
'?status_id=' + statusId +
|
||||
'&start_date=' + statementStartDate.format('YYYY-MM-DD') +
|
||||
'&end_date=' + statementEndDate.format('YYYY-MM-DD') +
|
||||
'&show_payments=' + ($('#show_payments').is(':checked') ? '1' : '') +
|
||||
'&show_aging=' + ($('#show_aging').is(':checked') ? '1' : '') +
|
||||
'&json=true';
|
||||
console.log(url);
|
||||
|
||||
$.get(url, function(response) {
|
||||
invoice = currentInvoice = JSON.parse(response);
|
||||
|
Loading…
Reference in New Issue
Block a user