From 8ea29ea0ad96dabbf0f9776c498d0994e78d4bed Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 2 Jan 2018 22:54:10 +0200 Subject: [PATCH] Document date on export #1784 --- app/Ninja/Reports/DocumentReport.php | 2 +- app/Ninja/Reports/ExpenseReport.php | 2 +- app/Ninja/Reports/InvoiceReport.php | 2 +- app/Ninja/Reports/QuoteReport.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Ninja/Reports/DocumentReport.php b/app/Ninja/Reports/DocumentReport.php index d7563d329c..c874087319 100644 --- a/app/Ninja/Reports/DocumentReport.php +++ b/app/Ninja/Reports/DocumentReport.php @@ -50,7 +50,7 @@ class DocumentReport extends AbstractReport $zip = Archive::instance_by_useragent(date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.documents'))); foreach ($records as $record) { foreach ($record->documents as $document) { - $name = sprintf('%s_%s_%s', date('Y-m-d'), $record->present()->titledName, $document->name); + $name = sprintf('%s_%s_%s', $document->created_at->format('Y-m-d'), $record->present()->titledName, $document->name); $name = str_replace(' ', '_', $name); $name = str_replace('#', '', $name); $zip->add_file($name, $document->getRaw()); diff --git a/app/Ninja/Reports/ExpenseReport.php b/app/Ninja/Reports/ExpenseReport.php index 8457d7079b..788b33908e 100644 --- a/app/Ninja/Reports/ExpenseReport.php +++ b/app/Ninja/Reports/ExpenseReport.php @@ -39,7 +39,7 @@ class ExpenseReport extends AbstractReport foreach ($expenses->get() as $expense) { foreach ($expense->documents as $document) { $expenseId = str_pad($expense->public_id, $account->invoice_number_padding, '0', STR_PAD_LEFT); - $name = sprintf('%s_%s_%s_%s', date('Y-m-d'), trans('texts.expense'), $expenseId, $document->name); + $name = sprintf('%s_%s_%s_%s', $expense->expense_date ?: date('Y-m-d'), trans('texts.expense'), $expenseId, $document->name); $name = str_replace(' ', '_', $name); $zip->add_file($name, $document->getRaw()); } diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index f8f5e24ffa..54b5353e9c 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -48,7 +48,7 @@ class InvoiceReport extends AbstractReport foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { foreach ($invoice->documents as $document) { - $name = sprintf('%s_%s_%s', date('Y-m-d'), $invoice->present()->titledName, $document->name); + $name = sprintf('%s_%s_%s', $invoice->invoice_date ?: date('Y-m-d'), $invoice->present()->titledName, $document->name); $zip->add_file($name, $document->getRaw()); } } diff --git a/app/Ninja/Reports/QuoteReport.php b/app/Ninja/Reports/QuoteReport.php index 876268c45a..d7ed1f0ade 100644 --- a/app/Ninja/Reports/QuoteReport.php +++ b/app/Ninja/Reports/QuoteReport.php @@ -42,7 +42,7 @@ class QuoteReport extends AbstractReport foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { foreach ($invoice->documents as $document) { - $name = sprintf('%s_%s_%s', date('Y-m-d'), $invoice->present()->titledName, $document->name); + $name = sprintf('%s_%s_%s', $invoice->invoice_date ?: date('Y-m-d'), $invoice->present()->titledName, $document->name); $name = str_replace(' ', '_', $name); $zip->add_file($name, $document->getRaw()); }