{"record":{"id":"647ad454ad4e130e","repo":"aureuserp/aureuserp","slug":"accounts-account-manager-post-action-validate-cur","errorCode":null,"errorMessage":"accounts::account-manager.post-action-validate.currency-archived","messagePattern":"accounts::account-manager\\.post-action-validate\\.currency-archived","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"plugins/webkul/accounts/src/Services/MoveWorkflow.php","lineNumber":283,"sourceCode":"\n        if (in_array($move->state, [MoveState::POSTED, MoveState::CANCEL])) {\n            throw new Exception(__('accounts::account-manager.post-action-validate.draft-state-required'));\n        }\n\n        if ($move->lines->isEmpty()) {\n            throw new Exception(__('accounts::account-manager.post-action-validate.lines-required'));\n        }\n\n        if ($move->lines->some(fn (MoveLine $line) => $line->account && $line->account->deprecated)) {\n            throw new Exception(__('accounts::account-manager.post-action-validate.account-deprecated'));\n        }\n\n        if (! $move->journal) {\n            throw new Exception(__('accounts::account-manager.post-action-validate.journal-archived'));\n        }\n\n        if (! $move->currency) {\n            throw new Exception(__('accounts::account-manager.post-action-validate.currency-archived'));\n        }\n    }\n\n    protected function assertNotExchangeDifference(AccountMove $move): void\n    {\n        $partialIds = PartialReconcile::where('exchange_move_id', $move->id)->pluck('id')->unique();\n\n        $fullIds = FullReconcile::where('exchange_move_id', $move->id)->pluck('id')->unique();\n\n        if ($partialIds->merge($fullIds)->isNotEmpty()) {\n            throw new Exception('You cannot reset to draft an exchange difference journal entry.');\n        }\n    }\n\n    protected function stampLineStates(AccountMove $move, MoveState $state): void\n    {\n        foreach ($move->lines as $line) {\n            $line->update(['parent_state' => $state]);","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/aureuserp/aureuserp/blob/bd7cbeeb0c620985dfd9b88c56be7f3ea86be6b4/plugins/webkul/accounts/src/Services/MoveWorkflow.php#L265-L301","documentation":"Companion check to the journal guard in MoveWorkflow's post-action validation: it throws when `$move->currency` is null. Debits, credits, and exchange-rate handling all depend on a live currency record, so a move whose currency_id references an archived, deactivated, or missing currency cannot be posted.","triggerScenarios":"Posting or validating an AccountMove whose currency_id references a deactivated or deleted currency; moves created before the currency was disabled; imports that stored a currency reference with no matching currencies row.","commonSituations":"A foreign currency is disabled while invoices in that currency are still in draft; multi-currency ledgers consolidated and currency records archived; seeded data referencing currency IDs that were later wiped.","solutions":["Re-enable the archived currency so $move->currency resolves","Reassign the move to an active currency: $move->update(['currency_id' => $activeCurrency->id]) and re-check amounts","Fix imported currency_id values so each matches an existing currencies record","Guard before posting: if (! $move->currency) surface a validation error to the user instead of posting"],"exampleFix":"// before\napp(MoveWorkflow::class)->post($move); // throws currency-archived when currency is null\n\n// after\n$move->loadMissing('currency');\nif (! $move->currency) {\n    $move->update(['currency_id' => $companyCurrency->id]);\n}\napp(MoveWorkflow::class)->post($move);","handlingStrategy":"validation","validationCode":"$move->loadMissing('currency');\nif (! $move->currency) {\n    throw new RuntimeException(\"Move {$move->id} has no live currency; set currency_id before posting.\");\n}\napp(MoveWorkflow::class)->post($move);","typeGuard":"function hasLiveCurrency(AccountMove $move): bool\n{\n    $move->loadMissing('currency');\n\n    return $move->currency !== null;\n}","tryCatchPattern":null,"preventionTips":["Warn before deactivating a currency that open moves still use","Default currency_id on move creation from the company currency when omitted","Validate currency references during data import"],"tags":["accounting","currency","laravel","eloquent","multi-currency"],"backgroundTag":"required-relation-null","analyzedSha":"bd7cbeeb0c620985dfd9b88c56be7f3ea86be6b4","analyzedAt":"2026-08-21T06:41:00.338Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}