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
@@ -979,6 +979,13 @@ class ProductController extends SuperController
unset($data['cash_fee_buy_is_percent'], $data['cash_fee_sell_is_percent']);
}
if (! Product::hasShayeganItemColumn()) {
unset($data['shayegan_item_number']);
} elseif (array_key_exists('shayegan_item_number', $data)) {
$item = trim((string) $data['shayegan_item_number']);
$data['shayegan_item_number'] = $item === '' ? null : $item;
}
return $data;
}
@@ -62,6 +62,18 @@ class ShayeganController extends Controller
return $this->sync->recordWalletGold($data);
}
public function registerCustomer($customerId)
{
if (! app(\App\Services\ConfigService::class)->isShayeganAccounting()) {
return response()->json(['ok' => false, 'message' => 'حسابداری شایگان فعال نیست'], 422);
}
$customer = \App\Models\Customer::findOrFail($customerId);
$result = $this->sync->registerCustomer($customer);
return response()->json($result, ($result['ok'] ?? false) ? 200 : 422);
}
public function table(Request $request)
{
if (! Schema::hasTable('shayegan')) {
@@ -421,6 +421,9 @@ class CartController extends Controller
'amount' => $product->amount,
'unit' => $product->unit,
'trade_by_quantity' => $product->trade_by_quantity,
'shayegan_item_number' => Product::hasShayeganItemColumn()
? ($product->shayegan_item_number ?? null)
: null,
],
'line' => $lineIndex + 1,
'order' => [