fixed #36
This commit is contained in:
parent
88e62a8354
commit
bbb34ab50a
@ -70,6 +70,17 @@ class Account extends Model
|
||||
return $this->hasMany('App\Models\Expense\Payment');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert opening balance to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setOpeningBalanceAttribute($value)
|
||||
{
|
||||
$this->attributes['opening_balance'] = (float) $value;
|
||||
}
|
||||
|
||||
public function canDelete()
|
||||
{
|
||||
$error = false;
|
||||
|
@ -84,6 +84,28 @@ class Bill extends Model
|
||||
return $this->hasMany('App\Models\Expense\BillHistory');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert amount to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setAmountAttribute($value)
|
||||
{
|
||||
$this->attributes['amount'] = (float) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert currency rate to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrencyRateAttribute($value)
|
||||
{
|
||||
$this->attributes['currency_rate'] = (float) $value;
|
||||
}
|
||||
|
||||
public function scopeDue($query, $date)
|
||||
{
|
||||
return $query->where('due_at', '=', $date);
|
||||
|
@ -64,6 +64,28 @@ class Payment extends Model
|
||||
return $this->hasMany('App\Models\Banking\Transfer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert amount to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setAmountAttribute($value)
|
||||
{
|
||||
$this->attributes['amount'] = (float) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert currency rate to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrencyRateAttribute($value)
|
||||
{
|
||||
$this->attributes['currency_rate'] = (float) $value;
|
||||
}
|
||||
|
||||
public static function scopeLatest($query)
|
||||
{
|
||||
return $query->orderBy('paid_at', 'desc');
|
||||
|
@ -89,6 +89,28 @@ class Invoice extends Model
|
||||
return $this->hasMany('App\Models\Income\InvoiceHistory');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert amount to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setAmountAttribute($value)
|
||||
{
|
||||
$this->attributes['amount'] = (float) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert currency rate to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrencyRateAttribute($value)
|
||||
{
|
||||
$this->attributes['currency_rate'] = (float) $value;
|
||||
}
|
||||
|
||||
public function scopeDue($query, $date)
|
||||
{
|
||||
return $query->where('due_at', '=', $date);
|
||||
|
@ -70,6 +70,28 @@ class Revenue extends Model
|
||||
return $this->hasMany('App\Models\Banking\Transfer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert amount to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setAmountAttribute($value)
|
||||
{
|
||||
$this->attributes['amount'] = (float) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert currency rate to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrencyRateAttribute($value)
|
||||
{
|
||||
$this->attributes['currency_rate'] = (float) $value;
|
||||
}
|
||||
|
||||
public function scopeLatest($query)
|
||||
{
|
||||
return $query->orderBy('paid_at', 'desc');
|
||||
|
@ -59,6 +59,28 @@ class Item extends Model
|
||||
return $this->hasMany('App\Models\Income\Invoice');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert sale price to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setSalePriceAttribute($value)
|
||||
{
|
||||
$this->attributes['sale_price'] = (float) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert purchase price to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPurchasePriceAttribute($value)
|
||||
{
|
||||
$this->attributes['purchase_price'] = (float) $value;
|
||||
}
|
||||
|
||||
public function getConvertedAmount($format = false)
|
||||
{
|
||||
return $this->convert($this->amount, $this->currency_code, $this->currency_rate, $format);
|
||||
|
@ -53,6 +53,17 @@ class Currency extends Model
|
||||
return $this->hasMany('App\Models\Expense\Payment', 'currency_code', 'code');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert rate to float.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setRateAttribute($value)
|
||||
{
|
||||
$this->attributes['rate'] = (float) $value;
|
||||
}
|
||||
|
||||
public function canDisable()
|
||||
{
|
||||
$error = false;
|
||||
|
@ -18,7 +18,7 @@ class CreateAccountsTable extends Migration
|
||||
$table->string('name');
|
||||
$table->string('number');
|
||||
$table->string('currency_code');
|
||||
$table->decimal('opening_balance')->default('0');
|
||||
$table->float('opening_balance', 15, 4)->default('0.0000');
|
||||
$table->string('bank_name')->nullable();
|
||||
$table->string('bank_phone')->nullable();
|
||||
$table->text('bank_address')->nullable();
|
||||
|
Loading…
x
Reference in New Issue
Block a user