added some feature for accounting and price
This commit is contained in:
@@ -23,6 +23,7 @@ class Product extends Model
|
||||
private static ?bool $directPriceColumnExists = null;
|
||||
private static ?bool $tradeByQuantityColumnExists = null;
|
||||
private static ?bool $inventoryColumnExists = null;
|
||||
private static ?bool $overrideTradingHoursColumnExists = null;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
@@ -52,9 +53,30 @@ class Product extends Model
|
||||
if (!static::hasInventoryColumn()) {
|
||||
unset($product->attributes['inventory']);
|
||||
}
|
||||
if (!static::hasOverrideTradingHoursColumn()) {
|
||||
unset($product->attributes['override_trading_hours']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static function hasOverrideTradingHoursColumn(): bool
|
||||
{
|
||||
if (static::$overrideTradingHoursColumnExists !== null) {
|
||||
return static::$overrideTradingHoursColumnExists;
|
||||
}
|
||||
|
||||
try {
|
||||
static::$overrideTradingHoursColumnExists = Schema::hasColumn(
|
||||
(new static)->getTable(),
|
||||
'override_trading_hours'
|
||||
);
|
||||
} catch (\Throwable) {
|
||||
static::$overrideTradingHoursColumnExists = false;
|
||||
}
|
||||
|
||||
return static::$overrideTradingHoursColumnExists;
|
||||
}
|
||||
|
||||
public static function hasPriceOffsetColumn(): bool
|
||||
{
|
||||
if (static::$priceOffsetColumnExists !== null) {
|
||||
@@ -253,6 +275,7 @@ class Product extends Model
|
||||
'open_sell', // Whether selling is open (boolean).
|
||||
'auto_open_at', // Whether selling is open (boolean).
|
||||
'auto_close_at', // Whether selling is open (boolean).
|
||||
'override_trading_hours', // روشن: بازه ساعت خود محصول جایگزین بازه سراسری میشود
|
||||
'kalhor_name', // The name of the Kalhor entity.
|
||||
'default_credit', // Default credit amount.
|
||||
'reading_method', // The method of reading.
|
||||
@@ -286,6 +309,7 @@ class Product extends Model
|
||||
'show_in_assets' => 'boolean',
|
||||
'trade_by_quantity' => 'boolean',
|
||||
'use_last_price_if_zero' => 'boolean',
|
||||
'override_trading_hours' => 'boolean',
|
||||
'for_barayand' => 'boolean', // Cast to boolean.
|
||||
'open_sell' => 'boolean', // Cast to boolean.
|
||||
'auto_sell' => 'boolean', // Cast to boolean (you mentioned this in your casts but it's missing in `$fillable`).
|
||||
|
||||
Reference in New Issue
Block a user