Monday, 29 May 2017

Link Between GL And AP/AR

Hi There,

In case you have not seen that before, Acumatica has links between GL Batch lines and AP/AR Invoices lines - Following conditions should be applied:

  • GLTrain,TranType = ARTran.TranType;
  • GLTrain,RefNbr = ARTran.RefNbr;
  • GLTrain,LineNbr= ARTran.TranLineNbr;
TranLineNbr is populated on release of a document in another module with the number of the corresponding line in that document.

Please note that TranLineNbr can be empty in some cases. For example if you have consolidation posting to GL, than multiple AP/AR trans will be combined in one GL line, in that case TranLineNbr cannot be evaluated. Specially this field is not populated when PX.Objects.GL.GLTran.SummPost is ON.

Using that knowledge you can update something in GL from AP/AR transactions. For Example:

protected void GLTran_TranLineNbr_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
       GLTran row = (GLTran)e.Row;

       if (row != null
&& row.RefNbr != null && row.TranType != null && row.TranLineNbr != null)
       {
              ARTran tran = PXSelect<ARTran,
                      Where<ARTran.tranType, Equal<Required<ARTran.tranType>>,
                             And<ARTran.refNbr, Equal<Required<ARTran.refNbr>>,
                             And<ARTran.lineNbr, Equal<Required<ARTran.lineNbr>>>>>>.
Select(Base, row.TranType, row.RefNbr, row.TranLineNbr);
              if (tran != null && tran.Date != null)
              {
                      row.TranDate = tran.Date;
              }
       }
}

Have a nice Customization.

No comments: