1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Using Credits for payment

This commit is contained in:
David Bomba 2020-10-15 20:41:59 +11:00
parent 5dfc4cf7e1
commit 2f948b603b
9 changed files with 58 additions and 9 deletions

View File

@ -1 +1 @@
5.0.17
5.0.18

View File

@ -94,15 +94,15 @@ class InvoiceItemFactory
$item->cost = $faker->randomFloat(2, -1, -1000);
$item->line_total = $item->quantity * $item->cost;
$item->is_amount_discount = true;
$item->discount = $faker->numberBetween(1, 10);
$item->discount = 0;
$item->notes = $faker->realText(20);
$item->product_key = $faker->word();
$item->custom_value1 = $faker->realText(10);
$item->custom_value2 = $faker->realText(10);
$item->custom_value3 = $faker->realText(10);
$item->custom_value4 = $faker->realText(10);
$item->tax_name1 = 'GST';
$item->tax_rate1 = 10.00;
$item->tax_name1 = '';
$item->tax_rate1 = 0;
$item->type_id = "1";
$data[] = $item;

View File

@ -288,5 +288,39 @@ class InvoiceSum
return $this->getTotalTaxes();
}
public function purgeTaxes()
{
$this->tax_rate1 = 0;
$this->tax_name1 = '';
$this->tax_rate2 = 0;
$this->tax_name2 = '';
$this->tax_rate3 = 0;
$this->tax_name3 = '';
$this->discount = 0;
$line_items = collect($this->invoice->line_items);
$items = $line_items->map(function ($item){
$item->tax_rate1 = 0;
$item->tax_rate2 = 0;
$item->tax_rate3 = 0;
$item->tax_name1 = '';
$item->tax_name2 = '';
$item->tax_name3 = '';
$item->discount = 0;
return $item;
});
$this->invoice->line_items = $items->toArray();
$this->build();
return $this;
}
}

View File

@ -302,4 +302,9 @@ class InvoiceSumInclusive
return $this->getTotalTaxes();
}
public function purgeTaxes()
{
return $this;
}
}

View File

@ -318,7 +318,7 @@ class Company extends BaseModel
return isset($this->settings->language_id) && $this->language() ? $this->language()->locale : config('ninja.i18n.locale');
}
public function getLogo()
public function getLogo() :?string
{
return $this->settings->company_logo ?: null;
}
@ -394,7 +394,6 @@ class Company extends BaseModel
public function company_users()
{
//return $this->hasMany(CompanyUser::class)->withTimestamps();
return $this->hasMany(CompanyUser::class);
}

View File

@ -33,7 +33,10 @@ class RecurringInvoiceRepository extends BaseRepository
$invoice_calc = new InvoiceSum($invoice, $invoice->settings);
$invoice->service()->applyNumber()->save();
$invoice->service()
->applyNumber()
->createInvitations()
->save();
$invoice = $invoice_calc->build()->getInvoice();

View File

@ -91,7 +91,7 @@ class HandleReversal extends AbstractService
$credit_calc = new InvoiceSum($credit);
$credit_calc->build();
$credit = $credit_calc->getCredit();
$credit = $credit_calc->purgeTaxes()->getCredit();
$credit->service()->markSent()->save();
}

View File

@ -12,7 +12,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/').'/',
'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.0.17',
'app_version' => '5.0.18',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -333,6 +333,14 @@ trait MockAccountData
$this->credit->amount = 10;
$this->credit->balance = 10;
$this->credit->tax_name1 = '';
$this->credit->tax_name2 = '';
$this->credit->tax_name3 = '';
$this->credit->tax_rate1 = 0;
$this->credit->tax_rate2 = 0;
$this->credit->tax_rate3 = 0;
$this->credit->uses_inclusive_taxes = false;
$this->credit->save();