feat(tax): send Motamed ASA invoices to the tax sandbox in sandbox mode #41
Loading…
Reference in a new issue
No description provided.
Delete branch "asatsp/arc:feature/motamed-asa-sandbox"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
خلاصه
به درخواست شما، ارسال از طریق «معتمد آسا» در «حالت سندباکس» هم کار میکند. API نسخه ۲ آسا محیط Sandbox جداگانهای ندارد: همان نشانی (
https://api-v2.asatsp.ir)، همان توکن و همان شناسه و رمز کلاینت به کار میرود و هر عضوdata[]در/api/invoice/sendبا فیلدsandBoxمشخص میکند به کدام محیط برود (بخش 05F مستند API نسخه ۲). ساختار تغییری نکرده است: جدول، ستون یا migration تازهای نیست و همان الگوی ارائهدهنده و همانtax_settings.sandbox_modeاستفاده شده است. رفتار «ارسال مستقیم» و فنآوا تغییری نکرده است.رفتار
sandbox_mode، هر عضو/api/invoice/send(صورتحساب اصلی و برگشت از فروش) باsandBox: trueو بدونfiscalIdفرستاده میشود. آسا آن را فقط با شناسه حافظه مالیاتی Sandbox همان کسبوکار (پیشفرض Sandbox یا تنها شناسه فعال آن) میپذیرد و به محیط آزمایشی سازمان امور مالیاتی میفرستد. شناسه حافظهای که هنگام ثبتنام صادر شده عملیاتی است و در درخواست Sandbox پذیرفته نمیشود، برای همین فرستاده نمیشود. در حالت عادی، عضو باsandBox: falseو همان شناسه حافظه قبلی فرستاده میشود.editInvoice،cancelInvoiceوregisterPaymentفیلدsandBoxندارند و صورتحساب در همان محیطی میماند که ثبت شده است (بخش 08D: «حافظهٔ مالیاتی و محیط … همان صورتحساب میماند»).extra_info.asa_sandboxثبت میشود؛ سندهایی که پیش از این تغییر ارسال شدهاند عملیاتیاند. زنجیره Sandbox کد داخلی جداگانه دارد (hesabix-sandbox-{id})، چون آساinternalIdرا برای هر کسبوکار در هر دو محیط یکتا نگه میدارد. روشن یا خاموش کردن حالت سندباکس هیچ صورتحسابی را جابهجا نمیکند:MOTAMED_ASA_ENVIRONMENT_MISMATCHرد میشود (مثلاً ابطال یک صورتحساب واقعی در حالت سندباکس انجام نمیشود).MOTAMED_ASA_REFERENCE_OTHER_ENVIRONMENT).internalIdذخیرهشدهاش استعلام میشود، در هر محیطی که باشد. خواندن جدول پرداخت هم در هر دو حالت ممکن است.MOTAMED_ASA_SANDBOX_UNAVAILABLE(ذخیره تنظیمات، انتخاب روش، ورود دستی کلید و ارسال) برداشته شد. محدودیت فنآوا سر جایش است.motamedAsaSandboxNoteجای کلید بیاستفادهmotamedAsaSandboxUnavailableرا گرفته است (ARB فارسی و انگلیسی و فایلهای تولیدی).راهاندازی برای یک کسبوکار
https://sandboxrc.tax.gov.ir) گرفته و در معتمد آسا برای همان کسبوکار ثبت میشود. اگر چند شناسه Sandbox فعال بدون پیشفرض داشته باشد، یکی پیشفرض میشود.آزمونها
Summary (English)
Sandbox support for the Motamed ASA provider, without architectural change (no table, column or migration).
tax_settings.sandbox_modeon, every/api/invoice/sendmember (original and return) carriessandBox: trueand nofiscalId; ASA accepts it only with the business's Sandbox fiscal memory (its default or only active one) and sends it to the tax organisation's sandbox (API v2 docs, 05F). OtherwisesandBox: falsewith the business's memory id, as before.editInvoice,cancelInvoiceandregisterPaymenttake nosandBox; an invoice stays in the environment it was registered in (08D).extra_info.asa_sandbox; older chains are production) and a sandbox chain has its own internalId (hesabix-sandbox-{id}). Changing the setting never moves an invoice: a correction, cancellation or payment of an invoice from the other environment is refused (MOTAMED_ASA_ENVIRONMENT_MISMATCH) before the document is marked as being sent; an original or return unknown to ASA or refused there restarts in the current environment; a return must refer to a sale of its own environment.MOTAMED_ASA_SANDBOX_UNAVAILABLEguards are removed; Fanava's are kept.tests/test_motamed_asa_sandbox.py.تیم فنی معتمد آسا
🤖 Generated with Claude Code
Hesabix asked for a sandbox. Motamed ASA's API v2 has no separate sandbox host: the same base URL, token and client credentials are used, and each /send member says where it goes with sandBox (API v2 docs, section 05F). No new table, column or migration; Direct and Fanava are unchanged. - With tax_settings.sandbox_mode on, every /api/invoice/send member (original, return) carries sandBox: true and no fiscalId: ASA accepts it only with the business's Sandbox fiscal memory (its default, or the only active one) and sends it to the tax organisation's sandbox. The memory id issued at sign-up is a production one. In production mode the member carries sandBox: false and that memory id, as before. - editInvoice, cancelInvoice and registerPayment take no sandBox: an invoice keeps the environment it was registered in (docs 08D). Each document records its environment in extra_info.asa_sandbox (chains sent before this change are production), and a sandbox chain has its own internalId (hesabix-sandbox-{id}), as ASA keeps internalIds unique per business across both environments. - Changing the setting never moves an invoice. Before the document is marked as being sent, a correction or cancellation of an invoice from the other environment is refused (MOTAMED_ASA_ENVIRONMENT_MISMATCH); an original or return whose chain there is unknown to ASA or was refused starts again in the current environment, one registered or in flight is refused. Payment registration follows the same rule; reading payments and inquiries work in either mode, each chain by its stored internalId. A return must refer to a sale of its own environment (MOTAMED_ASA_REFERENCE_OTHER_ENVIRONMENT). - The MOTAMED_ASA_SANDBOX_UNAVAILABLE guards are removed (settings save, provider selection, manual credentials, sending); Fanava's stay. - Tax settings: Motamed ASA stays selectable in sandbox mode, and a note says where invoices go and that the business's Sandbox fiscal memory must be registered with Motamed ASA. motamedAsaSandboxNote replaces the now unused motamedAsaSandboxUnavailable (ARB and generated files). Tests: tests/test_motamed_asa_sandbox.py Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>مشکلی که وجود داره اینکه تفکیک بین محیط سندباکس و واقعی وجود نداره. برای مثال یک فاکتور به محیط سندباکس ارسال شده و الان میخوایم به محیط واقعی ارسال کنیم. افزونه فکر میکنه که قبلا ارسال شده این صورتحساب. من فکر میکنم باگ باشه
ما اینو مرچ میکنیم ولی باید این مشکل حل بشه