mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-21 23:11:07 -04:00
Minor fixes
This commit is contained in:
parent
b25f58db6f
commit
d267dc1f09
@ -402,7 +402,7 @@ class InvoiceService
|
|||||||
$balance = $this->invoice->balance;
|
$balance = $this->invoice->balance;
|
||||||
|
|
||||||
//return early if type three does not exist.
|
//return early if type three does not exist.
|
||||||
if (! collect($this->invoice->line_items)->contains('type_id', 3)) {
|
if (! collect($this->invoice->line_items)->contains('type_id', '3')) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,8 +1042,6 @@ html {
|
|||||||
|
|
||||||
$dom = null;
|
$dom = null;
|
||||||
|
|
||||||
nlog($html);
|
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ use App\Jobs\Util\ReminderJob;
|
|||||||
use App\DataMapper\InvoiceItem;
|
use App\DataMapper\InvoiceItem;
|
||||||
use App\DataMapper\FeesAndLimits;
|
use App\DataMapper\FeesAndLimits;
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
|
use App\Factory\InvoiceItemFactory;
|
||||||
|
use App\Factory\ClientGatewayTokenFactory;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,6 +95,122 @@ class LateFeeTest extends TestCase
|
|||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLateFeeRemovals()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data[1]['min_limit'] = -1;
|
||||||
|
$data[1]['max_limit'] = -1;
|
||||||
|
$data[1]['fee_amount'] = 0.00;
|
||||||
|
$data[1]['fee_percent'] = 1;
|
||||||
|
$data[1]['fee_tax_name1'] = '';
|
||||||
|
$data[1]['fee_tax_rate1'] = 0;
|
||||||
|
$data[1]['fee_tax_name2'] = '';
|
||||||
|
$data[1]['fee_tax_rate2'] = 0;
|
||||||
|
$data[1]['fee_tax_name3'] = '';
|
||||||
|
$data[1]['fee_tax_rate3'] = 0;
|
||||||
|
$data[1]['adjust_fee_percent'] = false;
|
||||||
|
$data[1]['fee_cap'] = 0;
|
||||||
|
$data[1]['is_enabled'] = true;
|
||||||
|
|
||||||
|
$cg = new \App\Models\CompanyGateway;
|
||||||
|
$cg->company_id = $this->company->id;
|
||||||
|
$cg->user_id = $this->user->id;
|
||||||
|
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||||
|
$cg->require_cvv = true;
|
||||||
|
$cg->require_billing_address = true;
|
||||||
|
$cg->require_shipping_address = true;
|
||||||
|
$cg->update_details = true;
|
||||||
|
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
||||||
|
$cg->fees_and_limits = $data;
|
||||||
|
$cg->save();
|
||||||
|
|
||||||
|
$cgt = ClientGatewayTokenFactory::create($this->company->id);
|
||||||
|
$cgt->client_id = $this->client->id;
|
||||||
|
$cgt->token = '';
|
||||||
|
$cgt->gateway_customer_reference = '';
|
||||||
|
$cgt->gateway_type_id = 1;
|
||||||
|
$cgt->company_gateway_id = $cg->id;
|
||||||
|
$cgt->save();
|
||||||
|
|
||||||
|
$line_items = [];
|
||||||
|
|
||||||
|
$item = InvoiceItemFactory::create();
|
||||||
|
$item->quantity = 1;
|
||||||
|
$item->cost = 10;
|
||||||
|
$item->type_id = '1';
|
||||||
|
|
||||||
|
$line_items[] = $item;
|
||||||
|
|
||||||
|
$invoice_item = new InvoiceItem;
|
||||||
|
$invoice_item->type_id = '5';
|
||||||
|
$invoice_item->product_key = trans('texts.fee');
|
||||||
|
$invoice_item->quantity = 1;
|
||||||
|
$invoice_item->cost = 10;
|
||||||
|
|
||||||
|
$line_items[] = $item;
|
||||||
|
|
||||||
|
$item = InvoiceItemFactory::create();
|
||||||
|
$item->quantity = 1;
|
||||||
|
$item->cost = 1;
|
||||||
|
$item->type_id = '3';
|
||||||
|
|
||||||
|
$line_items[] = $item;
|
||||||
|
|
||||||
|
$this->assertTrue(collect($line_items)->contains('type_id', '3'));
|
||||||
|
$this->assertTrue(collect($line_items)->contains('type_id', 3));
|
||||||
|
|
||||||
|
$i = Invoice::factory()->create([
|
||||||
|
|
||||||
|
'client_id' => $this->client->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'line_items' => $line_items,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$i = $i->calc()->getInvoice();
|
||||||
|
|
||||||
|
$this->assertEquals(3, count($i->line_items));
|
||||||
|
|
||||||
|
$invoice_items = (array) $i->line_items;
|
||||||
|
|
||||||
|
$invoice_items = collect($invoice_items)->filter(function ($item) {
|
||||||
|
return $item->type_id != '3';
|
||||||
|
});
|
||||||
|
|
||||||
|
$i->line_items = $invoice_items;
|
||||||
|
|
||||||
|
$i->line_items = collect($i->line_items)
|
||||||
|
->reject(function ($item) {
|
||||||
|
return $item->type_id == '3';
|
||||||
|
})->toArray();
|
||||||
|
|
||||||
|
$this->assertEquals(2, count($i->line_items));
|
||||||
|
|
||||||
|
$i->service()->autoBill();
|
||||||
|
|
||||||
|
$i = $i->fresh();
|
||||||
|
|
||||||
|
$this->assertCount(2, $i->line_items);
|
||||||
|
|
||||||
|
$line_items = $i->line_items;
|
||||||
|
|
||||||
|
$invoice_item = new InvoiceItem;
|
||||||
|
$invoice_item->type_id = '5';
|
||||||
|
$invoice_item->product_key = trans('texts.fee');
|
||||||
|
$invoice_item->quantity = 1;
|
||||||
|
$invoice_item->cost = 10;
|
||||||
|
|
||||||
|
$line_items[] = $item;
|
||||||
|
|
||||||
|
$i->line_items = $line_items;
|
||||||
|
|
||||||
|
$i = $i->calc()->getInvoice();
|
||||||
|
|
||||||
|
$this->assertCount(3, $i->line_items);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function testLateFeeAdded()
|
public function testLateFeeAdded()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user