1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

API fixes

This commit is contained in:
Hillel Coren 2019-07-21 09:12:42 +03:00
parent 5f998b0ea8
commit 9943b89b2d
3 changed files with 19 additions and 10 deletions

View File

@ -154,7 +154,7 @@ class DocumentAPIController extends BaseAPIController
{
$entity = $request->entity();
$this->documentRepo->delete($entity);
$entity->delete();
return $this->itemResponse($entity);
}

View File

@ -25,10 +25,16 @@ class DocumentTransformer extends EntityTransformer
'name' => $document->name,
'type' => $document->type,
'path' => $document->path,
'invoice_id' => $document->invoice_id && $document->invoice ? (int) $document->invoice->public_id : null,
'expense_id' => $document->expense_id && $document->expense ? (int) $document->expense->public_id : null,
'invoice_id' => (int) ($document->invoice_id && $document->invoice ? $document->invoice->public_id : null),
'expense_id' => (int) ($document->expense_id && $document->expense ? $document->expense->public_id : null),
'updated_at' => $this->getTimestamp($document->updated_at),
'created_at' => $this->getTimestamp($document->created_at),
'is_deleted' => (bool) false,
'is_default' => (bool) $document->is_default,
'preview' => $document->preview,
'size' => (int) $document->size,
'width' => (int) $document->width,
'height' => (int) $document->height,
]);
}
}

View File

@ -71,19 +71,22 @@ class ExpenseTransformer extends EntityTransformer
'transaction_reference' => $expense->transaction_reference ?: '',
'bank_id' => (int) ($expense->bank_id ?: 0),
'expense_currency_id' => (int) ($expense->expense_currency_id ?: 0),
'expense_category_id' => $expense->expense_category ? (int) $expense->expense_category->public_id : 0,
'expense_category_id' => (int) ($expense->expense_category ? $expense->expense_category->public_id : 0),
'amount' => (float) $expense->amount,
'expense_date' => $expense->expense_date ?: '',
'payment_date' => $expense->payment_date ?: '',
'invoice_documents' => (bool) $expense->invoice_documents,
'payment_type_id' => (int) $expense->payment_type_id,
'exchange_rate' => (float) $expense->exchange_rate,
'invoice_currency_id' => (int) $expense->invoice_currency_id,
'is_deleted' => (bool) $expense->is_deleted,
'tax_name1' => $expense->tax_name1 ?: '',
'tax_name2' => $expense->tax_name2 ?: '',
'tax_rate1' => $expense->tax_rate1 ?: '',
'tax_rate2' => $expense->tax_rate2 ?: '',
'client_id' => $this->client ? $this->client->public_id : (isset($expense->client->public_id) ? (int) $expense->client->public_id : 0),
'invoice_id' => isset($expense->invoice->public_id) ? (int) $expense->invoice->public_id : 0,
'vendor_id' => isset($expense->vendor->public_id) ? (int) $expense->vendor->public_id : 0,
'tax_rate1' => (float) ($expense->tax_rate1 ?: 0),
'tax_rate2' => (float) ($expense->tax_rate2 ?: 0),
'client_id' => (int) ($this->client ? $this->client->public_id : (isset($expense->client->public_id) ? $expense->client->public_id : 0)),
'invoice_id' => (int) (isset($expense->invoice->public_id) ? $expense->invoice->public_id : 0),
'vendor_id' => (int) (isset($expense->vendor->public_id) ? $expense->vendor->public_id : 0),
'custom_value1' => $expense->custom_value1 ?: '',
'custom_value2' => $expense->custom_value2 ?: '',
]);