mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-08-05 11:10:16 -04:00
API fixes
This commit is contained in:
parent
f639ebae94
commit
acc73d53dc
@ -151,10 +151,10 @@ class DocumentAPIController extends BaseAPIController
|
||||
* )
|
||||
*/
|
||||
public function destroy(UpdateDocumentRequest $request)
|
||||
{
|
||||
{
|
||||
$entity = $request->entity();
|
||||
|
||||
$this->documentRepo->delete($entity);
|
||||
$entity->delete();
|
||||
|
||||
return $this->itemResponse($entity);
|
||||
}
|
||||
|
@ -15,9 +15,8 @@ class DocumentTransformer extends EntityTransformer
|
||||
* @SWG\Property(property="type", type="string", example="png")
|
||||
* @SWG\Property(property="path", type="string", example="abc/sample.png")
|
||||
* @SWG\Property(property="invoice_id", type="integer", example=1)
|
||||
* @SWG\Property(property="expense_id", type="integer", example=1)
|
||||
* @SWG\Property(property="updated_at", type="integer", example=1451160233, readOnly=true)
|
||||
* @SWG\Property(property="is_default", type="boolean", example=false)
|
||||
* @SWG\Property(property="archived_at", type="integer", example=1451160233, readOnly=true)
|
||||
*/
|
||||
public function transform(Document $document)
|
||||
{
|
||||
@ -26,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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ class ExpenseTransformer extends EntityTransformer
|
||||
{
|
||||
/**
|
||||
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
|
||||
* @SWG\Property(property="private_notes", type="string", example="Notes")
|
||||
* @SWG\Property(property="public_notes", type="string", example="Notes")
|
||||
* @SWG\Property(property="private_notes", type="string", example="Notes...")
|
||||
* @SWG\Property(property="public_notes", type="string", example="Notes...")
|
||||
* @SWG\Property(property="should_be_invoiced", type="boolean", example=false)
|
||||
* @SWG\Property(property="updated_at", type="integer", example=1451160233, readOnly=true)
|
||||
* @SWG\Property(property="archived_at", type="integer", example=1451160233, readOnly=true)
|
||||
@ -21,11 +21,11 @@ class ExpenseTransformer extends EntityTransformer
|
||||
* @SWG\Property(property="bank_id", type="integer", example=1)
|
||||
* @SWG\Property(property="expense_currency_id", type="integer", example=1)
|
||||
* @SWG\Property(property="expense_category_id", type="integer", example=1)
|
||||
* @SWG\Property(property="amount", type="number", format="float,", example="17.5", readOnly=true)
|
||||
* @SWG\Property(property="amount", type="number", format="float,", example="17.5")
|
||||
* @SWG\Property(property="expense_date", type="string", format="date", example="2016-01-01")
|
||||
* @SWG\Property(property="exchange_rate", type="number", format="float", example="10")
|
||||
* @SWG\Property(property="exchange_rate", type="number", format="float", example="")
|
||||
* @SWG\Property(property="invoice_currency_id", type="integer", example=1)
|
||||
* @SWG\Property(property="is_deleted", type="boolean", example=false, readOnly=true)
|
||||
* @SWG\Property(property="is_deleted", type="boolean", example=false)
|
||||
* @SWG\Property(property="tax_name1", type="string", example="VAT")
|
||||
* @SWG\Property(property="tax_name2", type="string", example="Upkeep")
|
||||
* @SWG\Property(property="tax_rate1", type="number", format="float", example="17.5")
|
||||
@ -33,8 +33,6 @@ class ExpenseTransformer extends EntityTransformer
|
||||
* @SWG\Property(property="client_id", type="integer", example=1)
|
||||
* @SWG\Property(property="invoice_id", type="integer", example=1)
|
||||
* @SWG\Property(property="vendor_id", type="integer", example=1)
|
||||
* @SWG\Property(property="custom_value1", type="string", example="Custom Value")
|
||||
* @SWG\Property(property="custom_value2", type="string", example="Custom Value")
|
||||
*/
|
||||
|
||||
protected $availableIncludes = [
|
||||
@ -73,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 ?: '',
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user