Hello Community,
Could you help me with code that allows me to create a discount code and then apply it to a sales order?
I am creating the discount code, and it is being created correctly — all the data is saved properly in both the header and the details. However, when I try to apply it to a sales order, the discount code is not applied: the sequence ID is not generated automatically, and when I set the sequence ID manually, the type is not set. By contrast, if I create the same discount manually and apply it to a sales order, all the fields are saved correctly.

