added some feature for accounting and price

This commit is contained in:
2026-06-28 15:16:39 +03:30
parent 9f92466ada
commit 3801e5ee88
11 changed files with 423 additions and 39 deletions
+24
View File
@@ -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`).