mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Tests for gateway fees
This commit is contained in:
parent
9223ff9ac8
commit
021b741e56
@ -270,8 +270,9 @@ class CompanyGateway extends BaseModel
|
||||
info("fee after adding fee tax 3 = {$fee}");
|
||||
}
|
||||
|
||||
//TODO CALCULATE FEE CAP HERE
|
||||
|
||||
if($fees_and_limits->fee_cap > 0 && ($fee > $fees_and_limits->fee_cap))
|
||||
$fee = $fees_and_limits->fee_cap;
|
||||
|
||||
return $fee;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App\Models\CompanyGateway
|
||||
*/
|
||||
class CompanyGatewayApiTest extends TestCase
|
||||
{
|
||||
@ -352,4 +353,42 @@ class CompanyGatewayApiTest extends TestCase
|
||||
|
||||
$this->assertEquals(12, $company_gateway->calcGatewayFee(10));
|
||||
}
|
||||
|
||||
|
||||
public function testFeesAndLimitsFeePercentAndAmountAndDoubleTaxCalcuationWithFeeCap()
|
||||
{
|
||||
//{"1":{"min_limit":1,"max_limit":1000000,"fee_amount":10,"fee_percent":2,"fee_tax_name1":"","fee_tax_name2":"","fee_tax_name3":"","fee_tax_rate1":0,"fee_tax_rate2":0,"fee_tax_rate3":0,"fee_cap":10,"adjust_fee_percent":true}}
|
||||
$fee = new FeesAndLimits;
|
||||
$fee->fee_amount = 10;
|
||||
// $fee->fee_percent = 2;
|
||||
$fee->fee_tax_name1 = 'GST';
|
||||
$fee->fee_tax_rate1 = '10.0';
|
||||
$fee->fee_tax_name2 = 'GST';
|
||||
$fee->fee_tax_rate2 = '10.0';
|
||||
$fee->fee_cap = 1;
|
||||
|
||||
$fee_arr[1] = (array)$fee;
|
||||
|
||||
$data = [
|
||||
'config' => 'random config',
|
||||
'gateway_key' => '3b6621f970ab18887c4f6dca78d3f8bb',
|
||||
'fees_and_limits' => $fee_arr,
|
||||
];
|
||||
|
||||
/* POST */
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token
|
||||
])->post('/api/v1/company_gateways', $data);
|
||||
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
$id = $this->decodePrimaryKey($arr['data']['id']);
|
||||
|
||||
$company_gateway = CompanyGateway::find($id);
|
||||
|
||||
$this->assertEquals(1, $company_gateway->calcGatewayFee(10));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user