feat(shayegan): per-product item code and auto customer Account/Put

This commit is contained in:
2026-10-28 16:51:47 +03:30
parent 25ee47b473
commit 9528056036
10 changed files with 344 additions and 13 deletions
+20
View File
@@ -33,6 +33,7 @@ class Product extends Model
private static ?bool $karatColumnExists = null;
private static ?bool $tvPriceFormulaColumnsExist = null;
private static ?bool $priceFormulaColumnsExist = null;
private static ?bool $shayeganItemColumnExists = null;
protected static function booted(): void
{
@@ -104,9 +105,27 @@ class Product extends Model
$product->attributes['tv_price_formula']
);
}
if (!static::hasShayeganItemColumn()) {
unset($product->attributes['shayegan_item_number']);
}
});
}
public static function hasShayeganItemColumn(): bool
{
if (static::$shayeganItemColumnExists !== null) {
return static::$shayeganItemColumnExists;
}
try {
static::$shayeganItemColumnExists = Schema::hasColumn((new static)->getTable(), 'shayegan_item_number');
} catch (\Throwable) {
static::$shayeganItemColumnExists = false;
}
return static::$shayeganItemColumnExists;
}
public static function hasTvPriceFormulaColumns(): bool
{
if (static::$tvPriceFormulaColumnsExist !== null) {
@@ -497,6 +516,7 @@ class Product extends Model
'unit', // The unit of the item.
'group_type', // The unit of the item.
'finance_p_name', // کد کار زرین (idKar)
'shayegan_item_number', // ItemNumber در فاکتور شایگان
'file_id', // The ID of the associated file.
'can_canceled', // Whether the record can be canceled (boolean).
'active', // The active status of the record (boolean).