From 37a826374b8b4e02a178110bf897f0861340c321 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 10 Nov 2019 23:06:30 +1100 Subject: [PATCH] Remove settings from invoice table (#3051) * Implement client/group/company level counters clientCounter, groupCounter and counter * Implement functionalityfor customising the timing of invoice_number creation * Add Jobs * adjustments * clean line items at the request layer * Clean line items at the request layer * minor formatting for notification * Schema Fixes * schema changes, cast country_id to stirng * Fixes for tests * force line item ids to string * Map company gateway fees and limits * Schema changes * Remove id from invoice item stdClass * Remove settings object from invoice table --- app/DataMapper/CompanySettings.php | 19 ++---- app/DataMapper/InvoiceItem.php | 4 +- app/Factory/CloneInvoiceFactory.php | 1 - app/Factory/CloneInvoiceToQuoteFactory.php | 1 - app/Factory/InvoiceFactory.php | 1 - .../InvoiceToRecurringInvoiceFactory.php | 1 - app/Factory/RecurringInvoiceFactory.php | 1 - .../RecurringInvoiceToInvoiceFactory.php | 1 - app/Factory/RecurringQuoteFactory.php | 1 - app/Helpers/Invoice/InvoiceItemSum.php | 6 +- .../Invoice/InvoiceItemSumInclusive.php | 4 +- app/Helpers/Invoice/InvoiceSum.php | 8 +-- app/Helpers/Invoice/InvoiceSumInclusive.php | 7 +-- .../OpenAPI/CompanyGatewaySchema.php | 4 +- .../Controllers/OpenAPI/CompanySchema.php | 4 ++ .../OpenAPI/CompanySettingsSchema.php | 16 ++--- .../Controllers/OpenAPI/InvoiceSchema.php | 1 + app/Http/Controllers/TemplateController.php | 4 +- .../StoreCompanyGatewayRequest.php | 12 ++++ .../UpdateCompanyGatewayRequest.php | 18 +++++- app/Jobs/Invoice/StoreInvoice.php | 14 ++--- app/Models/Client.php | 1 + app/Models/Company.php | 2 + app/Models/Invoice.php | 2 +- app/Models/RecurringInvoice.php | 23 +++---- .../ClientContactRequestCancellation.php | 2 +- app/Notifications/GmailTestNotification.php | 61 +++++++++++++++++++ .../CompanyGatewayTransformer.php | 34 +++++++---- app/Utils/Traits/CleanLineItems.php | 3 +- .../2014_10_13_000000_create_users_table.php | 24 ++++---- ..._11_10_115926_create_failed_jobs_table.php | 35 +++++++++++ database/seeds/RandomDataSeeder.php | 17 ++---- tests/Feature/InvitationTest.php | 2 +- tests/Feature/InvoiceTest.php | 3 - tests/Feature/QuoteTest.php | 2 +- tests/Feature/RecurringInvoiceTest.php | 2 +- tests/Feature/RecurringQuoteTest.php | 2 +- tests/MockAccountData.php | 11 +--- tests/Unit/CompareObjectTest.php | 2 +- tests/Unit/InvoiceInclusiveTest.php | 21 +++---- tests/Unit/InvoiceItemInclusiveTest.php | 18 +++--- tests/Unit/InvoiceTest.php | 23 +++---- 42 files changed, 249 insertions(+), 169 deletions(-) create mode 100644 app/Notifications/GmailTestNotification.php create mode 100644 database/migrations/2019_11_10_115926_create_failed_jobs_table.php diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 76fc05d086ea..5927c8536523 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -50,11 +50,6 @@ class CompanySettings extends BaseSettings public $custom_value3 = ''; public $custom_value4 = ''; - public $custom_invoice_taxes1 = false; - public $custom_invoice_taxes2 = false; - public $custom_invoice_taxes3 = false; - public $custom_invoice_taxes4 = false; - public $default_task_rate = 0; public $payment_terms = 1; @@ -121,8 +116,8 @@ class CompanySettings extends BaseSettings public $invoice_terms = ''; public $quote_terms = ''; - public $invoice_taxes = false; - public $invoice_item_taxes = false; + public $invoice_taxes = 0; + public $invoice_item_taxes = 0; public $invoice_design_id = '1'; public $quote_design_id = '1'; public $invoice_footer = ''; @@ -134,7 +129,6 @@ class CompanySettings extends BaseSettings public $tax_name3 = ''; public $tax_rate3 = 0; public $payment_type_id = '1'; - public $custom_fields = ''; public $invoice_fields = ''; public $show_accept_invoice_terms = false; @@ -304,15 +298,10 @@ class CompanySettings extends BaseSettings 'custom_value2' => 'string', 'custom_value3' => 'string', 'custom_value4' => 'string', - 'custom_invoice_taxes1' => 'bool', - 'custom_invoice_taxes2' => 'bool', - 'custom_invoice_taxes3' => 'bool', - 'custom_invoice_taxes4' => 'bool', 'custom_message_dashboard' => 'string', 'custom_message_unpaid_invoice' => 'string', 'custom_message_paid_invoice' => 'string', 'custom_message_unapproved_quote' => 'string', - 'custom_fields' => 'string', 'default_task_rate' => 'float', 'email_signature' => 'string', 'email_subject_invoice' => 'string', @@ -336,8 +325,8 @@ class CompanySettings extends BaseSettings 'invoice_number_counter' => 'integer', 'invoice_design_id' => 'string', 'invoice_fields' => 'string', - 'invoice_taxes' => 'bool', - 'invoice_item_taxes' => 'bool', + 'invoice_taxes' => 'int', + 'invoice_item_taxes' => 'int', 'invoice_footer' => 'string', 'invoice_labels' => 'string', 'invoice_terms' => 'string', diff --git a/app/DataMapper/InvoiceItem.php b/app/DataMapper/InvoiceItem.php index af6080de1352..9327403f58cc 100644 --- a/app/DataMapper/InvoiceItem.php +++ b/app/DataMapper/InvoiceItem.php @@ -38,7 +38,7 @@ class InvoiceItem public $tax_rate3 = 0; - public $sort_id = 0; + public $sort_id = '0'; public $line_total = 0; @@ -68,7 +68,7 @@ class InvoiceItem 'tax_rate1' => 'float', 'tax_rate2' => 'float', 'tax_rate3' => 'float', - 'sort_id' => 'int', + 'sort_id' => 'string', 'line_total' => 'float', 'date' => 'string', 'custom_value1' => 'string', diff --git a/app/Factory/CloneInvoiceFactory.php b/app/Factory/CloneInvoiceFactory.php index 8485a4b5f929..39faae882893 100644 --- a/app/Factory/CloneInvoiceFactory.php +++ b/app/Factory/CloneInvoiceFactory.php @@ -25,7 +25,6 @@ class CloneInvoiceFactory $clone_invoice->partial_due_date = null; $clone_invoice->user_id = $user_id; $clone_invoice->balance = $invoice->amount; - $clone_invoice->settings = $invoice->settings; $clone_invoice->line_items = $invoice->line_items; $clone_invoice->backup = null; diff --git a/app/Factory/CloneInvoiceToQuoteFactory.php b/app/Factory/CloneInvoiceToQuoteFactory.php index d1a43cddd4ea..9f9e8e293a62 100644 --- a/app/Factory/CloneInvoiceToQuoteFactory.php +++ b/app/Factory/CloneInvoiceToQuoteFactory.php @@ -52,7 +52,6 @@ class CloneInvoiceToQuoteFactory $quote->due_date = null; $quote->partial_due_date = null; $quote->balance = $invoice->amount; - $quote->settings = $invoice->settings; $quote->line_items = $invoice->line_items; return $quote; diff --git a/app/Factory/InvoiceFactory.php b/app/Factory/InvoiceFactory.php index 5c5f0efd5786..5a9e2acc97a7 100644 --- a/app/Factory/InvoiceFactory.php +++ b/app/Factory/InvoiceFactory.php @@ -35,7 +35,6 @@ class InvoiceFactory $invoice->partial_due_date = null; $invoice->is_deleted = false; $invoice->line_items = json_encode([]); - $invoice->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()); //todo need to embed the settings here $invoice->backup = json_encode([]); $invoice->tax_name1 = ''; $invoice->tax_rate1 = 0; diff --git a/app/Factory/InvoiceToRecurringInvoiceFactory.php b/app/Factory/InvoiceToRecurringInvoiceFactory.php index 64d8346da661..a53bf313f128 100644 --- a/app/Factory/InvoiceToRecurringInvoiceFactory.php +++ b/app/Factory/InvoiceToRecurringInvoiceFactory.php @@ -36,7 +36,6 @@ class InvoiceToRecurringInvoiceFactory $recurring_invoice->due_date = $invoice->due_date; //todo calculate based on terms $recurring_invoice->is_deleted = $invoice->is_deleted; $recurring_invoice->line_items = $invoice->line_items; - $recurring_invoice->settings = $invoice->settings; $recurring_invoice->tax_name1 = $invoice->tax_name1; $recurring_invoice->tax_rate1 = $invoice->tax_rate1; $recurring_invoice->tax_name2 = $invoice->tax_name2; diff --git a/app/Factory/RecurringInvoiceFactory.php b/app/Factory/RecurringInvoiceFactory.php index 1324a26a7a05..abe19b485707 100644 --- a/app/Factory/RecurringInvoiceFactory.php +++ b/app/Factory/RecurringInvoiceFactory.php @@ -34,7 +34,6 @@ class RecurringInvoiceFactory $invoice->partial_due_date = null; $invoice->is_deleted = false; $invoice->line_items = json_encode([]); - $invoice->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()); //todo need to embed the settings here $invoice->backup = json_encode([]); $invoice->tax_name1 = ''; $invoice->tax_rate1 = 0; diff --git a/app/Factory/RecurringInvoiceToInvoiceFactory.php b/app/Factory/RecurringInvoiceToInvoiceFactory.php index 98bd63ec0ae1..a1255976e9af 100644 --- a/app/Factory/RecurringInvoiceToInvoiceFactory.php +++ b/app/Factory/RecurringInvoiceToInvoiceFactory.php @@ -34,7 +34,6 @@ class recurring_invoiceToInvoiceFactory $invoice->due_date = $recurring_invoice->due_date; //todo calculate based on terms $invoice->is_deleted = $recurring_invoice->is_deleted; $invoice->line_items = $recurring_invoice->line_items; - $invoice->settings = $recurring_invoice->settings; $invoice->backup = json_encode([]); $invoice->tax_name1 = $recurring_invoice->tax_name1; $invoice->tax_rate1 = $recurring_invoice->tax_rate1; diff --git a/app/Factory/RecurringQuoteFactory.php b/app/Factory/RecurringQuoteFactory.php index 70bd1de8c956..2b55a61b53bf 100644 --- a/app/Factory/RecurringQuoteFactory.php +++ b/app/Factory/RecurringQuoteFactory.php @@ -33,7 +33,6 @@ class RecurringQuoteFactory $quote->partial_due_date = null; $quote->is_deleted = false; $quote->line_items = json_encode([]); - $quote->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()); //todo need to embed the settings here $quote->backup = json_encode([]); $quote->tax_name1 = ''; $quote->tax_rate1 = 0; diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 0007766dd449..6e9a7f53a5a0 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -26,8 +26,6 @@ class InvoiceItemSum use Discounter; use Taxer; - protected $settings; - protected $invoice; private $items; @@ -48,11 +46,9 @@ class InvoiceItemSum private $tax_collection; - public function __construct($invoice, $settings) + public function __construct($invoice) { - $this->settings = $settings; - $this->tax_collection = collect([]); $this->invoice = $invoice; diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index b393c2951bdf..09bea6a85780 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -24,7 +24,6 @@ class InvoiceItemSumInclusive use Discounter; use Taxer; - protected $settings; protected $invoice; @@ -46,10 +45,9 @@ class InvoiceItemSumInclusive private $tax_collection; - public function __construct($invoice, $settings) + public function __construct($invoice) { - $this->settings = $settings; $this->tax_collection = collect([]); diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 85e3103f7d6f..3941ac22726a 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -30,8 +30,6 @@ class InvoiceSum protected $invoice; - protected $settings; - public $tax_map; public $invoice_item; @@ -52,13 +50,11 @@ class InvoiceSum * * @param \App\Models\Invoice $invoice The invoice */ - public function __construct($invoice, $settings) + public function __construct($invoice) { $this->invoice = $invoice; - $this->settings = $settings; - $this->tax_map = new Collection; } @@ -80,7 +76,7 @@ class InvoiceSum private function calculateLineItems() { - $this->invoice_items = new InvoiceItemSum($this->invoice, $this->settings); + $this->invoice_items = new InvoiceItemSum($this->invoice); $this->invoice_items->process(); $this->invoice->line_items = $this->invoice_items->getLineItems(); $this->total = $this->invoice_items->getSubTotal(); diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index 7edeb9c112f3..1f5f84c13500 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -31,8 +31,6 @@ class InvoiceSumInclusive protected $invoice; - protected $settings; - public $tax_map; public $invoice_item; @@ -53,12 +51,11 @@ class InvoiceSumInclusive * * @param \App\Models\Invoice $invoice The invoice */ - public function __construct($invoice, $settings) + public function __construct($invoice) { $this->invoice = $invoice; - $this->settings = $settings; $this->tax_map = new Collection; @@ -80,7 +77,7 @@ class InvoiceSumInclusive private function calculateLineItems() { - $this->invoice_items = new InvoiceItemSumInclusive($this->invoice, $this->settings); + $this->invoice_items = new InvoiceItemSumInclusive($this->invoice); $this->invoice_items->process(); $this->invoice->line_items = $this->invoice_items->getLineItems(); $this->total = $this->invoice_items->getSubTotal(); diff --git a/app/Http/Controllers/OpenAPI/CompanyGatewaySchema.php b/app/Http/Controllers/OpenAPI/CompanyGatewaySchema.php index ddf2b2e6181e..c55a072f27c3 100644 --- a/app/Http/Controllers/OpenAPI/CompanyGatewaySchema.php +++ b/app/Http/Controllers/OpenAPI/CompanyGatewaySchema.php @@ -9,10 +9,10 @@ * @OA\Property(property="accepted_credit_cards", type="integer", example="32", description="Bitmask representation of cards"), * @OA\Property(property="show_billing_address", type="boolean", example=true, description="______"), * @OA\Property(property="show_shipping_address", type="boolean", example=true, description="______"), + * @OA\Property(property="config", type="string", example="2", description="______"), * @OA\Property(property="update_details", type="boolean", example=true, description="______"), * @OA\Property(property="adjust_fee_percent", type="boolean", example=true, description="______"), - * @OA\Property(property="config", type="string", example="2", description="______"), - * @OA\Property(property="priority", type="string", example="2", description="______"), + * @OA\Property(property="fees_and_limits", type="object", description="A mapped collection of the fees and limits for the configured gateway"), * @OA\Property(property="user_id", type="string", example="2", description="______"), * @OA\Property(property="min_limit", type="string", example="2", description="______"), * @OA\Property(property="max_limit", type="string", example="2", description="______"), diff --git a/app/Http/Controllers/OpenAPI/CompanySchema.php b/app/Http/Controllers/OpenAPI/CompanySchema.php index 4b698e5146fc..c6f082dfd23f 100644 --- a/app/Http/Controllers/OpenAPI/CompanySchema.php +++ b/app/Http/Controllers/OpenAPI/CompanySchema.php @@ -10,6 +10,10 @@ * @OA\Property(property="fill_products", type="boolean", example=true, description="Toggles filling a product description based on product key"), * @OA\Property(property="convert_products", type="boolean", example=true, description="___________"), * @OA\Property(property="update_products", type="boolean", example=true, description="Toggles updating a product description which description changes"), + * @OA\Property(property="custom_fields", type="object", description="Custom fields map"), + * @OA\Property(property="enable_product_cost", type="boolean", example=true, description="______________"), + * @OA\Property(property="enable_product_quantity", type="boolean", example=true, description="______________"), + * @OA\Property(property="default_quantity", type="boolean", example=true, description="______________"), * @OA\Property(property="custom_surcharge_taxes1", type="boolean", example=true, description="Toggles charging taxes on custom surcharge amounts"), * @OA\Property(property="custom_surcharge_taxes2", type="boolean", example=true, description="Toggles charging taxes on custom surcharge amounts"), * @OA\Property(property="custom_surcharge_taxes3", type="boolean", example=true, description="Toggles charging taxes on custom surcharge amounts"), diff --git a/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php b/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php index 223635752806..1af5ac1684d7 100644 --- a/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php +++ b/app/Http/Controllers/OpenAPI/CompanySettingsSchema.php @@ -15,10 +15,6 @@ * @OA\Property(property="custom_value2", type="string", example="Custom Label", description="____________"), * @OA\Property(property="custom_value3", type="string", example="Custom Label", description="____________"), * @OA\Property(property="custom_value4", type="string", example="Custom Label", description="____________"), - * @OA\Property(property="custom_invoice_taxes1", type="boolean", example=true, description="____________"), - * @OA\Property(property="custom_invoice_taxes2", type="boolean", example=true, description="____________"), - * @OA\Property(property="custom_invoice_taxes3", type="boolean", example=true, description="____________"), - * @OA\Property(property="custom_invoice_taxes4", type="boolean", example=true, description="____________"), * @OA\Property(property="default_task_rate", type="number", format="float", example="10.00", description="____________"), * @OA\Property(property="send_reminders", type="boolean", example=true, description="____________"), * @OA\Property(property="enable_client_portal_tasks", type="boolean", example=true, description="____________"), @@ -77,20 +73,18 @@ * @OA\Property(property="fill_products", type="boolean", example=true, description="Automatically fill products based on product_key"), * @OA\Property(property="invoice_terms", type="string", example="Invoice Terms are...", description="The default invoice terms"), * @OA\Property(property="quote_terms", type="string", example="Quote Terms are...", description="The default quote terms"), - * @OA\Property(property="invoice_taxes", type="boolean", example=true, description="Taxes can be applied to the invoice"), - * @OA\Property(property="invoice_item_taxes", type="boolean", example=true, description="Taxes can be applied to the invoice items"), + * @OA\Property(property="invoice_taxes", type="number", example="1", description="Taxes can be applied to the invoice"), + * @OA\Property(property="invoice_item_taxes", type="number", example="1", description="Taxes can be applied to the invoice items"), * @OA\Property(property="invoice_design_id", type="string", example="1", description="The default design id (invoice, quote etc)"), * @OA\Property(property="quote_design_id", type="string", example="1", description="The default design id (invoice, quote etc)"), * @OA\Property(property="invoice_footer", type="string", example="1", description="The default invoice footer"), * @OA\Property(property="invoice_labels", type="string", example="1", description="JSON string of invoice labels"), - * @OA\Property(property="show_item_taxes", type="boolean", example=true, description="Toggles whether the itemised taxes are displayed"), * @OA\Property(property="tax_rate1", type="number", example="10", description="The tax rate (float)"), * @OA\Property(property="tax_name1", type="string", example="GST", description="The tax name"), * @OA\Property(property="tax_rate2", type="number", example="10", description="The tax rate (float)"), * @OA\Property(property="tax_name2", type="string", example="GST", description="The tax name"), * @OA\Property(property="tax_rate3", type="number", example="10", description="The tax rate (float)"), * @OA\Property(property="tax_name3", type="string", example="GST", description="The tax name"), - * @OA\Property(property="enable_second_tax_rate", type="boolean", example=true, description="Toggles whether the a second tax rate can be applied"), * @OA\Property(property="payment_type_id", type="string", example="1", description="The default payment type id"), * @OA\Property(property="custom_fields", type="string", example="{}", description="JSON string of custom fields"), * @OA\Property(property="invoice_fields", type="string", example="{}", description="JSON string of invoice fields"), @@ -159,9 +153,9 @@ * @OA\Property(property="schedule_reminder1", type="string", example="after_invoice_date", description="(enum: after_invoice_date, before_due_date, after_due_date)"), * @OA\Property(property="schedule_reminder2", type="string", example="after_invoice_date", description="(enum: after_invoice_date, before_due_date, after_due_date)"), * @OA\Property(property="schedule_reminder3", type="string", example="after_invoice_date", description="(enum: after_invoice_date, before_due_date, after_due_date)"), - * @OA\Property(property="late_fee_amount1", type="float", example=10.00, description="____________"), - * @OA\Property(property="late_fee_amount2", type="float", example=20.00, description="____________"), - * @OA\Property(property="late_fee_amount3", type="float", example=100.00, description="____________"), + * @OA\Property(property="late_fee_amount1", type="number", example=10.00, description="____________"), + * @OA\Property(property="late_fee_amount2", type="number", example=20.00, description="____________"), + * @OA\Property(property="late_fee_amount3", type="number", example=100.00, description="____________"), * @OA\Property(property="endless_reminder_frequency_id", type="string", example="1", description="____________"), * @OA\Property(property="client_online_payment_notification", type="boolean", example=false, description="____________"), * @OA\Property(property="client_manual_payment_notification", type="boolean", example=false, description="____________"), diff --git a/app/Http/Controllers/OpenAPI/InvoiceSchema.php b/app/Http/Controllers/OpenAPI/InvoiceSchema.php index 3e73972ef2e1..9e94d2d1ad0b 100644 --- a/app/Http/Controllers/OpenAPI/InvoiceSchema.php +++ b/app/Http/Controllers/OpenAPI/InvoiceSchema.php @@ -32,6 +32,7 @@ * @OA\Property(property="partial", type="number", format="float", example="10.00", description="_________"), * @OA\Property(property="is_amount_discount", type="boolean", example=true, description="_________"), * @OA\Property(property="is_deleted", type="boolean", example=true, description="_________"), + * @OA\Property(property="uses_inclusive_taxes", type="boolean", example=true, description="Defines the type of taxes used as either inclusive or exclusive"), * @OA\Property(property="invoice_date", type="string", format="date", example="1994-07-30", description="_________"), * @OA\Property(property="partial_due_date", type="string", format="date", example="1994-07-30", description="_________"), * @OA\Property(property="due_date", type="string", format="date", example="1994-07-30", description="_________"), diff --git a/app/Http/Controllers/TemplateController.php b/app/Http/Controllers/TemplateController.php index 596bb61aa90a..d3d4ad4f819a 100644 --- a/app/Http/Controllers/TemplateController.php +++ b/app/Http/Controllers/TemplateController.php @@ -130,8 +130,10 @@ class TemplateController extends BaseController */ public function show($entity, $entity_id) { + $text = request()->input('text'); + + return response()->json($text, 200); - return response()->json(request()->all(), 200); } } \ No newline at end of file diff --git a/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php b/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php index 5cb2484a2a5a..8984aed22442 100644 --- a/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php +++ b/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php @@ -44,6 +44,18 @@ class StoreCompanyGatewayRequest extends Request $input = $this->all(); $input['config'] = encrypt($input['config']); + $input['min_limit'] = isset($input['fees_and_limits']['min_limit']) ? $input['fees_and_limits']['min_limit'] : null; + $input['max_limit'] = isset($input['fees_and_limits']['max_limit']) ? $input['fees_and_limits']['max_limit'] : null; + $input['fee_amount'] = isset($input['fees_and_limits']['fee_amount']) ? $input['fees_and_limits']['fee_amount'] : null; + $input['fee_percent'] = isset($input['fees_and_limits']['fee_percent']) ? $input['fees_and_limits']['fee_percent'] : null; + $input['fee_tax_name1'] = isset($input['fees_and_limits']['fee_tax_name1']) ? $input['fees_and_limits']['fee_tax_name1'] : ''; + $input['fee_tax_name2'] = isset($input['fees_and_limits']['fee_tax_name2']) ? $input['fees_and_limits']['fee_tax_name2'] : ''; + $input['fee_tax_name3'] = isset($input['fees_and_limits']['fee_tax_name3']) ? $input['fees_and_limits']['fee_tax_name3'] : ''; + $input['fee_tax_rate1'] = isset($input['fees_and_limits']['fee_tax_rate1']) ? $input['fees_and_limits']['fee_tax_rate1'] : 0; + $input['fee_tax_rate2'] = isset($input['fees_and_limits']['fee_tax_rate2']) ? $input['fees_and_limits']['fee_tax_rate2'] : 0; + $input['fee_tax_rate3'] = isset($input['fees_and_limits']['fee_tax_rate3']) ? $input['fees_and_limits']['fee_tax_rate3'] : 0; + $input['fee_cap'] = isset($input['fees_and_limits']['fee_cap']) ? $input['fees_and_limits']['fee_cap'] : null; + $input['adjust_fee_percent'] = isset($input['fees_and_limits']['adjust_fee_percent']) ? $input['fees_and_limits']['adjust_fee_percent'] : 0; $this->replace($input); diff --git a/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php b/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php index df88e5a3b5aa..74c92ba4effb 100644 --- a/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php +++ b/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php @@ -43,10 +43,24 @@ class UpdateCompanyGatewayRequest extends Request $input = $this->all(); $input['config'] = encrypt($input['config']); - + $input['min_limit'] = isset($input['fees_and_limits']['min_limit']) ? $input['fees_and_limits']['min_limit'] : null; + $input['max_limit'] = isset($input['fees_and_limits']['max_limit']) ? $input['fees_and_limits']['max_limit'] : null; + $input['fee_amount'] = isset($input['fees_and_limits']['fee_amount']) ? $input['fees_and_limits']['fee_amount'] : null; + $input['fee_percent'] = isset($input['fees_and_limits']['fee_percent']) ? $input['fees_and_limits']['fee_percent'] : null; + $input['fee_tax_name1'] = isset($input['fees_and_limits']['fee_tax_name1']) ? $input['fees_and_limits']['fee_tax_name1'] : ''; + $input['fee_tax_name2'] = isset($input['fees_and_limits']['fee_tax_name2']) ? $input['fees_and_limits']['fee_tax_name2'] : ''; + $input['fee_tax_name3'] = isset($input['fees_and_limits']['fee_tax_name3']) ? $input['fees_and_limits']['fee_tax_name3'] : ''; + $input['fee_tax_rate1'] = isset($input['fees_and_limits']['fee_tax_rate1']) ? $input['fees_and_limits']['fee_tax_rate1'] : 0; + $input['fee_tax_rate2'] = isset($input['fees_and_limits']['fee_tax_rate2']) ? $input['fees_and_limits']['fee_tax_rate2'] : 0; + $input['fee_tax_rate3'] = isset($input['fees_and_limits']['fee_tax_rate3']) ? $input['fees_and_limits']['fee_tax_rate3'] : 0; + $input['fee_cap'] = isset($input['fees_and_limits']['fee_cap']) ? $input['fees_and_limits']['fee_cap'] : null; + $input['adjust_fee_percent'] = isset($input['fees_and_limits']['adjust_fee_percent']) ? $input['fees_and_limits']['adjust_fee_percent'] : 0; + $this->replace($input); return $this->all(); } -} \ No newline at end of file +} + + diff --git a/app/Jobs/Invoice/StoreInvoice.php b/app/Jobs/Invoice/StoreInvoice.php index 2ad6bc879ba1..6454e20424ed 100644 --- a/app/Jobs/Invoice/StoreInvoice.php +++ b/app/Jobs/Invoice/StoreInvoice.php @@ -64,16 +64,16 @@ class StoreInvoice implements ShouldQueue $payment = false; - /* Test if we should auto-bill the invoice */ - if(property_exists($this->invoice->settings, 'auto_bill') && (bool)$this->invoice->settings->auto_bill) - { + // /* Test if we should auto-bill the invoice */ + // if(property_exists($this->invoice->client->getSetting('auto_bill')) && (bool)$this->invoice->client->getSetting('auto_bill')) + // { - $this->invoice = $invoice_repo->markSent($this->invoice); + // $this->invoice = $invoice_repo->markSent($this->invoice); - //fire autobill - todo - the PAYMENT class will update the INVOICE status. - // $payment = + // //fire autobill - todo - the PAYMENT class will update the INVOICE status. + // // $payment = - } + // } if(isset($this->data['email_invoice']) && (bool)$this->data['email_invoice']) { diff --git a/app/Models/Client.php b/app/Models/Client.php index 38d36ec323e7..1b2c1fcf0b1c 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -98,6 +98,7 @@ class Client extends BaseModel ]; protected $casts = [ + 'country_id' => 'string', 'settings' => 'object', 'updated_at' => 'timestamp', 'created_at' => 'timestamp', diff --git a/app/Models/Company.php b/app/Models/Company.php index 9a191c59fab4..f2ad7e7ef0c4 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -77,6 +77,8 @@ class Company extends BaseModel ]; protected $casts = [ + 'country_id' => 'string', + 'custom_fields' => 'object', 'settings' => 'object', 'custom_fields' => 'object', 'updated_at' => 'timestamp', diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 42eaff22b679..3f7b1d6db758 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -276,7 +276,7 @@ class Invoice extends BaseModel { $invoice_calc = null; - if($this->settings->inclusive_taxes) + if($this->uses_inclusive_taxes) $invoice_calc = new InvoiceSumInclusive($this, $this->settings); else $invoice_calc = new InvoiceSum($this, $this->settings); diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index f0c49f6434ac..afa00d39b3cd 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -38,18 +38,19 @@ class RecurringInvoice extends BaseModel /** - * Recurring intervals + * Recurring intervals //todo MAP WHEN WE MIGRATE */ - const FREQUENCY_WEEKLY = 1; - const FREQUENCY_TWO_WEEKS = 2; - const FREQUENCY_FOUR_WEEKS = 3; - const FREQUENCY_MONTHLY = 4; - const FREQUENCY_TWO_MONTHS = 5; - const FREQUENCY_THREE_MONTHS = 6; - const FREQUENCY_FOUR_MONTHS = 7; - const FREQUENCY_SIX_MONTHS = 8; - const FREQUENCY_ANNUALLY = 9; - const FREQUENCY_TWO_YEARS = 10; + const FREQUENCY_DAILY = 1; + const FREQUENCY_WEEKLY = 2; + const FREQUENCY_TWO_WEEKS = 3; + const FREQUENCY_FOUR_WEEKS = 4; + const FREQUENCY_MONTHLY = 5; + const FREQUENCY_TWO_MONTHS = 6; + const FREQUENCY_THREE_MONTHS = 7; + const FREQUENCY_FOUR_MONTHS = 8; + const FREQUENCY_SIX_MONTHS = 9; + const FREQUENCY_ANNUALLY = 10; + const FREQUENCY_TWO_YEARS = 11; const RECURS_INDEFINITELY = -1; diff --git a/app/Notifications/ClientContactRequestCancellation.php b/app/Notifications/ClientContactRequestCancellation.php index 3425c0160005..410b58a5838a 100644 --- a/app/Notifications/ClientContactRequestCancellation.php +++ b/app/Notifications/ClientContactRequestCancellation.php @@ -70,7 +70,7 @@ class ClientContactRequestCancellation extends Notification implements ShouldQue return (new MailMessage) ->subject('Request for recurring invoice cancellation from '.$client_contact_name) ->markdown('email.support.cancellation', [ - 'message' => "Contact {$client_contact_name} from client {$client_name} requested to cancel Recurring Invoice #{$recurring_invoice_number}", + 'message' => "Contact [{$client_contact_name}] from Client [{$client_name}] requested to cancel Recurring Invoice [#{$recurring_invoice_number}]", ]); } diff --git a/app/Notifications/GmailTestNotification.php b/app/Notifications/GmailTestNotification.php new file mode 100644 index 000000000000..5c6f39717f16 --- /dev/null +++ b/app/Notifications/GmailTestNotification.php @@ -0,0 +1,61 @@ +line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Transformers/CompanyGatewayTransformer.php b/app/Transformers/CompanyGatewayTransformer.php index 03d2311bd874..433f6233ceb6 100644 --- a/app/Transformers/CompanyGatewayTransformer.php +++ b/app/Transformers/CompanyGatewayTransformer.php @@ -52,19 +52,8 @@ class CompanyGatewayTransformer extends EntityTransformer 'show_shipping_address' => (bool)$company_gateway->show_shipping_address, 'update_details' => (bool)$company_gateway->update_details, 'config' => (string) $company_gateway->getConfigTransformed(), - 'priority' => (int)$company_gateway->priority, - 'min_limit' => (float)$company_gateway->min_limit ?: null, - 'max_limit' => (float)$company_gateway->max_limit ?: null, - 'fee_amount' => (float) $company_gateway->fee_amount ?: null, - 'fee_percent' => (float)$company_gateway->fee_percent ?: null, - 'fee_tax_name1' => (string)$company_gateway->fee_tax_name1 ?: '', - 'fee_tax_name2' => (string) $company_gateway->fee_tax_name2 ?: '', - 'fee_tax_name3' => (string) $company_gateway->fee_tax_name3 ?: '', - 'fee_tax_rate1' => (float) $company_gateway->fee_tax_rate1, - 'fee_tax_rate2' => (float)$company_gateway->fee_tax_rate2, - 'fee_tax_rate3' => (float)$company_gateway->fee_tax_rate3, - 'fee_cap' => (float)$company_gateway->fee_cap ?: null, - 'adjust_fee_percent' => (bool)$company_gateway->adjust_fee_percent, + //'priority' => (int)$company_gateway->priority, + 'fees_and_limits' => $this->mapFeesAndLimits($company_gateway), 'updated_at' => $company_gateway->updated_at, 'deleted_at' => $company_gateway->deleted_at, ]; @@ -77,4 +66,23 @@ class CompanyGatewayTransformer extends EntityTransformer return $this->includeItem($company_gateway->gateway, $transformer, Gateway::class); } + + private function mapFeesAndLimits($company_gateway) + { + $cg = new \stdClass; + $cg->min_limit = (float)$company_gateway->min_limit ?: null; + $cg->max_limit = (float)$company_gateway->max_limit ?: null; + $cg->fee_amount = (float) $company_gateway->fee_amount ?: null; + $cg->fee_percent = (float)$company_gateway->fee_percent ?: null; + $cg->fee_tax_name1 = (string)$company_gateway->fee_tax_name1 ?: ''; + $cg->fee_tax_name2 = (string) $company_gateway->fee_tax_name2 ?: ''; + $cg->fee_tax_name3 = (string) $company_gateway->fee_tax_name3 ?: ''; + $cg->fee_tax_rate1 = (float) $company_gateway->fee_tax_rate1; + $cg->fee_tax_rate2 = (float)$company_gateway->fee_tax_rate2; + $cg->fee_tax_rate3 = (float)$company_gateway->fee_tax_rate3; + $cg->fee_cap = (float)$company_gateway->fee_cap ?: null; + $cg->adjust_fee_percent = (bool)$company_gateway->adjust_fee_percent; + + return $cg; + } } diff --git a/app/Utils/Traits/CleanLineItems.php b/app/Utils/Traits/CleanLineItems.php index 327b6aafca4c..815af4216189 100644 --- a/app/Utils/Traits/CleanLineItems.php +++ b/app/Utils/Traits/CleanLineItems.php @@ -57,9 +57,10 @@ trait CleanLineItems if(array_key_exists("id", $item)) { - $item['id'] = $item['id']*-1; + unset($item['id']); } + return $item; } diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 926fe440f490..29ceadfbc5e7 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -152,19 +152,12 @@ class CreateUsersTable extends Migration $table->boolean('show_product_cost')->default(false); $table->unsignedInteger('enabled_tax_rates')->default(1); - // $table->string('website')->nullable(); - // $table->string('address1')->nullable(); - // $table->string('address2')->nullable(); - // $table->string('city')->nullable(); - // $table->string('state')->nullable(); - // $table->string('postal_code')->nullable(); - // $table->string('phone')->nullable(); - // $table->string('email')->nullable(); - // $table->unsignedInteger('country_id')->nullable(); + $table->boolean('enable_product_cost')->default(0); + $table->boolean('enable_product_quantity')->default(1); + $table->boolean('default_quantity')->default(1); + $table->string('domain')->nullable(); $table->string('db')->nullable(); - // $table->string('vat_number')->nullable(); - // $table->string('id_number')->nullable(); $table->unsignedInteger('size_id')->nullable(); $table->string('first_day_of_week')->nullable(); $table->string('first_month_of_year')->nullable(); @@ -434,7 +427,7 @@ class CreateUsersTable extends Migration $t->boolean('is_deleted')->default(false); $t->text('line_items')->nullable(); - $t->text('settings')->nullable(); + //$t->text('settings')->nullable(); $t->text('backup')->nullable(); $t->text('footer')->nullable(); @@ -451,6 +444,8 @@ class CreateUsersTable extends Migration $t->string('tax_name3')->nullable(); $t->decimal('tax_rate3', 13, 3)->default(0); + $t->boolean('uses_inclusive_taxes')->default(0); + $t->string('custom_value1')->nullable(); $t->string('custom_value2')->nullable(); $t->string('custom_value3')->nullable(); @@ -460,7 +455,10 @@ class CreateUsersTable extends Migration $t->string('custom_surcharge2')->nullable(); $t->string('custom_surcharge3')->nullable(); $t->string('custom_surcharge4')->nullable(); - $t->boolean('custom_surcharge_taxes')->default(false); + $t->boolean('custom_surcharge_tax1')->default(false); + $t->boolean('custom_surcharge_tax2')->default(false); + $t->boolean('custom_surcharge_tax3')->default(false); + $t->boolean('custom_surcharge_tax4')->default(false); $t->decimal('amount', 16, 4); $t->decimal('balance', 16, 4); diff --git a/database/migrations/2019_11_10_115926_create_failed_jobs_table.php b/database/migrations/2019_11_10_115926_create_failed_jobs_table.php new file mode 100644 index 000000000000..389bdf768a2e --- /dev/null +++ b/database/migrations/2019_11_10_115926_create_failed_jobs_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('failed_jobs'); + } +} diff --git a/database/seeds/RandomDataSeeder.php b/database/seeds/RandomDataSeeder.php index 3294fdc0f9bd..23dcd666658a 100644 --- a/database/seeds/RandomDataSeeder.php +++ b/database/seeds/RandomDataSeeder.php @@ -114,24 +114,19 @@ class RandomDataSeeder extends Seeder factory(\App\Models\Product::class,50)->create(['user_id' => $user->id, 'company_id' => $company->id]); /** Invoice Factory */ - factory(\App\Models\Invoice::class,500)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id, 'settings' => ClientSettings::buildClientSettings($company->settings, $client->settings)]); - - $invoices = Invoice::all(); + factory(\App\Models\Invoice::class,50)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]); + + $invoices = Invoice::cursor(); $invoice_repo = new InvoiceRepository(); $invoices->each(function ($invoice) use($invoice_repo, $user, $company, $client){ - - $settings = $invoice->settings; - //$settings->inclusive_taxes = (bool)random_int(0, 1); - $settings->inclusive_taxes = true; - $invoice->settings = $settings; $invoice_calc = null; - if($settings->inclusive_taxes) - $invoice_calc = new InvoiceSumInclusive($invoice, $invoice->settings); + if($invoice->uses_inclusive_taxes) + $invoice_calc = new InvoiceSumInclusive($invoice); else - $invoice_calc = new InvoiceSum($invoice, $invoice->settings); + $invoice_calc = new InvoiceSum($invoice); $invoice = $invoice_calc->build()->getInvoice(); diff --git a/tests/Feature/InvitationTest.php b/tests/Feature/InvitationTest.php index cac521e6ce90..594f5d82dd58 100644 --- a/tests/Feature/InvitationTest.php +++ b/tests/Feature/InvitationTest.php @@ -102,7 +102,7 @@ class InvitationTest extends TestCase $client = Client::whereUserId($user->id)->whereCompanyId($company->id)->first(); - factory(\App\Models\Invoice::class,5)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id, 'settings' => ClientSettings::buildClientSettings($company->settings, $client->settings)]); + factory(\App\Models\Invoice::class,5)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]); $invoice = Invoice::whereUserId($user->id)->whereCompanyId($company->id)->whereClientId($client->id)->first(); diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index 7f0a2627e020..238926edaa07 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -131,9 +131,6 @@ class InvoiceTest extends TestCase ]; $this->assertNotNull($this->invoice); - $this->assertNotNull($this->invoice->settings); - - $this->assertTrue(property_exists($this->invoice->settings, 'custom_invoice_taxes1')); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), diff --git a/tests/Feature/QuoteTest.php b/tests/Feature/QuoteTest.php index f3f95bd0f76d..fc7312b3671c 100644 --- a/tests/Feature/QuoteTest.php +++ b/tests/Feature/QuoteTest.php @@ -185,7 +185,7 @@ class QuoteTest extends TestCase $this->assertNotNull($quote); $this->assertNotNull($quote->settings); - $this->assertTrue(property_exists($quote->settings, 'custom_invoice_taxes1')); + $this->assertTrue(property_exists($quote->settings, 'military_time')); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), diff --git a/tests/Feature/RecurringInvoiceTest.php b/tests/Feature/RecurringInvoiceTest.php index 1a7bf34db262..d12140fe9e45 100644 --- a/tests/Feature/RecurringInvoiceTest.php +++ b/tests/Feature/RecurringInvoiceTest.php @@ -185,7 +185,7 @@ class RecurringInvoiceTest extends TestCase $this->assertNotNull($RecurringInvoice); $this->assertNotNull($RecurringInvoice->settings); - $this->assertTrue(property_exists($RecurringInvoice->settings, 'custom_invoice_taxes1')); + $this->assertTrue(property_exists($RecurringInvoice->settings, 'military_time')); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), diff --git a/tests/Feature/RecurringQuoteTest.php b/tests/Feature/RecurringQuoteTest.php index 11be88b4df6d..a0a1d7a52079 100644 --- a/tests/Feature/RecurringQuoteTest.php +++ b/tests/Feature/RecurringQuoteTest.php @@ -186,7 +186,7 @@ class RecurringQuoteTest extends TestCase $this->assertNotNull($RecurringQuote); $this->assertNotNull($RecurringQuote->settings); - $this->assertTrue(property_exists($RecurringQuote->settings, 'custom_invoice_taxes1')); + $this->assertTrue(property_exists($RecurringQuote->settings, 'military_time')); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index b5eb1f998a0b..493fcf7fa657 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -103,18 +103,11 @@ trait MockAccountData $this->invoice->client_id = $this->client->id; $this->invoice->line_items = $this->buildLineItems(); - - $this->settings = $this->client->getMergedSettings(); + $this->invoice->uses_inclusive_Taxes = false; - $this->settings->custom_taxes1 = false; - $this->settings->custom_taxes2 = false; - $this->settings->inclusive_taxes = false; - $this->settings->precision = 2; - - $this->invoice->settings = $this->settings; $this->invoice->save(); - $this->invoice_calc = new InvoiceSum($this->invoice, $this->settings); + $this->invoice_calc = new InvoiceSum($this->invoice); $this->invoice_calc->build(); $this->invoice = $this->invoice_calc->getInvoice(); diff --git a/tests/Unit/CompareObjectTest.php b/tests/Unit/CompareObjectTest.php index c2d2eadb65ef..e3d61ff70d61 100644 --- a/tests/Unit/CompareObjectTest.php +++ b/tests/Unit/CompareObjectTest.php @@ -57,7 +57,7 @@ class CompareObjectTest extends TestCase $this->assertEquals($settings->timezone_id, 15); $this->assertEquals($settings->language_id, 1); $this->assertEquals($settings->payment_terms, 1); - $this->assertFalse($settings->custom_invoice_taxes1); + $this->assertFalse($settings->send_portal_password); } diff --git a/tests/Unit/InvoiceInclusiveTest.php b/tests/Unit/InvoiceInclusiveTest.php index 1f6c9c82f07a..33d0b5eac82e 100644 --- a/tests/Unit/InvoiceInclusiveTest.php +++ b/tests/Unit/InvoiceInclusiveTest.php @@ -34,12 +34,9 @@ class InvoiceInclusiveTest extends TestCase $this->invoice->line_items = $this->buildLineItems(); - $this->settings = $this->invoice->settings; + $this->invoice->uses_inclusive_taxes = true; - $this->settings->inclusive_taxes = true; - $this->settings->precision = 2; - - $this->invoice_calc = new InvoiceSumInclusive($this->invoice, $this->settings); + $this->invoice_calc = new InvoiceSumInclusive($this->invoice); } @@ -133,7 +130,7 @@ class InvoiceInclusiveTest extends TestCase $this->invoice->custom_surcharge1 = 5; $this->invoice->tax_name1 = 'GST'; $this->invoice->tax_rate1 = 10; - $this->settings->inclusive_taxes = true; + $this->invoice->uses_inclusive_taxes = true; $this->invoice->is_amount_discount = true; $this->invoice_calc->build(); @@ -153,7 +150,7 @@ class InvoiceInclusiveTest extends TestCase $this->invoice->tax_rate1 = 10; $this->invoice->tax_name2 = 'GST'; $this->invoice->tax_rate2 = 10; - $this->settings->inclusive_taxes = true; + $this->invoice->uses_inclusive_taxes = true; $this->invoice->is_amount_discount = true; $this->invoice_calc->build(); @@ -186,7 +183,7 @@ class InvoiceInclusiveTest extends TestCase $this->invoice->line_items = $line_items; - $this->settings->inclusive_taxes = true; + $this->invoice->uses_inclusive_taxes = true; $this->invoice->discount = 0; $this->invoice->custom_surcharge1 = 0; @@ -222,7 +219,7 @@ class InvoiceInclusiveTest extends TestCase $this->invoice->line_items = $line_items; - $this->settings->inclusive_taxes = true; + $this->invoice->uses_inclusive_taxes = true; $this->invoice->discount = 0; $this->invoice->custom_surcharge1 = 0; @@ -263,7 +260,7 @@ class InvoiceInclusiveTest extends TestCase $this->invoice->line_items = $line_items; - $this->settings->inclusive_taxes = true; + $this->invoice->uses_inclusive_taxes = true; $this->invoice->discount = 5; $this->invoice->is_amount_discount = false; $this->invoice->custom_surcharge1 = 0; @@ -308,7 +305,7 @@ class InvoiceInclusiveTest extends TestCase $this->invoice->line_items = $line_items; - $this->settings->inclusive_taxes = true; + $this->invoice->uses_inclusive_taxes = true; $this->invoice->discount = 5; $this->invoice->is_amount_discount = true; $this->invoice->custom_surcharge1 = 0; @@ -354,7 +351,7 @@ class InvoiceInclusiveTest extends TestCase $this->invoice->line_items = $line_items; - $this->settings->inclusive_taxes = true; + $this->invoice->uses_inclusive_taxes = true; $this->invoice->discount = 5; $this->invoice->is_amount_discount = true; $this->invoice->custom_surcharge1 = 0; diff --git a/tests/Unit/InvoiceItemInclusiveTest.php b/tests/Unit/InvoiceItemInclusiveTest.php index ba6a02548bcb..01bc55c2373a 100644 --- a/tests/Unit/InvoiceItemInclusiveTest.php +++ b/tests/Unit/InvoiceItemInclusiveTest.php @@ -41,7 +41,7 @@ class InvoiceItemInclusiveTest extends TestCase $this->invoice->line_items = [$item]; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getLineTotal(), 10); @@ -61,7 +61,7 @@ class InvoiceItemInclusiveTest extends TestCase $settings->inclusive_taxes = true; $settings->precision = 2; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getLineTotal(), 8); @@ -81,7 +81,7 @@ class InvoiceItemInclusiveTest extends TestCase $settings->inclusive_taxes = true; $settings->precision = 2; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getLineTotal(), 7.48); @@ -103,7 +103,7 @@ class InvoiceItemInclusiveTest extends TestCase $this->invoice->line_items = [$item]; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getTotalTaxes(), 0.91); @@ -126,7 +126,7 @@ class InvoiceItemInclusiveTest extends TestCase $this->invoice->line_items = [$item]; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getTotalTaxes(), 0.73); @@ -149,7 +149,7 @@ class InvoiceItemInclusiveTest extends TestCase $settings->inclusive_taxes = true; $settings->precision = 2; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getTotalTaxes(), 2.4); @@ -173,7 +173,7 @@ class InvoiceItemInclusiveTest extends TestCase $settings->inclusive_taxes = false; $settings->precision = 2; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getSubTotal(), 9); @@ -196,7 +196,7 @@ class InvoiceItemInclusiveTest extends TestCase $settings->inclusive_taxes = false; $settings->precision = 2; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getSubTotal(), 19); @@ -220,7 +220,7 @@ class InvoiceItemInclusiveTest extends TestCase $settings->inclusive_taxes = false; $settings->precision = 2; - $item_calc = new InvoiceItemSumInclusive($this->invoice, $settings); + $item_calc = new InvoiceItemSumInclusive($this->invoice); $item_calc->process(); $this->assertEquals($item_calc->getSubTotal(), 19.8); diff --git a/tests/Unit/InvoiceTest.php b/tests/Unit/InvoiceTest.php index 98998d4d9186..7dc2bc2bec31 100644 --- a/tests/Unit/InvoiceTest.php +++ b/tests/Unit/InvoiceTest.php @@ -33,15 +33,10 @@ class InvoiceTest extends TestCase $this->invoice->line_items = $this->buildLineItems(); - $this->settings = $this->invoice->settings; - - $this->settings->custom_invoice_taxes1 = true; - $this->settings->custom_invoice_taxes2 = true; - $this->settings->inclusive_taxes = true; - $this->settings->precision = 2; + $this->invoice->usesinclusive_taxes = true; - $this->invoice_calc = new InvoiceSum($this->invoice, $this->settings); + $this->invoice_calc = new InvoiceSum($this->invoice); } @@ -119,7 +114,7 @@ class InvoiceTest extends TestCase $this->invoice->custom_value1 = 5; $this->invoice->tax_name1 = 'GST'; $this->invoice->tax_rate1 = 10; - $this->settings->inclusive_taxes = false; + $this->invoice->uses_inclusive_taxes = false; $this->invoice->is_amount_discount = true; //$this->invoice_calc = new InvoiceSum($this->invoice, $this->settings); @@ -135,7 +130,7 @@ class InvoiceTest extends TestCase public function testInvoiceTotalsWithDiscountWithSurchargeWithDoubleExclusiveTax() { - $this->invoice_calc = new InvoiceSum($this->invoice, $this->settings); + $this->invoice_calc = new InvoiceSum($this->invoice); $this->invoice->discount = 5; $this->invoice->custom_value1 = 5; @@ -143,7 +138,7 @@ class InvoiceTest extends TestCase $this->invoice->tax_rate1 = 10; $this->invoice->tax_name2 = 'GST'; $this->invoice->tax_rate2 = 10; - $this->settings->inclusive_taxes = false; + $this->invoice->uses_inclusive_taxes = false; $this->invoice_calc->build(); @@ -176,11 +171,11 @@ class InvoiceTest extends TestCase $this->invoice->line_items = $line_items; - $this->settings->inclusive_taxes = true; + $this->invoice->uses_inclusive_taxes = true; $this->invoice->discount = 0; $this->invoice->custom_value1 = 0; - $this->invoice_calc = new InvoiceSum($this->invoice, $this->settings); + $this->invoice_calc = new InvoiceSum($this->invoice); $this->invoice_calc->build(); $this->assertEquals($this->invoice_calc->getSubTotal(), 20); @@ -218,8 +213,8 @@ class InvoiceTest extends TestCase $this->invoice->tax_name2 = 'GST'; $this->invoice->tax_rate2 = 10; - $this->settings->inclusive_taxes = false; - $this->invoice_calc = new InvoiceSum($this->invoice, $this->settings); + $this->invoice->uses_inclusive_taxes = false; + $this->invoice_calc = new InvoiceSum($this->invoice); $this->invoice_calc->build(); $this->assertEquals($this->invoice_calc->getSubTotal(), 20);