When a user manually enters a sales order, the method SalesTable.initFromCustTable runs and sets field defaults based on the customer defaults. Why is this method not invoked when processing an AIF salesorder insert????
Also, why are sales order default field values not taken from the address when a different address is selected. Attached is example code I had to add to get some of those fields to apply. (code snippet was added to salestable.initFromCustTableMandatoryFields())
// TCC_ISSUE177_BlindShipment - mjf - 4/22/2013
// added this code to grab defaults from the address
shipCarrierAddress = ShipCarrierAddress::findByCustomerLocation(custTable.AccountNum, location.RecId);
if (shipCarrierAddress)
{
this.ShipCarrierBlindShipment = shipCarrierAddress.ShipCarrierBlindShipment;
this.ShipCarrierResidential = shipCarrierAddress.ShipCarrierResidentialDest;
if (shipCarrierAddress.DlvModeId != '')
{
this.DlvMode = shipCarrierAddress.DlvModeId;
}
if (shipCarrierAddress.DlvTermId != '')
{
this.DlvTerm = shipCarrierAddress.DlvTermId;
}
if (shipCarrierAddress.ShipCarrierAccount != '')
{
this.ShipCarrierAccount = shipCarrierAddress.ShipCarrierAccount;
}
if (shipCarrierAddress.ShipCarrierAccountCode != '')
{
this.ShipCarrierAccountCode = shipCarrierAddress.ShipCarrierAccountCode;
}
if (shipCarrierAddress.ShipCarrierId != '')
{
this.ShipCarrierId = shipCarrierAddress.ShipCarrierId;
}
}
I also had to add the following code to get taxation right because a different address was selected on a sales order. (code is from salestable.initFromCustTableIL).
// code taken from here and moved below TCC_ISSUE177_BlindShipment mjf 4/22/2013
salesTable.DlvTerm = custTable.DlvTerm;
salesTable.DlvMode = custTable.DlvMode;
salesTable.DlvReason = custTable.DlvReason;
dlvMode = DlvMode::find(custTable.DlvMode);
if (salesTable.DlvMode)
{
salesTable.ShipCarrierId = dlvMode.ShipCarrierId;
salesTable.ShipCarrierAccountCode = dlvMode.ShipCarrierAccountCode;
salesTable.ShipCarrierDlvType = dlvMode.ShipCarrierDlvType;
}
// TCC_ISSUE177_BlindShipment start
// MJF - 4/22/2013
// moved from area listed above.
salesTable.initFromCustTableMandatoryFields();
//used sales table dlv term and tax group if available instead of cust table as it may have come fromthe address
if (salesTable.TaxGroup)
{
salesTable.setTaxGroup(TaxSales::custTaxGroup(salesTable.DlvTerm, salesTable.TaxGroup, salesTable.deliveryLocation()));
}
else
{
salesTable.setTaxGroup(TaxSales::custTaxGroup(custTable.DlvTerm, custTable.TaxGroup, salesTable.deliveryLocation()));
}
// TCC_ISSUE177_BlindShipment end
Unless I'm missing something, these merit hotfixes