mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Stripe Zero Decimal CUrrencies
This commit is contained in:
parent
15dc54a719
commit
995b16d7e3
@ -18,7 +18,7 @@ trait Utilities
|
||||
public function convertFromStripeAmount($amount, $precision, $currency)
|
||||
{
|
||||
|
||||
if($currency->code == "JPY")
|
||||
if(in_array($amount, ["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"]))
|
||||
return $amount;
|
||||
|
||||
return $amount / pow(10, $precision);
|
||||
@ -28,7 +28,7 @@ trait Utilities
|
||||
public function convertToStripeAmount($amount, $precision, $currency)
|
||||
{
|
||||
|
||||
if($currency->code == "JPY")
|
||||
if(in_array($amount, ["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"]))
|
||||
return $amount;
|
||||
|
||||
return round(($amount * pow(10, $precision)),0);
|
||||
|
41
tests/Unit/ZeroDecimalTest.php
Normal file
41
tests/Unit/ZeroDecimalTest.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Jobs\Util\UploadFile;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ZeroDecimalTest extends TestCase
|
||||
{
|
||||
|
||||
|
||||
public array $currencies = ["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"];
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testCurrencyHit()
|
||||
{
|
||||
|
||||
$this->assertTrue(in_array("KRW", $this->currencies));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user