mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on API functionality
This commit is contained in:
parent
aef4658873
commit
6d09bda646
@ -71,6 +71,7 @@ class AccountApiController extends BaseAPIController
|
||||
'invoices' => ['invoice_items', 'user', 'client', 'payments'],
|
||||
'products' => [],
|
||||
'tax_rates' => [],
|
||||
'expenses' => ['client', 'invoice', 'vendor']
|
||||
];
|
||||
|
||||
foreach ($map as $key => $values) {
|
||||
|
@ -85,6 +85,19 @@ class InvoiceApiController extends BaseAPIController
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
public function show($publicId)
|
||||
{
|
||||
|
||||
$invoice = Invoice::scope($publicId)->withTrashed()->first();
|
||||
|
||||
if(!$invoice)
|
||||
return $this->errorResponse(['message'=>'Invoice does not exist!'], 404);
|
||||
|
||||
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
|
||||
$data = $this->createItem($invoice, $transformer, 'invoice');
|
||||
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SWG\Post(
|
||||
|
@ -218,8 +218,8 @@ class PaymentApiController extends BaseAPIController
|
||||
$query->withTrashed();
|
||||
}])->first();
|
||||
|
||||
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
|
||||
$data = $this->createItem($invoice, $transformer, 'invoice');
|
||||
$transformer = new PaymentTransformer(\Auth::user()->account, Input::get('serializer'));
|
||||
$data = $this->createItem($payment, $transformer, 'invoice');
|
||||
|
||||
return $this->response($data);
|
||||
}
|
||||
|
@ -164,6 +164,10 @@ class Account extends Eloquent
|
||||
return $this->belongsTo('App\Models\TaxRate');
|
||||
}
|
||||
|
||||
public function expenses()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense','account_id','id')->withTrashed();
|
||||
}
|
||||
|
||||
public function setIndustryIdAttribute($value)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ class ExpenseTransformer extends EntityTransformer
|
||||
{
|
||||
public function transform(Expense $expense)
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => (int) $expense->public_id,
|
||||
'private_notes' => $expense->private_notes,
|
||||
@ -24,6 +25,9 @@ class ExpenseTransformer extends EntityTransformer
|
||||
'exchange_rate' => (float) $expense->exchange_rate,
|
||||
'invoice_currency_id' => (int) $expense->invoice_currency_id,
|
||||
'is_deleted' => (bool) $expense->is_deleted,
|
||||
'client_id' => isset($expense->client->public_id) ? (int) $expense->client->public_id : null,
|
||||
'invoice_id' => isset($expense->invoice->public_id) ? (int) $expense->invoice->public_id : null,
|
||||
'vendor_id' => isset($expense->vendor->public_id) ? (int) $expense->vendor->public_id : null,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user