diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 09f485cc83bc..d9361ef0b0b0 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -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', diff --git a/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php b/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php index 4831e3fc6265..8b8aa64940ec 100644 --- a/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php +++ b/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php @@ -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="____________"), * ) - */ \ No newline at end of file + */ + diff --git a/app/Http/Controllers/TaxRateController.php b/app/Http/Controllers/TaxRateController.php index 30a99b39e811..46cb3da8f3ed 100644 --- a/app/Http/Controllers/TaxRateController.php +++ b/app/Http/Controllers/TaxRateController.php @@ -75,7 +75,7 @@ class TaxRateController extends BaseController */ public function index() { - $tax_rates = TaxRate::all(); + $tax_rates = TaxRate::scope(); return $this->listResponse($tax_rates); } diff --git a/app/Listeners/SendVerificationNotification.php b/app/Listeners/SendVerificationNotification.php index 3094c32c06c1..1e319233076f 100644 --- a/app/Listeners/SendVerificationNotification.php +++ b/app/Listeners/SendVerificationNotification.php @@ -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. * diff --git a/app/Policies/EntityPolicy.php b/app/Policies/EntityPolicy.php index 6caeedd6866f..c57d70905dd2 100644 --- a/app/Policies/EntityPolicy.php +++ b/app/Policies/EntityPolicy.php @@ -12,7 +12,6 @@ namespace App\Policies; use App\Models\User; -use Illuminate\Support\Facades\Log; /** * Class EntityPolicy diff --git a/app/Policies/TaxRatePolicy.php b/app/Policies/TaxRatePolicy.php new file mode 100644 index 000000000000..3eeb3fba275b --- /dev/null +++ b/app/Policies/TaxRatePolicy.php @@ -0,0 +1,24 @@ + UserPolicy::class, GroupSetting::class => GroupSettingPolicy::class, CompanyGateway::class => CompanyGatewayPolicy::class, + TaxRate::class => TaxRatePolicy::class, ]; /** diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index 4161aad020c3..f623e55490c5 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -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; diff --git a/tests/Unit/InvoiceInclusiveTest.php b/tests/Unit/InvoiceInclusiveTest.php index 2a0bc34f9f20..1f6c9c82f07a 100644 --- a/tests/Unit/InvoiceInclusiveTest.php +++ b/tests/Unit/InvoiceInclusiveTest.php @@ -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;