From 5e7d3392aba51a43bb88d0b24281d003b32530e1 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Sat, 21 Oct 2017 14:23:57 +0300 Subject: [PATCH] fixed #53 --- .../{Version104.php => Version107.php} | 14 +++++------- app/Models/Banking/Account.php | 4 ++-- app/Models/Expense/Bill.php | 8 +++---- app/Models/Expense/BillItem.php | 22 +++++++++++++++++++ app/Models/Expense/BillPayment.php | 22 +++++++++++++++++++ app/Models/Expense/BillTotal.php | 11 ++++++++++ app/Models/Expense/Payment.php | 8 +++---- app/Models/Income/Invoice.php | 8 +++---- app/Models/Income/InvoiceItem.php | 22 +++++++++++++++++++ app/Models/Income/InvoicePayment.php | 22 +++++++++++++++++++ app/Models/Income/InvoiceTotal.php | 11 ++++++++++ app/Models/Income/Revenue.php | 8 +++---- app/Models/Item/Item.php | 8 +++---- app/Models/Setting/Currency.php | 4 ++-- app/Models/Setting/Tax.php | 11 ++++++++++ app/Providers/EventServiceProvider.php | 3 ++- ...017_09_01_000000_create_accounts_table.php | 2 +- .../2017_09_01_000000_create_bills_table.php | 12 +++++----- ...7_09_01_000000_create_currencies_table.php | 2 +- ...017_09_01_000000_create_invoices_table.php | 14 ++++++------ .../2017_09_01_000000_create_items_table.php | 4 ++-- ...017_09_01_000000_create_payments_table.php | 4 ++-- ...017_09_01_000000_create_revenues_table.php | 4 ++-- .../2017_09_01_000000_create_taxes_table.php | 2 +- ..._10_11_000000_create_bill_totals_table.php | 2 +- ..._11_000000_create_invoice_totals_table.php | 2 +- 26 files changed, 177 insertions(+), 57 deletions(-) rename app/Listeners/Updates/{Version104.php => Version107.php} (58%) diff --git a/app/Listeners/Updates/Version104.php b/app/Listeners/Updates/Version107.php similarity index 58% rename from app/Listeners/Updates/Version104.php rename to app/Listeners/Updates/Version107.php index cfde224c9..acb001474 100644 --- a/app/Listeners/Updates/Version104.php +++ b/app/Listeners/Updates/Version107.php @@ -2,14 +2,14 @@ namespace App\Listeners\Updates; -//use App\Models\Auth\Permission; use App\Events\UpdateFinished; +use DB; -class Version104 extends Listener +class Version107 extends Listener { const ALIAS = 'core'; - const VERSION = '1.0.4'; + const VERSION = '1.0.7'; /** * Handle the event. @@ -24,10 +24,8 @@ class Version104 extends Listener return; } - /*Permission::create([ - 'name' => 'john-doe', - 'display_name' => 'John Doe', - 'description' => 'John Doe', - ]);*/ + $table = env('DB_PREFIX') . 'taxes'; + + DB::statement("ALTER TABLE `$table` MODIFY `rate` DOUBLE(15,4) NOT NULL"); } } diff --git a/app/Models/Banking/Account.php b/app/Models/Banking/Account.php index 1d2c7c856..950ed2915 100644 --- a/app/Models/Banking/Account.php +++ b/app/Models/Banking/Account.php @@ -71,14 +71,14 @@ class Account extends Model } /** - * Convert opening balance to float. + * Convert opening balance to double. * * @param string $value * @return void */ public function setOpeningBalanceAttribute($value) { - $this->attributes['opening_balance'] = (float) $value; + $this->attributes['opening_balance'] = (double) $value; } /** diff --git a/app/Models/Expense/Bill.php b/app/Models/Expense/Bill.php index 4feb76663..4d5bb1603 100644 --- a/app/Models/Expense/Bill.php +++ b/app/Models/Expense/Bill.php @@ -80,25 +80,25 @@ class Bill extends Model } /** - * Convert amount to float. + * Convert amount to double. * * @param string $value * @return void */ public function setAmountAttribute($value) { - $this->attributes['amount'] = (float) $value; + $this->attributes['amount'] = (double) $value; } /** - * Convert currency rate to float. + * Convert currency rate to double. * * @param string $value * @return void */ public function setCurrencyRateAttribute($value) { - $this->attributes['currency_rate'] = (float) $value; + $this->attributes['currency_rate'] = (double) $value; } public function scopeDue($query, $date) diff --git a/app/Models/Expense/BillItem.php b/app/Models/Expense/BillItem.php index ce3f105d6..986510e3b 100644 --- a/app/Models/Expense/BillItem.php +++ b/app/Models/Expense/BillItem.php @@ -33,4 +33,26 @@ class BillItem extends Model { return $this->belongsTo('App\Models\Setting\Tax'); } + + /** + * Convert price to double. + * + * @param string $value + * @return void + */ + public function setPriceAttribute($value) + { + $this->attributes['price'] = (double) $value; + } + + /** + * Convert total to double. + * + * @param string $value + * @return void + */ + public function setTotalAttribute($value) + { + $this->attributes['total'] = (double) $value; + } } diff --git a/app/Models/Expense/BillPayment.php b/app/Models/Expense/BillPayment.php index e7b1c116c..79598d56d 100644 --- a/app/Models/Expense/BillPayment.php +++ b/app/Models/Expense/BillPayment.php @@ -45,4 +45,26 @@ class BillPayment extends Model { return $query->orderBy('paid_at', 'desc'); } + + /** + * Convert amount to double. + * + * @param string $value + * @return void + */ + public function setAmountAttribute($value) + { + $this->attributes['amount'] = (double) $value; + } + + /** + * Convert currency rate to double. + * + * @param string $value + * @return void + */ + public function setCurrencyRateAttribute($value) + { + $this->attributes['currency_rate'] = (double) $value; + } } diff --git a/app/Models/Expense/BillTotal.php b/app/Models/Expense/BillTotal.php index 5ad66d03b..10127f3bb 100644 --- a/app/Models/Expense/BillTotal.php +++ b/app/Models/Expense/BillTotal.php @@ -22,4 +22,15 @@ class BillTotal extends Model { return $this->belongsTo('App\Models\Expense\Bill'); } + + /** + * Convert amount to double. + * + * @param string $value + * @return void + */ + public function setAmountAttribute($value) + { + $this->attributes['amount'] = (double) $value; + } } diff --git a/app/Models/Expense/Payment.php b/app/Models/Expense/Payment.php index 1fca04f28..33d7da38e 100644 --- a/app/Models/Expense/Payment.php +++ b/app/Models/Expense/Payment.php @@ -65,25 +65,25 @@ class Payment extends Model } /** - * Convert amount to float. + * Convert amount to double. * * @param string $value * @return void */ public function setAmountAttribute($value) { - $this->attributes['amount'] = (float) $value; + $this->attributes['amount'] = (double) $value; } /** - * Convert currency rate to float. + * Convert currency rate to double. * * @param string $value * @return void */ public function setCurrencyRateAttribute($value) { - $this->attributes['currency_rate'] = (float) $value; + $this->attributes['currency_rate'] = (double) $value; } public static function scopeLatest($query) diff --git a/app/Models/Income/Invoice.php b/app/Models/Income/Invoice.php index fdb7a2279..425e3d0c5 100644 --- a/app/Models/Income/Invoice.php +++ b/app/Models/Income/Invoice.php @@ -85,25 +85,25 @@ class Invoice extends Model } /** - * Convert amount to float. + * Convert amount to double. * * @param string $value * @return void */ public function setAmountAttribute($value) { - $this->attributes['amount'] = (float) $value; + $this->attributes['amount'] = (double) $value; } /** - * Convert currency rate to float. + * Convert currency rate to double. * * @param string $value * @return void */ public function setCurrencyRateAttribute($value) { - $this->attributes['currency_rate'] = (float) $value; + $this->attributes['currency_rate'] = (double) $value; } public function scopeDue($query, $date) diff --git a/app/Models/Income/InvoiceItem.php b/app/Models/Income/InvoiceItem.php index 55e92dc9b..b50ee2cf6 100644 --- a/app/Models/Income/InvoiceItem.php +++ b/app/Models/Income/InvoiceItem.php @@ -33,4 +33,26 @@ class InvoiceItem extends Model { return $this->belongsTo('App\Models\Setting\Tax'); } + + /** + * Convert price to double. + * + * @param string $value + * @return void + */ + public function setPriceAttribute($value) + { + $this->attributes['price'] = (double) $value; + } + + /** + * Convert total to double. + * + * @param string $value + * @return void + */ + public function setTotalAttribute($value) + { + $this->attributes['total'] = (double) $value; + } } diff --git a/app/Models/Income/InvoicePayment.php b/app/Models/Income/InvoicePayment.php index 295fe8f7a..79eb4f21f 100644 --- a/app/Models/Income/InvoicePayment.php +++ b/app/Models/Income/InvoicePayment.php @@ -45,4 +45,26 @@ class InvoicePayment extends Model { return $query->orderBy('paid_at', 'desc'); } + + /** + * Convert amount to double. + * + * @param string $value + * @return void + */ + public function setAmountAttribute($value) + { + $this->attributes['amount'] = (double) $value; + } + + /** + * Convert currency rate to double. + * + * @param string $value + * @return void + */ + public function setCurrencyRateAttribute($value) + { + $this->attributes['currency_rate'] = (double) $value; + } } diff --git a/app/Models/Income/InvoiceTotal.php b/app/Models/Income/InvoiceTotal.php index 8ed61ac40..e97e984fa 100644 --- a/app/Models/Income/InvoiceTotal.php +++ b/app/Models/Income/InvoiceTotal.php @@ -22,4 +22,15 @@ class InvoiceTotal extends Model { return $this->belongsTo('App\Models\Income\Invoice'); } + + /** + * Convert amount to double. + * + * @param string $value + * @return void + */ + public function setAmountAttribute($value) + { + $this->attributes['amount'] = (double) $value; + } } diff --git a/app/Models/Income/Revenue.php b/app/Models/Income/Revenue.php index 2e3cd8c7d..0299cabff 100644 --- a/app/Models/Income/Revenue.php +++ b/app/Models/Income/Revenue.php @@ -71,25 +71,25 @@ class Revenue extends Model } /** - * Convert amount to float. + * Convert amount to double. * * @param string $value * @return void */ public function setAmountAttribute($value) { - $this->attributes['amount'] = (float) $value; + $this->attributes['amount'] = (double) $value; } /** - * Convert currency rate to float. + * Convert currency rate to double. * * @param string $value * @return void */ public function setCurrencyRateAttribute($value) { - $this->attributes['currency_rate'] = (float) $value; + $this->attributes['currency_rate'] = (double) $value; } public function scopeLatest($query) diff --git a/app/Models/Item/Item.php b/app/Models/Item/Item.php index 99e1020a5..a1008b0c3 100644 --- a/app/Models/Item/Item.php +++ b/app/Models/Item/Item.php @@ -60,25 +60,25 @@ class Item extends Model } /** - * Convert sale price to float. + * Convert sale price to double. * * @param string $value * @return void */ public function setSalePriceAttribute($value) { - $this->attributes['sale_price'] = (float) $value; + $this->attributes['sale_price'] = (double) $value; } /** - * Convert purchase price to float. + * Convert purchase price to double. * * @param string $value * @return void */ public function setPurchasePriceAttribute($value) { - $this->attributes['purchase_price'] = (float) $value; + $this->attributes['purchase_price'] = (double) $value; } public static function getItems($filter_data = array()) diff --git a/app/Models/Setting/Currency.php b/app/Models/Setting/Currency.php index b937f01e6..704194b80 100644 --- a/app/Models/Setting/Currency.php +++ b/app/Models/Setting/Currency.php @@ -54,13 +54,13 @@ class Currency extends Model } /** - * Convert rate to float. + * Convert rate to double. * * @param string $value * @return void */ public function setRateAttribute($value) { - $this->attributes['rate'] = (float) $value; + $this->attributes['rate'] = (double) $value; } } diff --git a/app/Models/Setting/Tax.php b/app/Models/Setting/Tax.php index 98f5f6d60..e3d71f6f8 100644 --- a/app/Models/Setting/Tax.php +++ b/app/Models/Setting/Tax.php @@ -37,4 +37,15 @@ class Tax extends Model { return $this->hasMany('App\Models\Income\InvoiceItem'); } + + /** + * Convert rate to double. + * + * @param string $value + * @return void + */ + public function setRateAttribute($value) + { + $this->attributes['rate'] = (double) $value; + } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index a83ab6343..3595b29a2 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -14,7 +14,8 @@ class EventServiceProvider extends ServiceProvider */ protected $listen = [ 'App\Events\UpdateFinished' => [ - 'App\Listeners\Updates\Version104', + 'App\Listeners\Updates\Version106', + 'App\Listeners\Updates\Version107', ], 'Illuminate\Auth\Events\Login' => [ 'App\Listeners\Auth\Login', diff --git a/database/migrations/2017_09_01_000000_create_accounts_table.php b/database/migrations/2017_09_01_000000_create_accounts_table.php index c3a2321a2..d95bc1b98 100644 --- a/database/migrations/2017_09_01_000000_create_accounts_table.php +++ b/database/migrations/2017_09_01_000000_create_accounts_table.php @@ -18,7 +18,7 @@ class CreateAccountsTable extends Migration $table->string('name'); $table->string('number'); $table->string('currency_code'); - $table->float('opening_balance', 15, 4)->default('0.0000'); + $table->double('opening_balance', 15, 4)->default('0.0000'); $table->string('bank_name')->nullable(); $table->string('bank_phone')->nullable(); $table->text('bank_address')->nullable(); diff --git a/database/migrations/2017_09_01_000000_create_bills_table.php b/database/migrations/2017_09_01_000000_create_bills_table.php index b2cef1bf4..66e27ae10 100644 --- a/database/migrations/2017_09_01_000000_create_bills_table.php +++ b/database/migrations/2017_09_01_000000_create_bills_table.php @@ -20,9 +20,9 @@ class CreateBillsTable extends Migration $table->string('bill_status_code'); $table->date('billed_at'); $table->date('due_at'); - $table->float('amount', 15, 4); + $table->double('amount', 15, 4); $table->string('currency_code'); - $table->float('currency_rate', 15, 8); + $table->double('currency_rate', 15, 8); $table->integer('vendor_id'); $table->string('vendor_name'); $table->string('vendor_email'); @@ -46,8 +46,8 @@ class CreateBillsTable extends Migration $table->string('name'); $table->string('sku')->nullable(); $table->integer('quantity'); - $table->float('price', 15, 4); - $table->float('total', 15, 4); + $table->double('price', 15, 4); + $table->double('total', 15, 4); $table->float('tax', 15, 4)->default('0.0000'); $table->integer('tax_id'); $table->timestamps(); @@ -73,9 +73,9 @@ class CreateBillsTable extends Migration $table->integer('bill_id'); $table->integer('account_id'); $table->date('paid_at'); - $table->float('amount', 15, 4); + $table->double('amount', 15, 4); $table->string('currency_code'); - $table->float('currency_rate', 15, 8); + $table->double('currency_rate', 15, 8); $table->text('description')->nullable(); $table->string('payment_method'); $table->string('reference')->nullable(); diff --git a/database/migrations/2017_09_01_000000_create_currencies_table.php b/database/migrations/2017_09_01_000000_create_currencies_table.php index 74ca20705..49ca90f60 100644 --- a/database/migrations/2017_09_01_000000_create_currencies_table.php +++ b/database/migrations/2017_09_01_000000_create_currencies_table.php @@ -17,7 +17,7 @@ class CreateCurrenciesTable extends Migration $table->integer('company_id'); $table->string('name'); $table->string('code'); - $table->float('rate', 15, 8); + $table->double('rate', 15, 8); $table->tinyInteger('enabled')->default(0); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2017_09_01_000000_create_invoices_table.php b/database/migrations/2017_09_01_000000_create_invoices_table.php index 94fff7818..072a302d6 100644 --- a/database/migrations/2017_09_01_000000_create_invoices_table.php +++ b/database/migrations/2017_09_01_000000_create_invoices_table.php @@ -20,9 +20,9 @@ class CreateInvoicesTable extends Migration $table->string('invoice_status_code'); $table->date('invoiced_at'); $table->date('due_at'); - $table->float('amount', 15, 4); + $table->double('amount', 15, 4); $table->string('currency_code'); - $table->float('currency_rate', 15, 8); + $table->double('currency_rate', 15, 8); $table->integer('customer_id'); $table->string('customer_name'); $table->string('customer_email'); @@ -46,9 +46,9 @@ class CreateInvoicesTable extends Migration $table->string('name'); $table->string('sku')->nullable(); $table->integer('quantity'); - $table->float('price', 15, 4); - $table->float('total', 15, 4); - $table->float('tax', 15, 4)->default('0.0000'); + $table->double('price', 15, 4); + $table->double('total', 15, 4); + $table->double('tax', 15, 4)->default('0.0000'); $table->integer('tax_id'); $table->timestamps(); $table->softDeletes(); @@ -73,9 +73,9 @@ class CreateInvoicesTable extends Migration $table->integer('invoice_id'); $table->integer('account_id'); $table->date('paid_at'); - $table->float('amount', 15, 4); + $table->double('amount', 15, 4); $table->string('currency_code'); - $table->float('currency_rate', 15, 8); + $table->double('currency_rate', 15, 8); $table->text('description')->nullable(); $table->string('payment_method'); $table->string('reference')->nullable(); diff --git a/database/migrations/2017_09_01_000000_create_items_table.php b/database/migrations/2017_09_01_000000_create_items_table.php index 260504d18..d76144ae8 100644 --- a/database/migrations/2017_09_01_000000_create_items_table.php +++ b/database/migrations/2017_09_01_000000_create_items_table.php @@ -18,8 +18,8 @@ class CreateItemsTable extends Migration $table->string('name'); $table->string('sku'); $table->text('description')->nullable(); - $table->float('sale_price', 15, 4); - $table->float('purchase_price', 15, 4); + $table->double('sale_price', 15, 4); + $table->double('purchase_price', 15, 4); $table->integer('quantity'); $table->integer('category_id')->nullable(); $table->integer('tax_id')->nullable(); diff --git a/database/migrations/2017_09_01_000000_create_payments_table.php b/database/migrations/2017_09_01_000000_create_payments_table.php index 54860a20f..8d9ea1bb8 100644 --- a/database/migrations/2017_09_01_000000_create_payments_table.php +++ b/database/migrations/2017_09_01_000000_create_payments_table.php @@ -17,9 +17,9 @@ class CreatePaymentsTable extends Migration $table->integer('company_id'); $table->integer('account_id'); $table->date('paid_at'); - $table->float('amount', 15, 4); + $table->double('amount', 15, 4); $table->string('currency_code'); - $table->float('currency_rate', 15, 8); + $table->double('currency_rate', 15, 8); $table->integer('vendor_id')->nullable(); $table->text('description')->nullable(); $table->integer('category_id'); diff --git a/database/migrations/2017_09_01_000000_create_revenues_table.php b/database/migrations/2017_09_01_000000_create_revenues_table.php index d4290dca5..e87bba220 100644 --- a/database/migrations/2017_09_01_000000_create_revenues_table.php +++ b/database/migrations/2017_09_01_000000_create_revenues_table.php @@ -17,9 +17,9 @@ class CreateRevenuesTable extends Migration $table->integer('company_id'); $table->integer('account_id'); $table->date('paid_at'); - $table->float('amount', 15, 4); + $table->double('amount', 15, 4); $table->string('currency_code'); - $table->float('currency_rate', 15, 8); + $table->double('currency_rate', 15, 8); $table->integer('customer_id')->nullable(); $table->text('description')->nullable(); $table->integer('category_id'); diff --git a/database/migrations/2017_09_01_000000_create_taxes_table.php b/database/migrations/2017_09_01_000000_create_taxes_table.php index bf3454fb8..ca0154e37 100644 --- a/database/migrations/2017_09_01_000000_create_taxes_table.php +++ b/database/migrations/2017_09_01_000000_create_taxes_table.php @@ -16,7 +16,7 @@ class CreateTaxesTable extends Migration $table->increments('id'); $table->integer('company_id'); $table->string('name'); - $table->integer('rate'); + $table->double('rate', 15, 4); $table->boolean('enabled'); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2017_10_11_000000_create_bill_totals_table.php b/database/migrations/2017_10_11_000000_create_bill_totals_table.php index 89c84f9c0..d3b8b7a0e 100644 --- a/database/migrations/2017_10_11_000000_create_bill_totals_table.php +++ b/database/migrations/2017_10_11_000000_create_bill_totals_table.php @@ -24,7 +24,7 @@ class CreateBillTotalsTable extends Migration $table->integer('bill_id'); $table->string('code')->nullable(); $table->string('name'); - $table->float('amount', 15, 4); + $table->double('amount', 15, 4); $table->integer('sort_order'); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2017_10_11_000000_create_invoice_totals_table.php b/database/migrations/2017_10_11_000000_create_invoice_totals_table.php index 6a3e1f77b..639232f56 100644 --- a/database/migrations/2017_10_11_000000_create_invoice_totals_table.php +++ b/database/migrations/2017_10_11_000000_create_invoice_totals_table.php @@ -24,7 +24,7 @@ class CreateInvoiceTotalsTable extends Migration $table->integer('invoice_id'); $table->string('code')->nullable(); $table->string('name'); - $table->float('amount', 15, 4); + $table->double('amount', 15, 4); $table->integer('sort_order'); $table->timestamps(); $table->softDeletes();