Fixes for tests

This commit is contained in:
David Bomba 2024-11-05 10:03:25 +11:00
parent 3656fe7221
commit 1ffe41f84f
4 changed files with 11 additions and 10 deletions

View File

@ -58,11 +58,11 @@ class InvoiceItemFactory
for ($x = 0; $x < $items; $x++) { for ($x = 0; $x < $items; $x++) {
$item = self::create(); $item = self::create();
$item->quantity = $faker->numberBetween(1, 10); $item->quantity = rand(1, 10);
$item->cost = $faker->randomFloat(2, 1, 1000); $item->cost = $faker->randomFloat(2, 1, 1000);
$item->line_total = $item->quantity * $item->cost; $item->line_total = $item->quantity * $item->cost;
$item->is_amount_discount = true; $item->is_amount_discount = true;
$item->discount = $faker->numberBetween(1, 10); $item->discount = rand(1, 10);
$item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20)); $item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20));
$item->product_key = $faker->word(); $item->product_key = $faker->word();
// $item->custom_value1 = $faker->realText(10); // $item->custom_value1 = $faker->realText(10);
@ -78,11 +78,11 @@ class InvoiceItemFactory
$item = self::create(); $item = self::create();
$item->quantity = $faker->numberBetween(1, 10); $item->quantity = rand(1, 10);
$item->cost = $faker->randomFloat(2, 1, 1000); $item->cost = $faker->randomFloat(2, 1, 1000);
$item->line_total = $item->quantity * $item->cost; $item->line_total = $item->quantity * $item->cost;
$item->is_amount_discount = true; $item->is_amount_discount = true;
$item->discount = $faker->numberBetween(1, 10); $item->discount = rand(1, 10);
$item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20)); $item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20));
$item->product_key = $faker->word(); $item->product_key = $faker->word();
// $item->custom_value1 = $faker->realText(10); // $item->custom_value1 = $faker->realText(10);
@ -112,7 +112,7 @@ class InvoiceItemFactory
for ($x = 0; $x < $items; $x++) { for ($x = 0; $x < $items; $x++) {
$item = self::create(); $item = self::create();
$item->quantity = $faker->numberBetween(-1, -10); $item->quantity = rand(-1, -10);
$item->cost = $faker->randomFloat(2, -1, -1000); $item->cost = $faker->randomFloat(2, -1, -1000);
$item->line_total = $item->quantity * $item->cost; $item->line_total = $item->quantity * $item->cost;
$item->is_amount_discount = true; $item->is_amount_discount = true;

View File

@ -103,7 +103,7 @@ class StorecoveAdapter
DateTimeNormalizer::FORMAT_KEY => 'Y-m-d', DateTimeNormalizer::FORMAT_KEY => 'Y-m-d',
AbstractObjectNormalizer::SKIP_NULL_VALUES => true, AbstractObjectNormalizer::SKIP_NULL_VALUES => true,
]; ];
nlog($p);
$e = new \InvoiceNinja\EInvoice\EInvoice(); $e = new \InvoiceNinja\EInvoice\EInvoice();
$peppolInvoice = $e->decode('Peppol', $p, 'xml'); $peppolInvoice = $e->decode('Peppol', $p, 'xml');
@ -208,6 +208,7 @@ class StorecoveAdapter
if ($allowance->reason == ctrans('texts.discount')) { if ($allowance->reason == ctrans('texts.discount')) {
nlog($allowance->amount_excluding_tax);
$allowance->amount_excluding_tax = $allowance->amount_excluding_tax * -1; $allowance->amount_excluding_tax = $allowance->amount_excluding_tax * -1;
} }
@ -331,9 +332,9 @@ class StorecoveAdapter
//NON-EU Sale //NON-EU Sale
nlog("non eu"); nlog("non eu");
$this->nexus = $company_country_code; $this->nexus = $company_country_code;
} elseif (in_array($company_country_code, $eu_countries) && in_array($client_country_code, $eu_countries)) { } elseif (in_array($client_country_code, $eu_countries)) {
//EU Sale //EU Sale where Company country != Client Country
// First, determine if we're over threshold // First, determine if we're over threshold
$is_over_threshold = isset($this->ninja_invoice->company->tax_data->regions->EU->has_sales_above_threshold) && $is_over_threshold = isset($this->ninja_invoice->company->tax_data->regions->EU->has_sales_above_threshold) &&

View File

@ -27,7 +27,7 @@ class InvoiceFactory extends Factory
return [ return [
'status_id' => Invoice::STATUS_SENT, 'status_id' => Invoice::STATUS_SENT,
'number' => $this->faker->ean13(), 'number' => $this->faker->ean13(),
'discount' => $this->faker->numberBetween(1, 10), 'discount' => rand(1,10),
'is_amount_discount' => (bool) random_int(0, 1), 'is_amount_discount' => (bool) random_int(0, 1),
'tax_name1' => 'GST', 'tax_name1' => 'GST',
'tax_rate1' => 10, 'tax_rate1' => 10,

View File

@ -96,7 +96,7 @@ class TaxRuleConsistencyTest extends TestCase
'user_id' => $this->user->id, 'user_id' => $this->user->id,
]); ]);
// nlog($invoice->withoutRelations()->toArray()); nlog($invoice->withoutRelations()->toArray());
$e_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice(); $e_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice();