Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: transition_not_allowed #3

Open
maher640 opened this issue Aug 6, 2024 · 1 comment
Open

Issue: transition_not_allowed #3

maher640 opened this issue Aug 6, 2024 · 1 comment

Comments

@maher640
Copy link

maher640 commented Aug 6, 2024

https://github.com/tamara-solution/salesforce/blob/232ede527bbf3e715595d54cd0d3fa353f0dadff/cartridges/int_tamara_core/cartridge/scripts/services/tamaraServiceCapture.js#L33

For some unknown reasons the fully capture status is not saved into the order, which make the call to tamaraServiceCapture that comes eaither from the BM or CaptureShippedOrder to fail. The returned error is:

{
    "message": "The order ... cannot be moved to the status fully_captured from fully_captured",
    "errors": [{
        "error_code": "transition_not_allowed",
        "data": {
            "order_id": "...",
            "old_state": "fully_captured",
            "new_state": "fully_captured"
        }
    }],
    "data": {
        "capture_ids": ["...."]
    },
    "title": null,
    "screen_type": null
}

A quick fix to this would be:
When this error occurs, simply call tamaraServiceOrderDetail.

@maher640
Copy link
Author

maher640 commented Aug 6, 2024

A possible fix would be something like this:

if (!callResult.isOk()) {
    try {
        var parsedError = JSON.parse(callResult.getErrorMessage());
        if (parsedError.errors[0].error_code === 'transition_not_allowed') {
            const tamaraServiceOrderDetails = require('*/cartridge/scripts/services/tamaraServiceOrderDetail');
            tamaraServiceOrderDetails.initService(order, true);
            return;
        } else {
            throw new Error(
                'Order No: ' + order.getOrderNo() + '. Call error code ' + callResult.getError().toString() + ' | Error => ResponseStatus: ' + callResult.getStatus() + ' | ResponseErrorText:  ' + callResult.getErrorMessage() + ' | ResponseText: ' + callResult.getMsg()
            );
        }
    } catch (err) {
        throw new Error(
            'Order No: ' + order.getOrderNo() + '. Call error code ' + callResult.getError().toString() + ' | Error => ResponseStatus: ' + callResult.getStatus() + ' | ResponseErrorText:  ' + callResult.getErrorMessage() + ' | ResponseText: ' + callResult.getMsg()
        );
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant