An end-user message can be: «We can’t save the invoice right now.» (when invoicing in the backend) or «Cannot place order.» (when the payment action is authorize_capture
in the frontend’s checkout).
An SQL expression:
INSERT INTO `sales_invoice_grid` (
`entity_id`, `increment_id`, `state`, `store_id`, `store_name`, `order_id`
, `order_increment_id`, `order_created_at`, `customer_name`, `customer_email`
`customer_group_id`, `payment_method`, `store_currency_code`, `order_currency_code`
, `base_currency_code`, `global_currency_code`, `billing_name`, `billing_address`
, `shipping_address`, `shipping_information`, `subtotal`, `shipping_and_handling`
, `base_grand_total`, `grand_total`, `created_at`, `updated_at`
) SELECT sales_invoice.entity_id AS `entity_id`, sales_invoice.increment_id AS `increment_id`, sales_invoice.state AS `state`, sales_invoice.store_id AS `store_id`, sales_order.store_name AS `store_name`, sales_invoice.order_id AS `order_id`, sales_order.increment_id AS `order_increment_id`, sales_order.created_at AS `order_created_at`, TRIM(CONCAT_WS(' ', IF(`sales_order`.`customer_firstname` <> '', `sales_order`.`customer_firstname`, NULL), IF(`sales_order`.`customer_lastname` <> '', `sales_order`.`customer_lastname`, NULL))) AS `customer_name`, sales_order.customer_email AS `customer_email`, sales_order.customer_group_id AS `customer_group_id`, sales_order_payment.method AS `payment_method`, sales_invoice.store_currency_code AS `store_currency_code`, sales_invoice.order_currency_code AS `order_currency_code`, sales_invoice.base_currency_code AS `base_currency_code`, sales_invoice.global_currency_code AS `global_currency_code`, TRIM(CONCAT_WS(' ', IF(`sales_billing_address`.`firstname` <> '', `sales_billing_address`.`firstname`, NULL), IF(`sales_billing_address`.`lastname` <> '', `sales_billing_address`.`lastname`, NULL))) AS `billing_name`, TRIM(CONCAT_WS(' ', IF(`sales_billing_address`.`street` <> '', `sales_billing_address`.`street`, NULL), IF(`sales_billing_address`.`city` <> '', `sales_billing_address`.`city`, NULL), IF(`sales_billing_address`.`region` <> '', `sales_billing_address`.`region`, NULL), IF(`sales_billing_address`.`postcode` <> '', `sales_billing_address`.`postcode`, NULL))) AS `billing_address`, TRIM(CONCAT_WS(' ', IF(`sales_shipping_address`.`street` <> '', `sales_shipping_address`.`street`, NULL), IF(`sales_shipping_address`.`city` <> '', `sales_shipping_address`.`city`, NULL), IF(`sales_shipping_address`.`region` <> '', `sales_shipping_address`.`region`, NULL), IF(`sales_shipping_address`.`postcode` <> '', `sales_shipping_address`.`postcode`, NULL))) AS `shipping_address`, sales_order.shipping_description AS `shipping_information`, sales_order.base_subtotal AS `subtotal`, sales_order.base_shipping_amount AS `shipping_and_handling`, sales_invoice.base_grand_total AS `base_grand_total`, sales_invoice.grand_total AS `grand_total`, sales_invoice.created_at AS `created_at`, sales_invoice.updated_at AS `updated_at` FROM `sales_invoice`
LEFT JOIN `sales_order` ON sales_invoice.order_id = sales_order.entity_id
LEFT JOIN `sales_order_address` AS `sales_shipping_address` ON sales_invoice.shipping_address_id = sales_shipping_address.entity_id
LEFT JOIN `sales_order_address` AS `sales_billing_address` ON sales_invoice.billing_address_id = sales_billing_address.entity_id
LEFT JOIN `sales_order_payment` ON sales_invoice.order_id = sales_order_payment.parent_id WHERE (sales_invoice.entity_id = '5') ON DUPLICATE KEY UPDATE `entity_id` = VALUES(`entity_id`), `increment_id` = VALUES(`increment_id`), `state` = VALUES(`state`), `store_id` = VALUES(`store_id`), `store_name` = VALUES(`store_name`), `order_id` = VALUES(`order_id`), `order_increment_id` = VALUES(`order_increment_id`), `order_created_at` = VALUES(`order_created_at`), `customer_name` = VALUES(`customer_name`), `customer_email` = VALUES(`customer_email`), `customer_group_id` = VALUES(`customer_group_id`), `payment_method` = VALUES(`payment_method`), `store_currency_code` = VALUES(`store_currency_code`), `order_currency_code` = VALUES(`order_currency_code`), `base_currency_code` = VALUES(`base_currency_code`), `global_currency_code` = VALUES(`global_currency_code`), `billing_name` = VALUES(`billing_name`), `billing_address` = VALUES(`billing_address`), `shipping_address` = VALUES(`shipping_address`), `shipping_information` = VALUES(`shipping_information`), `subtotal` = VALUES(`subtotal`), `shipping_and_handling` = VALUES(`shipping_and_handling`), `base_grand_total` = VALUES(`base_grand_total`), `grand_total` = VALUES(`grand_total`), `created_at` = VALUES(`created_at`), `updated_at` = VALUES(`updated_at`)