Error in Updating Square Order after creating invoice - square

I am using Square SDK for dotnet and I am creating an order and then creating invoice and then updating the same order. I am using same api key, same customer and same location for all these operations but it is breaking at update call giving following error.
Category: "AUTHENTICATION_ERROR"
Code: "FORBIDDEN"
Detail: "LineItems cannot be modified for orders owned by another application."
Field: "order.line_items"

The error should be better, but essentially once you actually create the invoice, you can't edit the line items that would affect the amount. Per the documentation:
Updating an order. You cannot update order fields (such as line items, taxes, and discounts) that change the order amount. To update these order fields, you must cancel the invoice, which also cancels the order (sets the order status to CANCELED). You then create a new order and a new invoice. You can update order fields that do not change the order amount.

Related

How to pass Note from Sale Order Line to Transfer (Detailed Operation Line)?

In Sale Order Line, there is an option to write down some notes in the lines as "note". When the Sale Order is confirmed, the data is sent to stock.picking (Transfers) and the lines from Sale Order Line appear in Detailed Operations in the Transfers page, but without the note.
Where should I look for in order to customize and/or configure it to achieve such goal?
There is no differanciation of line types for stock.picking lines as for sales order lines. In sales order lines it's made by the field display_type.
Trying to imitate this feature for pickings could end in a mess. Personally i would try to get all notes and either copy them to a new notes one2many field or just in one new note text field on the created picking. Or maybe even "easier" is to compute all notes, because every picking line (stock.move) has a connection to the original sales line (sale_line_id) and so indirectly to the sales order or even directly by field stock.picking.sale_id.

Bigcommerce: edit an existing order shipment address

I imported 10k legacy orders with the wrong state. How do I fix it? When I use the order shipment update endpoint PUT /orders/{order_id}/shipments/{id} I get an error that the shipping_address field is not writable. What do I do?
I'm using the API docs here: https://developer.bigcommerce.com/api-reference/orders/orders-api/order-shipments/putordersorderidshipmentsid
It isn't possible to directly write to the order shipment address state field, but for context, that mirrors the behavior you'd see when working with order shipments in the control panel. The best solution would be to delete the shipments with the incorrect state and re-create the shipments.
Edit:
There are 2 options to re-create the shipment with the correct address: The first is to update the order by adding a new shipping address containing the correct state and use that shipping address when you re-make the shipment. Although existing order shipping addresses can't be edited, the order shipping address array is additive. So you can update the order by adding a new shipping address and use that order_address_id to create the new shipment. The second option would be to delete the entire order with the incorrect shipping address and re-import it with the correct data, then re-create the shipment.
On the orders resource, we are scoping a feature request to make shipping addresses editable. (This would align with what you're able to do when editing an order through the control panel). I'll keep you posted in this thread when there's an update on that, although the best solution in the meantime would be to use one of the options outlined above.

Xrm.Page.ui.getFormType() returns 2 when create order from quote

When i am creating an order from quote, in onload Xrm.Page.ui.getFormType() returns me the value 2.
but the form is in create mode, so should return 1.
When you "win" a quote and a Sales Order is generated, there is no Create state presented by the UI - the system creates the new record in the background and then displays it. When you are presented with the new Sales Order through this process, it already has a record ID so Xrm.Page.ui.getFormType() will return 2, which is the Update state.
The only way to get the Create state (1) from Xrm.Page.ui.getFormType() would be to manually create a Sales Order. However, if you do this you will lose much of the convenience the system does automatically for you, such as copying over all fields with the same name (essentially duplicating the Quote data into the the new Sales Order).

Integrity error where try to save a supplier invoices

I build a module who increase stock on supplier invoices. Work fine on devel server but when I pun on work server I have this error. How can I corret this error?
Integrity Error
The operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it - creation/update: a mandatory field is not correctly set
[object with reference: Purchase Order Line - purchase.order.line]
Integrity Error on OpenERP occur because of two possibility (mentioned on the description of error):
When you create or update a record, a mandatory field is not correctly set or is not filled. What field? One of field in your object (mentioned). In your case: purchase.order.line.
When you delete a record, the record you want to delete is used by another record and set as a mandatory field (required) from the python code.
My guess, if you get the error when you create/update a record (Purchase Order), maybe you create/update the order lines, but one of mandatory field in order lines is empty.

Magento update customer group prices for products

I'm trying to update the customer group prices in Magento using Mage (as I cannot find a way to do so in the SOAP V2 API). I've found a StackOverflow example, however it doesn't work for me. The code I'm using is as follows:
<?php
include_once '../App/Mage.php';
Mage::app();
$productID = $_GET["id"];
$product = Mage::getModel('catalog/product')->load($productID);
$groupPricingData = array(array('price_id'=>1,'website_id'=>0,
'cust_group'=>3, 'price'=>666));
$product->setData('group_price',$groupPricingData);
$product->save();
echo "true";
?>
I get the following error if I use a product that has any customer prices already set. If I try a product with no existing prices, it doesnt error, but the customer group price is not created.
SCREAM: Error suppression ignored for
( ! ) Fatal error: Uncaught exception 'Mage_Eav_Model_Entity_Attribute_Exception' with
message 'SQLSTATE[23000]: Integrity constraint violation: 1062
Duplicate entry '24-0-3-0' for key 'CC12C83765B562314470A24F2BDD0F36'' in
C:\wamp\www\magento\app\code\core\Mage\Core\Model\Config.php on line 1348
( ! ) Mage_Eav_Model_Entity_Attribute_Exception: SQLSTATE[23000]:
Integrity constraint violation: 1062 Duplicate entry '24-0-3-0' for
key 'CC12C83765B562314470A24F2BDD0F36' in
C:\wamp\www\magento\app\code\core\Mage\Core\Model\Config.php on line 1348
I have been scouring the web for an answer to how to properly "update" group price on Magento Product records and have been unsuccessful. Pouring over Magento's source code hasn't gotten me anywhere either. I have however, discovered two solutions on how to clear out the existing group price, so that you do not receive this error.
1 - Direct SQL query to remove the existing group price data
$coreResource = Mage::getSingleton('core/resource');
$conn = $coreResource->getConnection('core_write');
$table_name = $coreResource->getTableName('catalog_product_entity_group_price');
$conn->delete($table_name, array('entity_id = '.$product->getId()));
2- Set the group price for the product to be empty, and save the product.
$product->setData('group_price', array())->save();
Performing either of these (no need to do both) PRIOR to setting your group price data and saving the product, will avoid the Integrity constraint violation, since they effectively remove the existing group price for the product. Approach 1 feels sketchy because we usually do not make direct sql queries and instead rely on model classes to have methods already built in place for us to encapsulate this logic, but in my test environment (Magento 1.9) it works. Approach 2 may seem safer, however it is more resource intensive since it is saving the entire product record, when all we really need to do is update/delete the existing group price. Plus it requires a redundant save since we're "saving to remove" the existing group price.
I recommend re-indexing Product Prices afterwards, as group price data is also stored in 'catalog_product_index_group_price'.
Try to use this extension for magmi group prices:
https://github.com/tim-bezhashvyly/magmi-grouped-price-plugin