Changing the sales order freight GL account
Currently when a sales order is processed the freight values from the freight grid get posted to the Debtor Freight GL account from the debtor.
I want to change the freight account based on the physical warehouse, kind of like pseudo warehouse masking.
I am using the SetupBeforeHandlers so I can intercept the debtor accounts before the sales order gets processed.
Then I use the debtor entity to try to change the freight code which isn't working. It just uses the configured debtor freight GL account
I thought there may be something wrong with the entity, so I used the full debtor object but that still didn't work.
Can you help me with some valid code to change the debtor frieight GL account? This is for version 7.0.175, but happy to use 7.2 code & tweak it accordingly.
I want to change the freight account based on the physical warehouse, kind of like pseudo warehouse masking.
I am using the SetupBeforeHandlers so I can intercept the debtor accounts before the sales order gets processed.
- Code: Select all
public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm soForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm) JiwaForm;
soForm.SalesOrder.ProcessingStart += ChangeDebtorFreight;
}
Then I use the debtor entity to try to change the freight code which isn't working. It just uses the configured debtor freight GL account
- Code: Select all
public void ChangeDebtorFreight(object sender, System.EventArgs e)
{
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)sender;
switch (salesOrder.LogicalWarehouseResidingIn.PhysicalWarehouse.Description.Trim())
{
case "Adelaide":
salesOrder.Debtor.LedgerDebtorFreight.ReadRecordFromAccountNo("146000-04-00");
break;
case "Brisbane":
salesOrder.Debtor.LedgerDebtorFreight.ReadRecordFromAccountNo("146000-03-00");
break;
case "Sydney":
salesOrder.Debtor.LedgerDebtorFreight.ReadRecordFromAccountNo("146000-02-00");
break;
}
}
I thought there may be something wrong with the entity, so I used the full debtor object but that still didn't work.
- Code: Select all
public void ChangeDebtorFreight(object sender, System.EventArgs e)
{
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)sender;
JiwaFinancials.Jiwa.JiwaDebtors.Debtor debtor = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaDebtors.Debtor>(null);
debtor.Read(salesOrder.Debtor.DebtorID);
foreach (JiwaFinancials.Jiwa.JiwaDebtors.DebtorLedger debtorledger in debtor.DebtorLedgers)
{
if (debtorledger.LedgerName == "Debtor Freight")
{
switch (salesOrder.LogicalWarehouseResidingIn.PhysicalWarehouse.Description.Trim())
{
case "Adelaide":
debtorledger.Ledger.ReadRecordFromAccountNo("146000-04-00");
break;
case "Brisbane":
debtorledger.Ledger.ReadRecordFromAccountNo("146000-03-00");
break;
case "Sydney":
debtorledger.Ledger.ReadRecordFromAccountNo("146000-02-00");
break;
}
}
}
Can you help me with some valid code to change the debtor frieight GL account? This is for version 7.0.175, but happy to use 7.2 code & tweak it accordingly.