From 1ffe41f84f63a88ed9bd747854bee29c65e6675b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 5 Nov 2024 10:03:25 +1100 Subject: [PATCH] Fixes for tests --- app/Factory/InvoiceItemFactory.php | 10 +++++----- .../EDocument/Gateway/Storecove/StorecoveAdapter.php | 7 ++++--- database/factories/InvoiceFactory.php | 2 +- tests/Unit/Tax/TaxRuleConsistencyTest.php | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/Factory/InvoiceItemFactory.php b/app/Factory/InvoiceItemFactory.php index 23a46fac21..2dc9ce058c 100644 --- a/app/Factory/InvoiceItemFactory.php +++ b/app/Factory/InvoiceItemFactory.php @@ -58,11 +58,11 @@ class InvoiceItemFactory for ($x = 0; $x < $items; $x++) { $item = self::create(); - $item->quantity = $faker->numberBetween(1, 10); + $item->quantity = rand(1, 10); $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 = rand(1, 10); $item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20)); $item->product_key = $faker->word(); // $item->custom_value1 = $faker->realText(10); @@ -78,11 +78,11 @@ class InvoiceItemFactory $item = self::create(); - $item->quantity = $faker->numberBetween(1, 10); + $item->quantity = rand(1, 10); $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 = rand(1, 10); $item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20)); $item->product_key = $faker->word(); // $item->custom_value1 = $faker->realText(10); @@ -112,7 +112,7 @@ class InvoiceItemFactory for ($x = 0; $x < $items; $x++) { $item = self::create(); - $item->quantity = $faker->numberBetween(-1, -10); + $item->quantity = rand(-1, -10); $item->cost = $faker->randomFloat(2, -1, -1000); $item->line_total = $item->quantity * $item->cost; $item->is_amount_discount = true; diff --git a/app/Services/EDocument/Gateway/Storecove/StorecoveAdapter.php b/app/Services/EDocument/Gateway/Storecove/StorecoveAdapter.php index a137063243..c62d1c915f 100644 --- a/app/Services/EDocument/Gateway/Storecove/StorecoveAdapter.php +++ b/app/Services/EDocument/Gateway/Storecove/StorecoveAdapter.php @@ -103,7 +103,7 @@ class StorecoveAdapter DateTimeNormalizer::FORMAT_KEY => 'Y-m-d', AbstractObjectNormalizer::SKIP_NULL_VALUES => true, ]; - +nlog($p); $e = new \InvoiceNinja\EInvoice\EInvoice(); $peppolInvoice = $e->decode('Peppol', $p, 'xml'); @@ -208,6 +208,7 @@ class StorecoveAdapter if ($allowance->reason == ctrans('texts.discount')) { + nlog($allowance->amount_excluding_tax); $allowance->amount_excluding_tax = $allowance->amount_excluding_tax * -1; } @@ -331,9 +332,9 @@ class StorecoveAdapter //NON-EU Sale nlog("non eu"); $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 $is_over_threshold = isset($this->ninja_invoice->company->tax_data->regions->EU->has_sales_above_threshold) && diff --git a/database/factories/InvoiceFactory.php b/database/factories/InvoiceFactory.php index 713fc07350..f9e92320f7 100644 --- a/database/factories/InvoiceFactory.php +++ b/database/factories/InvoiceFactory.php @@ -27,7 +27,7 @@ class InvoiceFactory extends Factory return [ 'status_id' => Invoice::STATUS_SENT, 'number' => $this->faker->ean13(), - 'discount' => $this->faker->numberBetween(1, 10), + 'discount' => rand(1,10), 'is_amount_discount' => (bool) random_int(0, 1), 'tax_name1' => 'GST', 'tax_rate1' => 10, diff --git a/tests/Unit/Tax/TaxRuleConsistencyTest.php b/tests/Unit/Tax/TaxRuleConsistencyTest.php index 931fca0b5a..23fb96717d 100644 --- a/tests/Unit/Tax/TaxRuleConsistencyTest.php +++ b/tests/Unit/Tax/TaxRuleConsistencyTest.php @@ -96,7 +96,7 @@ class TaxRuleConsistencyTest extends TestCase 'user_id' => $this->user->id, ]); - // nlog($invoice->withoutRelations()->toArray()); + nlog($invoice->withoutRelations()->toArray()); $e_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice();