mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix for JSON account export
This commit is contained in:
parent
44344e7676
commit
243b1c1d37
@ -91,24 +91,7 @@ class AccountApiController extends BaseAPIController
|
|||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
$updatedAt = $request->updated_at ? date('Y-m-d H:i:s', $request->updated_at) : false;
|
$updatedAt = $request->updated_at ? date('Y-m-d H:i:s', $request->updated_at) : false;
|
||||||
|
|
||||||
$map = [
|
$account->loadAllData($updatedAt);
|
||||||
'users' => [],
|
|
||||||
'clients' => ['contacts'],
|
|
||||||
'invoices' => ['invoice_items', 'user', 'client', 'payments'],
|
|
||||||
'products' => [],
|
|
||||||
'tax_rates' => [],
|
|
||||||
'expenses' => ['client', 'invoice', 'vendor'],
|
|
||||||
'payments' => ['invoice'],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($map as $key => $values) {
|
|
||||||
$account->load([$key => function($query) use ($values, $updatedAt) {
|
|
||||||
$query->withTrashed()->with($values);
|
|
||||||
if ($updatedAt) {
|
|
||||||
$query->where('updated_at', '>=', $updatedAt);
|
|
||||||
}
|
|
||||||
}]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$transformer = new AccountTransformer(null, $request->serializer);
|
$transformer = new AccountTransformer(null, $request->serializer);
|
||||||
$account = $this->createItem($account, $transformer, 'account');
|
$account = $this->createItem($account, $transformer, 'account');
|
||||||
|
@ -614,6 +614,28 @@ class Account extends Eloquent
|
|||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadAllData($updatedAt = null)
|
||||||
|
{
|
||||||
|
$map = [
|
||||||
|
'users' => [],
|
||||||
|
'clients' => ['contacts'],
|
||||||
|
'invoices' => ['invoice_items', 'user', 'client', 'payments'],
|
||||||
|
'products' => [],
|
||||||
|
'tax_rates' => [],
|
||||||
|
'expenses' => ['client', 'invoice', 'vendor'],
|
||||||
|
'payments' => ['invoice'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($map as $key => $values) {
|
||||||
|
$this->load([$key => function($query) use ($values, $updatedAt) {
|
||||||
|
$query->withTrashed()->with($values);
|
||||||
|
if ($updatedAt) {
|
||||||
|
$query->where('updated_at', '>=', $updatedAt);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function loadLocalizationSettings($client = false)
|
public function loadLocalizationSettings($client = false)
|
||||||
{
|
{
|
||||||
$this->load('timezone', 'date_format', 'datetime_format', 'language');
|
$this->load('timezone', 'date_format', 'datetime_format', 'language');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user