mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Merge branch 'master' of github.com:hillelcoren/invoice-ninja
This commit is contained in:
commit
86b6d9dc10
@ -136,6 +136,12 @@ class Client extends EntityModel
|
||||
return $this->belongsTo('App\Models\Industry');
|
||||
}
|
||||
|
||||
public function credits()
|
||||
{
|
||||
return $this->hasMany('App\Models\Credit');
|
||||
}
|
||||
|
||||
|
||||
public function addContact($data, $isPrimary = false)
|
||||
{
|
||||
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
|
||||
|
@ -43,6 +43,7 @@ class ClientTransformer extends EntityTransformer
|
||||
protected $availableIncludes = [
|
||||
'contacts',
|
||||
'invoices',
|
||||
'credits',
|
||||
];
|
||||
|
||||
public function includeContacts(Client $client)
|
||||
@ -57,6 +58,12 @@ class ClientTransformer extends EntityTransformer
|
||||
return $this->includeCollection($client->invoices, $transformer, ENTITY_INVOICE);
|
||||
}
|
||||
|
||||
public function includeCredits(Client $client)
|
||||
{
|
||||
$transformer = new CreditTransformer($this->account, $this->serializer);
|
||||
return $this->includeCollection($client->credits, $transformer, ENTITY_CREDIT);
|
||||
}
|
||||
|
||||
public function transform(Client $client)
|
||||
{
|
||||
return [
|
||||
|
24
app/Ninja/Transformers/CreditTransformer.php
Normal file
24
app/Ninja/Transformers/CreditTransformer.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php namespace App\Ninja\Transformers;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Credit;
|
||||
use League\Fractal;
|
||||
|
||||
class CreditTransformer extends EntityTransformer
|
||||
{
|
||||
public function transform(Credit $credit)
|
||||
{
|
||||
return [
|
||||
'id' => (int) $credit->public_id,
|
||||
'amount' => (float) $credit->amount,
|
||||
'balance' => (float) $credit->balance,
|
||||
'updated_at' => $this->getTimestamp($credit->updated_at),
|
||||
'archived_at' => $this->getTimestamp($credit->deleted_at),
|
||||
'is_deleted' => (bool) $credit->is_deleted,
|
||||
'account_key' => $this->account->account_key,
|
||||
'credit_date' => $credit->credit_date,
|
||||
'credit_number' => $credit->credit_number,
|
||||
'private_notes' => $credit->private_notes,
|
||||
];
|
||||
}
|
||||
}
|
@ -20,6 +20,10 @@ class AddSourceCurrencyToExpenses extends Migration
|
||||
$table->renameColumn('currency_id', 'invoice_currency_id');
|
||||
$table->unsignedInteger('expense_currency_id');
|
||||
|
||||
});
|
||||
|
||||
Schema::table('expenses', function (Blueprint $table) {
|
||||
|
||||
// set account value so we're able to create foreign constraint
|
||||
DB::statement('update expenses e
|
||||
left join accounts a on a.id = e.account_id
|
||||
|
Loading…
Reference in New Issue
Block a user