From 9ec71efcbb126b9ee77837255e5f1189dbb80adf Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Wed, 4 Nov 2026 11:56:53 +0330 Subject: [PATCH] change accounting-number --- .../abshode-domain-lookup/learned-notes.md | 1 + app/Services/ShayeganSyncService.php | 16 +++++++-- ..._04_000001_shayegan_tafsil_code_format.php | 33 +++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2026_11_04_000001_shayegan_tafsil_code_format.php diff --git a/.cursor/skills/abshode-domain-lookup/learned-notes.md b/.cursor/skills/abshode-domain-lookup/learned-notes.md index 739d8f3..36a2d8c 100644 --- a/.cursor/skills/abshode-domain-lookup/learned-notes.md +++ b/.cursor/skills/abshode-domain-lookup/learned-notes.md @@ -3,6 +3,7 @@ فرمت هر خط: - YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی +- 2026-11-04 | فرمت کد تفصیلی شایگان | `ShayeganSyncService::customerTafsilNumber` | کل `shayegan_kol_customer` (121) + کد کاربر ۷رقمی: مشتری 1 → `1210000001`. کد ذخیره‌شدهٔ قبلی عوض نمی‌شود - 2026-11-02 | جدول اسناد شایگان | `shayeganTable.vue` + `ShayeganController::table` | BaseTable؛ پاسخ بدون `query` را خود فرانت به `{rows,query}` برمی‌گرداند. ستون عملیات `ops` است تا در RTL هشدار fixed ندهد - 2026-11-02 | ویرایش کد حسابداری شایگان | `CustomerAccountingCodeModal.vue` | provider شایگان هم `moshtari_code` ذخیره می‌کند؛ قبلاً فقط پرگار/ته‌حساب/زرین قبول می‌شد و پیام «حسابداری فعال نیست» می‌آمد - 2026-11-02 | مشتری تفصیلی شناور | `ShayeganSyncService::registerCustomer` → `Job/Put` | معین 12101 حساب جدا نمی‌سازد؛ `JobNumber` = معین+کد (`12101530`). گروه: setting `shayegan_job_group` diff --git a/app/Services/ShayeganSyncService.php b/app/Services/ShayeganSyncService.php index be5e02b..b735005 100644 --- a/app/Services/ShayeganSyncService.php +++ b/app/Services/ShayeganSyncService.php @@ -114,14 +114,13 @@ class ShayeganSyncService return ['ok' => false, 'message' => 'شماره معین مشتریان (shayegan_moin_customer) در تنظیمات خالی است']; } - $moinRaw = trim($this->config->getString('shayegan_moin_customer', '')); $name = trim((string) ($customer->name ?? '')); if ($name === '') { $name = 'مشتری ' . $customer->id; } - // مشتری تفصیلی شناور است (Job/Put)، نه حساب زیر معین. شماره = معین + کد کاربری. - $requestedAccountNumber = $moinRaw . ((string) (int) $customer->id); + // تفصیلی شناور: کل ثابت + کد کاربری ۷رقمی. مشتری ۱ → 1210000001 + $requestedAccountNumber = $this->customerTafsilNumber((int) $customer->id); $guid = (string) Str::uuid(); $put = [[ @@ -653,6 +652,17 @@ class ShayeganSyncService return trim((string) ($customer->moshtari_code ?? '')); } + /** کد کل (پیش‌فرض 121) + کد کاربری با صفر تا ۷ رقم. */ + private function customerTafsilNumber(int $customerId): string + { + $kol = trim($this->config->getString('shayegan_kol_customer', '121')); + if ($kol === '') { + $kol = '121'; + } + + return $kol . str_pad((string) $customerId, 7, '0', STR_PAD_LEFT); + } + private function scaleAmount(float $amount): float { $scale = (float) $this->config->getString('shayegan_amount_scale', '1'); diff --git a/database/migrations/2026_11_04_000001_shayegan_tafsil_code_format.php b/database/migrations/2026_11_04_000001_shayegan_tafsil_code_format.php new file mode 100644 index 0000000..665d356 --- /dev/null +++ b/database/migrations/2026_11_04_000001_shayegan_tafsil_code_format.php @@ -0,0 +1,33 @@ +where('key', 'shayegan_kol_customer')->update([ + 'description' => 'ابتدای ثابت کد تفصیلی. کد = این مقدار + کد کاربری ۷رقمی با صفر. مثال: 121 و مشتری 1 → 1210000001.', + 'updated_at' => now(), + ]); + + DB::table('settings')->where('key', 'shayegan_moin_customer')->update([ + 'description' => 'معین مشتریان. به شماره تفصیلی چسبانده نمی‌شود؛ شماره = کد کل + کد کاربری ۷رقمی.', + 'updated_at' => now(), + ]); + } + + public function down(): void + { + } +};