I am trying to get the unpaid balance to automatically be entered by default when adding a new package on the Shipments screen. We need to do this only for records where Payment type is COD. How do I reference SOOrder when modifying the value in SOPackageDetailEx?
I have the following code:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Runtime.Serialization;
using System.Text;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Data.WorkflowAPI;
using PX.Common;
using PX.Objects.AR;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.SM;
using PX.Objects.IN.Overrides.INDocumentRelease;
using POLineType = PX.Objects.PO.POLineType;
using POReceiptLine = PX.Objects.PO.POReceiptLine;
using PX.CarrierService;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.SO.Services;
using PX.Objects.PO;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Common.Collection;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Api;
using LocationStatus = PX.Objects.IN.Overrides.INDocumentRelease.LocationStatus;
using ShipmentActions = PX.Objects.SO.SOShipmentEntryActionsAttribute;
using PX.Objects;
using PX.Objects.SO;
namespace PX.Objects.SO
{
public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
{
#region Event Handlers
protected void SOPackageDetailEx_COD_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e, PXFieldDefaulting InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOPackageDetailEx)e.Row;
if (row == null) return;
e.NewValue = Convert.ToDecimal(20.0); // This is a test value to be replaced by
} // SOOrder.CuryUnpaidBalance for COD payments
#endregion
}
}
Basically we just need the bit where I am inserting 20.0 to be changed to insert the value held in SOOrder.UnpaidBalance instead if SOOrder.PaymentMethodID = ‘COD’. I’m not sure how to reference SOOrder from here. I have been going through the Acumatica training regarding customizations but this is still beyond me.
Thanks for any help,
Phil