We have a BPM that creates a material transaction on a project job when employee expenses are created. I need to create a BPM that will make the same transaction when a job cost adjustment is made so that it creates a negative transaction when the job cost adjustment is negative. I am using the methods for the JobAdjustmentSvcContract. No matter how I try to put the data into the transaction it is always making the cost and quantity positive. The actual job cost adjustment is negative, but I can’t get the code-created transaction to be negative. I have message statements showing the material cost is negative but when I look at the transaction in job tracker it is always positive. Here is the code with messages and my attempts at forcing it to be negative. Is there a different method or something I am missing to have the transaction be negative?
Erp.Contracts.JobEntrySvcContract vh_JobEntry = null;
vh_JobEntry = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobEntrySvcContract>(Db);
var JobHeadListDS = new Erp.Tablesets.JobHeadListTableset();
vh_JobEntry = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobEntrySvcContract>(Db);
JobHeadListDS = new Erp.Tablesets.JobHeadListTableset();
Erp.Contracts.JobAdjustmentSvcContract vh_JobAdjustment = null;
vh_JobAdjustment = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobAdjustmentSvcContract>(Db);
var JobAdjustmentDS = new Erp.Tablesets.JobAdjustmentTableset();
vh_JobAdjustment = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobAdjustmentSvcContract>(Db);
JobAdjustmentDS = new Erp.Tablesets.JobAdjustmentTableset();
jewhereClause = "JobNum='" + ttPartTran_xRow.JobNum + "'";
jepageSize = 0;
jeabsolutePage = 0;
JobHeadListDS = vh_JobEntry.GetList(jewhereClause,
jepageSize,
jeabsolutePage,
out jemorePages);
var ttJobHeadList_xRow = (from ttJobHeadList_Row in JobHeadListDS.JobHeadList
where string.Equals(ttJobHeadList_Row.Company, Session.CompanyID, StringComparison.OrdinalIgnoreCase)
&& ttJobHeadList_Row.JobNum == vJobNum
select ttJobHeadList_Row).FirstOrDefault();
if (ttJobHeadList_xRow != null)
{
this.PublishInfoMessage("In jobheadlist " ,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"", "");
Ice.IceRow myttJobsRow = JobAdjustmentDS.Jobs.NewRow();
myttJobsRow["Company"] = Session.CompanyID;
myttJobsRow["JobNum"] = ttJobHeadList_xRow.JobNum;
myttJobsRow["SysRowID"] = ttJobHeadList_xRow.SysRowID;
myttJobsRow["RowMod"] = IceRow.ROWSTATE_UPDATED;
JobAdjustmentDS.Jobs.Add(myttJobsRow);
vh_JobAdjustment.StartAdjustments(ref JobAdjustmentDS);
var ttJATrans_xRow = (from ttJATrans_Row in JobAdjustmentDS.JATrans
where string.Equals(ttJATrans_Row.Company, Session.CompanyID, StringComparison.OrdinalIgnoreCase)
&& ttJATrans_Row.JobNum == vJobNum
select ttJATrans_Row).FirstOrDefault();
if (ttJATrans_xRow != null)
{
this.PublishInfoMessage("jatrans found " + ttJATrans_xRow.JobNum.ToString(),Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"", "");
ttJATrans_xRow.TranDate = ttPartTran_xRow.TranDate;
ttJATrans_xRow.RowMod = IceRow.ROWSTATE_UPDATED;
} //if (ttJATrans_xRow != null)
vh_JobAdjustment.ChangeMtlAssemSeq(vAssemblySeq,
ref JobAdjustmentDS);
vh_JobAdjustment.ChangeMtlJobMtl(vMtlSeq,
ref JobAdjustmentDS);
ttJATrans_xRow = (from ttJATrans_Row in JobAdjustmentDS.JATrans
where string.Equals(ttJATrans_Row.Company, Session.CompanyID, StringComparison.OrdinalIgnoreCase)
&& ttJATrans_Row.JobNum == vJobNum
&& string.Equals(ttJATrans_Row.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase)
select ttJATrans_Row).FirstOrDefault();
if (ttJATrans_xRow != null)
{
ttJATrans_xRow.TranQty = 1;
//if (ttJATrans_xRow != null)
vh_JobAdjustment.ChangeMtlTranQty(1, ref JobAdjustmentDS);
ttJATrans_xRow.MtlBurUnitCost = Math.Round(ttPartTran_xRow.ExtCost * costPctg, 2);
if (ttJATrans_xRow.MtlBurUnitCost > 0)
{
//make sure it is negative for the adjustment
ttJATrans_xRow.MtlBurUnitCost = ttJATrans_xRow.MtlBurUnitCost * -1;
}
//set the extended cost to the same value to force i
this.PublishInfoMessage("values " + ttPartTran_xRow.ExtCost + " " + ttJATrans_xRow.MtlBurUnitCost,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"", "");
}
vh_JobAdjustment.CalcUnitCost( ref JobAdjustmentDS);
// vh_JobAdjustment.ChangeMtlExtCost(Math.Round(ttPartTran_xRow.ODCUnitCost * costPctg, 2), ref JobAdjustmentDS);
vh_JobAdjustment.PreCommitMaterialAdj(ref JobAdjustmentDS,
out requiresUserInput);
vh_JobAdjustment.CommitMaterialAdj(ref JobAdjustmentDS,
out legalNumberMessage);