Misc Amount is not Reflecting in Invoice Header and Invoice Detail

That is a known issue that can’t be resolved unless you move the logic to Epicor Functions. Given than you are on 10.2.300 you have another option you can make use of.

You create an Updatable BAQ lets call it CODE-CreateRMA and you create Calculated fields Calculated_Company, Calculated_InvoiceNum (etc) then you create code inside of the Updatable BAQ under BPM section, under Update (just pick Advanced BPM). You don’t have to have any tables.

Then you invoke the UBAQ from your Method Directive. Use the Updatable BAQ basically as a Function. Then the UBAQ BPM invokes the RMA BO.


Example Code how to invoke UBAQ from Method Directive

// You may need to reference Ice.Contracts.BO.DynamicQuery as Reference in your Invoice BPM

// Create the Logged Invoice by calling out to a Updatable BAQ
bool more;
var ds = dq.GetListByID("CODE-zCreateLoggedInvoice", null, 0, 0, out more); 
				
// set the calculated fields in the BAQ                    
ds.Tables["Results"].Rows[0]["Calculated_Company"] = sel.Company;
ds.Tables["Results"].Rows[0]["Calculated_VendorNum"] = sel.VendorNum;
ds.Tables["Results"].Rows[0]["Calculated_InvoiceNum"] = sel.InvoiceNum;
ds.Tables["Results"].Rows[0]["Calculated_InvoiceAmt"] = sel.DocInvoiceVendorAmt;
ds.Tables["Results"].Rows[0]["Calculated_GroupID"] = callContextBpmData.ShortChar01;
ds.Tables["Results"].Rows[0]["Calculated_PONum"] = sel.REFPONum;
// don't forget to  set the RowMod = "U" so that the update works
ds.Tables["Results"].Rows[0]["RowMod"] = "U"; 

// Run the updatable BAQ
ds = dq.UpdateByID("CODE-zCreateLoggedInvoice", ds); 

Then basically in your UBAQ you can read the Calculated Columns and get more data and do whatever you want.

var row = ttResults.FirstOrDefault();

if (row != null)
{          
	bool LogAPInvExists = (from LogAPInv_Row in Db.LogAPInv
		where LogAPInv_Row.Company == row.Calculated_Company
		&& LogAPInv_Row.VendorNum == row.Calculated_VendorNum
		&& LogAPInv_Row.InvoiceNum == row.Calculated_InvoiceNum
		select LogAPInv_Row).Any();
							
	// If no Logged Invoice exists
	if (!LogAPInvExists)
	{
		var LogAPInvSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.LogAPInvSvcContract>(Db);
		LogAPInvTableset ds = new LogAPInvTableset();
		LogAPInvSvc.GetNewLogAPInvInvoice(ref ds, row.Calculated_GroupID);
		string OurMsg = "";
		LogAPInvSvc.ChangeRefPONum(row.Calculated_PONum, true, out OurMsg, ref ds);
		// etc
	}
}
2 Likes