diff --git a/VERSION.txt b/VERSION.txt index 01a7765013..6896c9fb1c 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.0.17 \ No newline at end of file +5.0.18 \ No newline at end of file diff --git a/app/Factory/InvoiceItemFactory.php b/app/Factory/InvoiceItemFactory.php index d370495a90..63d9f3188b 100644 --- a/app/Factory/InvoiceItemFactory.php +++ b/app/Factory/InvoiceItemFactory.php @@ -94,15 +94,15 @@ class InvoiceItemFactory $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 = 0; $item->notes = $faker->realText(20); $item->product_key = $faker->word(); $item->custom_value1 = $faker->realText(10); $item->custom_value2 = $faker->realText(10); $item->custom_value3 = $faker->realText(10); $item->custom_value4 = $faker->realText(10); - $item->tax_name1 = 'GST'; - $item->tax_rate1 = 10.00; + $item->tax_name1 = ''; + $item->tax_rate1 = 0; $item->type_id = "1"; $data[] = $item; diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 561f9480a1..c21308cdc1 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -288,5 +288,39 @@ class InvoiceSum return $this->getTotalTaxes(); } + public function purgeTaxes() + { + + $this->tax_rate1 = 0; + $this->tax_name1 = ''; + + $this->tax_rate2 = 0; + $this->tax_name2 = ''; + + $this->tax_rate3 = 0; + $this->tax_name3 = ''; + + $this->discount = 0; + + $line_items = collect($this->invoice->line_items); + + $items = $line_items->map(function ($item){ + $item->tax_rate1 = 0; + $item->tax_rate2 = 0; + $item->tax_rate3 = 0; + $item->tax_name1 = ''; + $item->tax_name2 = ''; + $item->tax_name3 = ''; + $item->discount = 0; + + return $item; + }); + + $this->invoice->line_items = $items->toArray(); + + $this->build(); + + return $this; + } } diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index b84d409093..3887f96803 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -302,4 +302,9 @@ class InvoiceSumInclusive return $this->getTotalTaxes(); } + public function purgeTaxes() + { + + return $this; + } } diff --git a/app/Models/Company.php b/app/Models/Company.php index 4690d8c2fc..af1efb90ed 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -318,7 +318,7 @@ class Company extends BaseModel return isset($this->settings->language_id) && $this->language() ? $this->language()->locale : config('ninja.i18n.locale'); } - public function getLogo() + public function getLogo() :?string { return $this->settings->company_logo ?: null; } @@ -394,7 +394,6 @@ class Company extends BaseModel public function company_users() { - //return $this->hasMany(CompanyUser::class)->withTimestamps(); return $this->hasMany(CompanyUser::class); } diff --git a/app/Repositories/RecurringInvoiceRepository.php b/app/Repositories/RecurringInvoiceRepository.php index 525bbc9fc6..b88aca5e83 100644 --- a/app/Repositories/RecurringInvoiceRepository.php +++ b/app/Repositories/RecurringInvoiceRepository.php @@ -33,7 +33,10 @@ class RecurringInvoiceRepository extends BaseRepository $invoice_calc = new InvoiceSum($invoice, $invoice->settings); - $invoice->service()->applyNumber()->save(); + $invoice->service() + ->applyNumber() + ->createInvitations() + ->save(); $invoice = $invoice_calc->build()->getInvoice(); diff --git a/app/Services/Invoice/HandleReversal.php b/app/Services/Invoice/HandleReversal.php index 7a991f80ba..9abac432f9 100644 --- a/app/Services/Invoice/HandleReversal.php +++ b/app/Services/Invoice/HandleReversal.php @@ -91,7 +91,7 @@ class HandleReversal extends AbstractService $credit_calc = new InvoiceSum($credit); $credit_calc->build(); - $credit = $credit_calc->getCredit(); + $credit = $credit_calc->purgeTaxes()->getCredit(); $credit->service()->markSent()->save(); } diff --git a/config/ninja.php b/config/ninja.php index 7c8633f845..be29899238 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -12,7 +12,7 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/').'/', 'app_domain' => env('APP_DOMAIN', ''), - 'app_version' => '5.0.17', + 'app_version' => '5.0.18', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index b1056c2663..c6f2f659ce 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -333,6 +333,14 @@ trait MockAccountData $this->credit->amount = 10; $this->credit->balance = 10; + $this->credit->tax_name1 = ''; + $this->credit->tax_name2 = ''; + $this->credit->tax_name3 = ''; + + $this->credit->tax_rate1 = 0; + $this->credit->tax_rate2 = 0; + $this->credit->tax_rate3 = 0; + $this->credit->uses_inclusive_taxes = false; $this->credit->save();