mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Tax Rate fixes (#3031)
* Ensure tax rate queries are scoped appropriately * Add Tax Rate Policy * Fixes for settings * doc blocks * Add failed jobs tables to migrations * Only 1 migration file for failed table
This commit is contained in:
parent
e7a6a8c403
commit
14ea3fe256
@ -20,6 +20,13 @@ use App\Models\Company;
|
||||
class CompanySettings extends BaseSettings
|
||||
{
|
||||
|
||||
/*Group settings based on functionality*/
|
||||
|
||||
/*Invoice*/
|
||||
public $auto_archive_invoice = false;
|
||||
public $lock_sent_invoices = false;
|
||||
|
||||
|
||||
public $timezone_id = '';
|
||||
public $date_format_id = '';
|
||||
public $military_time = false;
|
||||
@ -51,8 +58,6 @@ class CompanySettings extends BaseSettings
|
||||
public $custom_message_unpaid_invoice = '';
|
||||
public $custom_message_paid_invoice = '';
|
||||
public $custom_message_unapproved_quote = '';
|
||||
public $lock_sent_invoices = false;
|
||||
public $auto_archive_invoice = false;
|
||||
public $auto_archive_quote = false;
|
||||
public $auto_convert_quote = false;
|
||||
|
||||
@ -60,12 +65,10 @@ class CompanySettings extends BaseSettings
|
||||
|
||||
public $translations;
|
||||
|
||||
/**
|
||||
* Counter Variables
|
||||
*/
|
||||
public $invoice_number_prefix = '';
|
||||
/* Counters */
|
||||
public $invoice_number_pattern = '';
|
||||
public $invoice_number_counter = 1;
|
||||
public $invoice_number_prefix = '';
|
||||
|
||||
public $quote_number_prefix = '';
|
||||
public $quote_number_pattern = '';
|
||||
@ -101,7 +104,6 @@ class CompanySettings extends BaseSettings
|
||||
|
||||
|
||||
public $shared_invoice_quote_counter = false;
|
||||
|
||||
public $recurring_invoice_number_prefix = 'R';
|
||||
public $reset_counter_frequency_id = '0';
|
||||
public $reset_counter_date = '';
|
||||
@ -128,7 +130,6 @@ class CompanySettings extends BaseSettings
|
||||
public $custom_fields = '';
|
||||
public $invoice_fields = '';
|
||||
|
||||
|
||||
public $enable_portal_password = false;
|
||||
public $show_accept_invoice_terms = false;
|
||||
public $show_accept_quote_terms = false;
|
||||
@ -175,7 +176,25 @@ class CompanySettings extends BaseSettings
|
||||
public $vat_number = '';
|
||||
public $id_number = '';
|
||||
|
||||
public $page_size = 'A4';
|
||||
public $font_size = 9;
|
||||
public $primary_font = 'roboto';
|
||||
public $secondary_font = 'roboto';
|
||||
public $hide_paid_to_date = false;
|
||||
public $embed_documents = false;
|
||||
public $all_pages_header = true;
|
||||
public $all_pages_footer = true;
|
||||
|
||||
|
||||
public static $casts = [
|
||||
'page_size' => 'string',
|
||||
'font_size' => 'int',
|
||||
'primary_font' => 'string',
|
||||
'secondary_font' => 'string',
|
||||
'hide_paid_to_date' => 'bool',
|
||||
'embed_documents' => 'bool',
|
||||
'all_pages_header' => 'bool',
|
||||
'all_pages_footer' => 'bool',
|
||||
'task_number_prefix' => 'string',
|
||||
'task_number_pattern' => 'string',
|
||||
'task_number_counter' => 'int',
|
||||
|
@ -126,6 +126,14 @@
|
||||
* @OA\Property(property="email", type="string", example="joe@acme.co", description="____________"),
|
||||
* @OA\Property(property="country_id", type="string", example="1", description="The country ID"),
|
||||
* @OA\Property(property="vat_number", type="string", example="32 120 377 720", description="____________"),
|
||||
* @OA\Property(property="id_number", type="string", example="ACME-CO-123", description="____________"),
|
||||
* @OA\Property(property="page_size", type="string", example="A4", description="The default page size"),
|
||||
* @OA\Property(property="font_size", type="number", example="9", description="The font size"),
|
||||
* @OA\Property(property="primary_font", type="string", example="roboto", description="The primary font"),
|
||||
* @OA\Property(property="secondary_font", type="string", example="roboto", description="The secondary font"),
|
||||
* @OA\Property(property="hide_paid_to_date", type="boolean", example=false, description="____________"),
|
||||
* @OA\Property(property="embed_documents", type="boolean", example=false, description="____________"),
|
||||
* @OA\Property(property="all_pages_header", type="boolean", example=false, description="____________"),
|
||||
* @OA\Property(property="all_pages_footer", type="boolean", example=false, description="____________"),
|
||||
* )
|
||||
*/
|
||||
*/
|
||||
|
||||
|
@ -75,7 +75,7 @@ class TaxRateController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$tax_rates = TaxRate::all();
|
||||
$tax_rates = TaxRate::scope();
|
||||
|
||||
return $this->listResponse($tax_rates);
|
||||
}
|
||||
|
@ -13,12 +13,18 @@ namespace App\Listeners;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Mail\VerifyUser;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendVerificationNotification implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class EntityPolicy
|
||||
|
24
app/Policies/TaxRatePolicy.php
Normal file
24
app/Policies/TaxRatePolicy.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\TaxRate;
|
||||
|
||||
/**
|
||||
* Class TaxRatePolicy
|
||||
* @package App\Policies
|
||||
*/
|
||||
class TaxRatePolicy extends EntityPolicy
|
||||
{
|
||||
|
||||
|
||||
}
|
@ -22,6 +22,7 @@ use App\Models\Product;
|
||||
use App\Models\Quote;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Models\RecurringQuote;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\User;
|
||||
use App\Policies\ActivityPolicy;
|
||||
use App\Policies\ClientPolicy;
|
||||
@ -34,6 +35,7 @@ use App\Policies\ProductPolicy;
|
||||
use App\Policies\QuotePolicy;
|
||||
use App\Policies\RecurringInvoicePolicy;
|
||||
use App\Policies\RecurringQuotePolicy;
|
||||
use App\Policies\TaxRatePolicy;
|
||||
use App\Policies\UserPolicy;
|
||||
use Auth;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
@ -59,6 +61,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
User::class => UserPolicy::class,
|
||||
GroupSetting::class => GroupSettingPolicy::class,
|
||||
CompanyGateway::class => CompanyGatewayPolicy::class,
|
||||
TaxRate::class => TaxRatePolicy::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -84,6 +84,7 @@ class InvoiceRepository extends BaseRepository
|
||||
|
||||
$finished_amount = $invoice->amount;
|
||||
|
||||
/**/
|
||||
if($finished_amount != $starting_amount)
|
||||
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, ($finished_amount - $starting_amount));
|
||||
|
||||
@ -110,6 +111,11 @@ class InvoiceRepository extends BaseRepository
|
||||
|
||||
$invoice->save();
|
||||
|
||||
/*
|
||||
* Why? because up until this point the invoice was a draft.
|
||||
* When marked as sent it becomes a ledgerable item.
|
||||
*
|
||||
*/
|
||||
UpdateCompanyLedgerWithInvoice::dispatchNow($this->invoice, $this->balance);
|
||||
|
||||
return $invoice;
|
||||
|
@ -86,7 +86,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
public function testInvoiceTotalsWithDiscountWithSurcharge()
|
||||
{
|
||||
$this->invoice->discount = 5;
|
||||
$this->invoice->custom_value1 = 5;
|
||||
$this->invoice->custom_surcharge1 = 5;
|
||||
|
||||
$this->invoice_calc->build();
|
||||
|
||||
@ -98,7 +98,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
public function testInvoiceTotalsWithDiscountWithSurchargeWithInclusiveTax()
|
||||
{
|
||||
$this->invoice->discount = 5;
|
||||
$this->invoice->custom_value1 = 5;
|
||||
$this->invoice->custom_surcharge1 = 5;
|
||||
$this->invoice->tax_name1 = 'GST';
|
||||
$this->invoice->tax_rate1 = 10;
|
||||
$this->invoice->is_amount_discount = true;
|
||||
@ -114,7 +114,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
public function testInvoiceTotalsWithPercentDiscountWithSurchargeWithInclusiveTax()
|
||||
{
|
||||
$this->invoice->discount = 5;
|
||||
$this->invoice->custom_value1 = 5;
|
||||
$this->invoice->custom_surcharge1 = 5;
|
||||
$this->invoice->tax_name1 = 'GST';
|
||||
$this->invoice->tax_rate1 = 10;
|
||||
$this->invoice->is_amount_discount = false;
|
||||
@ -130,7 +130,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
{
|
||||
|
||||
$this->invoice->discount = 5;
|
||||
$this->invoice->custom_value1 = 5;
|
||||
$this->invoice->custom_surcharge1 = 5;
|
||||
$this->invoice->tax_name1 = 'GST';
|
||||
$this->invoice->tax_rate1 = 10;
|
||||
$this->settings->inclusive_taxes = true;
|
||||
@ -148,7 +148,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
{
|
||||
|
||||
$this->invoice->discount = 5;
|
||||
$this->invoice->custom_value1 = 5;
|
||||
$this->invoice->custom_surcharge1 = 5;
|
||||
$this->invoice->tax_name1 = 'GST';
|
||||
$this->invoice->tax_rate1 = 10;
|
||||
$this->invoice->tax_name2 = 'GST';
|
||||
@ -188,7 +188,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
|
||||
$this->settings->inclusive_taxes = true;
|
||||
$this->invoice->discount = 0;
|
||||
$this->invoice->custom_value1 = 0;
|
||||
$this->invoice->custom_surcharge1 = 0;
|
||||
|
||||
$this->invoice_calc = new InvoiceSumInclusive($this->invoice, $this->settings);
|
||||
$this->invoice_calc->build();
|
||||
@ -224,7 +224,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
|
||||
$this->settings->inclusive_taxes = true;
|
||||
$this->invoice->discount = 0;
|
||||
$this->invoice->custom_value1 = 0;
|
||||
$this->invoice->custom_surcharge1 = 0;
|
||||
|
||||
$this->invoice->tax_rate1 = 10;
|
||||
$this->invoice->tax_rate2 = 10;
|
||||
@ -266,7 +266,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
$this->settings->inclusive_taxes = true;
|
||||
$this->invoice->discount = 5;
|
||||
$this->invoice->is_amount_discount = false;
|
||||
$this->invoice->custom_value1 = 0;
|
||||
$this->invoice->custom_surcharge1 = 0;
|
||||
|
||||
$this->invoice->tax_rate1 = 10;
|
||||
$this->invoice->tax_rate2 = 10;
|
||||
@ -311,7 +311,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
$this->settings->inclusive_taxes = true;
|
||||
$this->invoice->discount = 5;
|
||||
$this->invoice->is_amount_discount = true;
|
||||
$this->invoice->custom_value1 = 0;
|
||||
$this->invoice->custom_surcharge1 = 0;
|
||||
|
||||
$this->invoice->tax_rate1 = 10;
|
||||
$this->invoice->tax_rate2 = 10;
|
||||
@ -357,7 +357,7 @@ class InvoiceInclusiveTest extends TestCase
|
||||
$this->settings->inclusive_taxes = true;
|
||||
$this->invoice->discount = 5;
|
||||
$this->invoice->is_amount_discount = true;
|
||||
$this->invoice->custom_value1 = 0;
|
||||
$this->invoice->custom_surcharge1 = 0;
|
||||
|
||||
$this->invoice->tax_rate1 = 10;
|
||||
$this->invoice->tax_rate2 = 10;
|
||||
|
Loading…
x
Reference in New Issue
Block a user