Mark an order as "Full Payment" on Sage 200

168 views Asked by At

I am inserting orders on Sage 200 through an application using the client side, C# and APIs.

I would like to check the "Full payment" checkbox on the "Payment with order" tab.

enter image description here

Currently, I am setting the PaymentType property, which is not working.

order.PaymentType = Sage.Accounting.SOP.SOPOrderPaymentTypeEnum.EnumSOPOrderPaymentTypeFull;

order is an instance of Sage.Accounting.SOP.SOPOrder.

Do you know how I can check that property?

2

There are 2 answers

0
DotNetHitMan On

The following method should supply the required results.

    private static void SetPaymentWithOrder(Sage.Accounting.SOP.SOPOrder sopOrder)
    {
        // Indicate that order has payment
        sopOrder.PaymentWithOrder = true;

        // This is full payment order
        sopOrder.PaymentType = Sage.Accounting.SOP.SOPOrderPaymentTypeEnum.EnumSOPOrderPaymentTypeFull;

        // Fetch the the Payment Methods. SOPPaymentMethods contructor accepts the boolean flag whether to fetch payment methods including card processing method or not.
        Sage.Accounting.SOP.SOPPaymentMethods paymentMethodsCollection = new Sage.Accounting.SOP.SOPPaymentMethods(false);

        // Set the first payment method of the collection to the order
        sopOrder.PaymentMethod = paymentMethodsCollection.First;
    }

enter image description here

0
Cairns On

dont know if you ever managed to figure this one out or not.

Not sure if you knew this, but you cannot modify the Sales Order on the view form, or at least shouldn't be trying to do so.

Using either of the Enter/Amend Sales Order forms will allow you to do so. What is potentially happening, is that the properties that the controls are bound to are not updating the UI after your code has run.

You can simply force this to happen using the following

Fetching the underlying bound object

public Sage.Accounting.SOP.SOPOrderReturn SOPOrderReturn
{
    get
    {
        //Loop over the boundobjects collection
        //check if the bound object is of the type we want - e.g. SOPOrderReturn
        //if correct type, return this object
        Sage.Common.Collections.BoundObjectCollection boundObjects = this.form.BoundObjects;

        if (boundObjects != null)
        {
            foreach (object boundObject in boundObjects)
            {
                if (boundObject is Sage.Accounting.SOP.SOPOrderReturn)
                {
                    this._sopOrderReturn = boundObject as Sage.Accounting.SOP.SOPOrderReturn;
                    break;
                }
            }
        }
        return this._sopOrderReturn;
    }
}

Fetch the correct underlying form type that the amendable form is, suspending the databinding, perform your changes, resuming the databinding

Sage.MMS.SOP.MaintainOrderForm maintainOrderForm = this.form.UnderlyingControl as Sage.MMS.SOP.MaintainOrderForm;

maintainOrderForm.BindingContext[this.SOPOrderReturn].SuspendBinding();
this.SOPOrderReturn.PaymentWithOrder = true;
this.SOPOrderReturn.PaymentType = Sage.Accounting.SOP.SOPOrderPaymentTypeEnum.EnumSOPOrderPaymentTypeFull;
maintainOrderForm.BindingContext[this.SOPOrderReturn].ResumeBinding();

should do the trick.