Page 1 of 1

Parent debtor on hold

PostPosted: Wed May 11, 2016 2:38 pm
by Atronics
Putting a parent debtor on hold causes child accounts to also be on hold. This is fine. However, taking the parent off "On Hold" does not also reset the child accounts. Is there a plugin to manage this?

Re: Parent debtor on hold

PostPosted: Mon May 23, 2016 8:26 pm
by Mike.Sheen
Atronics wrote:Putting a parent debtor on hold causes child accounts to also be on hold. This is fine. However, taking the parent off "On Hold" does not also reset the child accounts. Is there a plugin to manage this?


No, we don't have a plugin already which does this.

It should be fairly easy to write one, though. I estimate an hour of development time to write the plugin.

Re: Parent debtor on hold  Topic is solved

PostPosted: Fri May 27, 2016 8:16 pm
by Mike.Sheen
This worked for me in demo data:

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   JiwaFinancials.Jiwa.JiwaDebtors.Debtor debtor = (JiwaFinancials.Jiwa.JiwaDebtors.Debtor)JiwaBusinessLogic;
   debtor.SaveEnd += Debtor_SaveEnd;
}

private void Debtor_SaveEnd(object sender, System.EventArgs e)
{
   JiwaFinancials.Jiwa.JiwaDebtors.Debtor debtor = (JiwaFinancials.Jiwa.JiwaDebtors.Debtor)sender;
   
   if (debtor.BranchDebtors.Count > 0 && debtor.AccountOnHold == false)
   {
      // update all branch debtors
      foreach (JiwaFinancials.Jiwa.JiwaDebtors.BranchDebtor branchDebtor in debtor.BranchDebtors)
      {
         JiwaFinancials.Jiwa.JiwaDebtors.Debtor child = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaDebtors.Debtor>(null);
         child.Read(branchDebtor.RecID);
         child.AccountOnHold = false;
         child.Save();
      }
   }
}


Working plugin attached.