1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Working on statements

This commit is contained in:
Hillel Coren 2018-05-01 17:57:35 +03:00
parent 898a64288c
commit dca32edfea
4 changed files with 27 additions and 21 deletions

View File

@ -2,6 +2,7 @@
namespace App\Jobs\Client; namespace App\Jobs\Client;
use Utils;
use App\Models\InvoiceItem; use App\Models\InvoiceItem;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
@ -25,12 +26,14 @@ class GenerateStatementData
{ {
$client = $this->client; $client = $this->client;
$client->load('contacts'); $client->load('contacts');
$account = $client->account; $account = $client->account;
$account->load(['date_format', 'datetime_format']);
$invoice = new Invoice(); $invoice = new Invoice();
$invoice->invoice_date = Utils::today();
$invoice->account = $account; $invoice->account = $account;
$invoice->client = $client; $invoice->client = $client;
$invoice->date_format = $account->date_format ? $account->date_format->format_moment : 'MMM D, YYYY';
$invoice->invoice_items = $this->getInvoices(); $invoice->invoice_items = $this->getInvoices();
@ -39,6 +42,8 @@ class GenerateStatementData
$invoice->invoice_items = $invoice->invoice_items->merge($payments); $invoice->invoice_items = $invoice->invoice_items->merge($payments);
} }
$invoice->hidePrivateFields();
return json_encode($invoice); return json_encode($invoice);
} }
@ -100,6 +105,7 @@ class GenerateStatementData
$payments = Payment::with('invoice', 'payment_type') $payments = Payment::with('invoice', 'payment_type')
->withArchived() ->withArchived()
->whereClientId($this->client->id) ->whereClientId($this->client->id)
//->excludeFailed()
->where('payment_date', '>=', $this->options['start_date']) ->where('payment_date', '>=', $this->options['start_date'])
->where('payment_date', '<=', $this->options['end_date']); ->where('payment_date', '<=', $this->options['end_date']);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -538,8 +538,8 @@ NINJA.statementInvoices = function(invoice) {
var rowStyle = (counter++ % 2 == 0) ? 'odd' : 'even'; var rowStyle = (counter++ % 2 == 0) ? 'odd' : 'even';
grid.push([ grid.push([
{text: item.product_key, style:['invoiceNumber', 'productKey', rowStyle]}, {text: item.product_key, style:['invoiceNumber', 'productKey', rowStyle]},
{text: item.custom_value1 && item.custom_value1 != '0000-00-00' ? moment(item.custom_value1).format(invoice.date_format) : ' ', style:['invoiceDate', rowStyle]}, {text: item.custom_value1 && item.custom_value1 != '0000-00-00' ? moment(item.custom_value1).format(invoice.account.date_format ? invoice.account.date_format.format_moment : 'MMM D, YYYY') : ' ', style:['invoiceDate', rowStyle]},
{text: item.custom_value2 && item.custom_value2 != '0000-00-00' ? moment(item.custom_value2).format(invoice.date_format) : ' ', style:['dueDate', rowStyle]}, {text: item.custom_value2 && item.custom_value2 != '0000-00-00' ? moment(item.custom_value2).format(invoice.account.date_format ? invoice.account.date_format.format_moment : 'MMM D, YYYY') : ' ', style:['dueDate', rowStyle]},
{text: formatMoneyInvoice(item.notes, invoice), style:['subtotals', rowStyle]}, {text: formatMoneyInvoice(item.notes, invoice), style:['subtotals', rowStyle]},
{text: formatMoneyInvoice(item.cost, invoice), style:['lineTotal', rowStyle]}, {text: formatMoneyInvoice(item.cost, invoice), style:['lineTotal', rowStyle]},
]); ]);
@ -566,7 +566,7 @@ NINJA.statementPayments = function(invoice) {
var rowStyle = (counter++ % 2 == 0) ? 'odd' : 'even'; var rowStyle = (counter++ % 2 == 0) ? 'odd' : 'even';
grid.push([ grid.push([
{text: item.product_key, style:['invoiceNumber', 'productKey', rowStyle]}, {text: item.product_key, style:['invoiceNumber', 'productKey', rowStyle]},
{text: item.custom_value1 && item.custom_value1 != '0000-00-00' ? moment(item.custom_value1).format(invoice.date_format) : ' ', style:['invoiceDate', rowStyle]}, {text: item.custom_value1 && item.custom_value1 != '0000-00-00' ? moment(item.custom_value1).format(invoice.account.date_format ? invoice.account.date_format.format_moment : 'MMM D, YYYY') : ' ', style:['invoiceDate', rowStyle]},
{text: item.custom_value2 ? item.custom_value2 : ' ', style:['dueDate', rowStyle]}, {text: item.custom_value2 ? item.custom_value2 : ' ', style:['dueDate', rowStyle]},
//{text: item.transaction_reference, style:['subtotals', rowStyle]}, //{text: item.transaction_reference, style:['subtotals', rowStyle]},
{text: formatMoneyInvoice(item.cost, invoice), style:['lineTotal', rowStyle]}, {text: formatMoneyInvoice(item.cost, invoice), style:['lineTotal', rowStyle]},