1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

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
This commit is contained in:
David Bomba 2019-11-10 23:06:30 +11:00 committed by GitHub
parent a78b6aaacd
commit 37a826374b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 249 additions and 169 deletions

View File

@ -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',

View File

@ -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',

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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([]);

View File

@ -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();

View File

@ -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();

View File

@ -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="______"),

View File

@ -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"),

View File

@ -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="____________"),

View File

@ -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="_________"),

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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();
}
}
}

View File

@ -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'])
{

View File

@ -98,6 +98,7 @@ class Client extends BaseModel
];
protected $casts = [
'country_id' => 'string',
'settings' => 'object',
'updated_at' => 'timestamp',
'created_at' => 'timestamp',

View File

@ -77,6 +77,8 @@ class Company extends BaseModel
];
protected $casts = [
'country_id' => 'string',
'custom_fields' => 'object',
'settings' => 'object',
'custom_fields' => 'object',
'updated_at' => 'timestamp',

View File

@ -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);

View File

@ -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;

View File

@ -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}]",
]);
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class GmailTestNotification extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->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 [
//
];
}
}

View File

@ -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;
}
}

View File

@ -57,9 +57,10 @@ trait CleanLineItems
if(array_key_exists("id", $item))
{
$item['id'] = $item['id']*-1;
unset($item['id']);
}
return $item;
}

View File

@ -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);

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->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');
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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'),

View File

@ -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'),

View File

@ -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'),

View File

@ -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'),

View File

@ -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();

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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);