无法从自定义图保存APTran记录

时间:2019-05-22 13:25:48

标签: acumatica

我有一个自定义页面,其中包含一个名为 POReceiptTieOut

的自定义图形。

数据源:

public PXSelect<POReceipt> Document;

表单数据成员:文档

网格数据成员:事务:

public PXSelectJoin<
        APTran,
                LeftJoin<POReceiptLine,
                          On<POReceiptLine.receiptNbr, Equal<APTran.receiptNbr>,
                          And<POReceiptLine.lineNbr, Equal<APTran.receiptLineNbr>>>>,
        Where<APTran.receiptNbr, Equal<Current<POReceipt.receiptNbr>>>> Transactions;

我希望能够更新此网格中的交易记录。当我按下标准的“保存”按钮时,出现此错误错误:“ TranDate”不能为空。我的Transactions DAC中所有记录上的APTran.TranDate存在,但是由于某种原因,保存操作无法识别它。

这是POReceiptTieOut图的代码

namespace APPOReceiptTieOut
{
public class POReceiptTieOut : PXGraph<POReceiptTieOut, POReceipt>
{

IPOReceiptRepository _receiptRepository {get;set;}

public POReceiptTieOut()
{
  _receiptRepository = new POReceiptRepository();
}


public PXSelect<POReceipt> Document;

[PXViewName(PX.Objects.AP.Messages.APTran)]
public PXSelectJoin<
        APTran,
                LeftJoin<POReceiptLine,
                          On<POReceiptLine.receiptNbr, Equal<APTran.receiptNbr>,
                          And<POReceiptLine.lineNbr, Equal<APTran.receiptLineNbr>>>>,
        Where<APTran.receiptNbr, Equal<Current<POReceipt.receiptNbr>>>> Transactions;


protected void POReceipt_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
  var row = (POReceipt)e.Row;
  var rowExt = row.GetExtension<POReceiptExt>();
  this.SetCalculatedValues(cache, row);      
}

protected void APTran_CuryLineAmt_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{      
  var row = (APTran)e.Row;      
  POReceipt receipt = Document.Current;
  this.SetCalculatedValues(Document.Cache, receipt);       
}

private void SetCalculatedValues(PXCache cache, object record)
{
  decimal invoiceLineTotal, receiptLineTotal;
  this.CalculateLineTotals(out invoiceLineTotal, out receiptLineTotal);

  cache.SetValueExt<POReceiptExt.usrTranTotal>(record, invoiceLineTotal);
  cache.SetValueExt<POReceiptExt.usrReceiptLineTotal>(record, receiptLineTotal);
  cache.SetValueExt<POReceiptExt.usrBalance>(record, receiptLineTotal - invoiceLineTotal);
  if( Math.Abs(receiptLineTotal  - invoiceLineTotal ) < 10 )
  {
    cache.SetValueExt<POReceipt.status>(record, "B");
  }
  else
  {
    cache.SetValueExt<POReceipt.status>(record, "H");
    cache.SetValueExt<POReceipt.hold>(record, true);
  }   
}

private void CalculateLineTotals(out decimal tranTotal, out decimal lineTotal)
{
    tranTotal = 0;
    lineTotal = 0;
    foreach(PXResult<APTran, POReceiptLine> record in Transactions.Select())
    {
       APTran tran = (APTran)record;
       POReceiptLine rLine = (POReceiptLine)record;
       lineTotal += rLine.TranCostFinal ?? 0; 
       tranTotal += tran.CuryTranAmt ?? 0;        
    }         
}

public bool ValidateReceiptBalance(string receiptNbr)
{      
    POReceipt receipt = _receiptRepository.GetByReceiptNbr(receiptNbr);
    if(receipt == null)
      throw new PXException("Receipt " + receiptNbr + " was not found");      

    this.Document.Current = receipt;

    decimal tranTotal = 0;
    decimal lineTotal = 0;
    this.CalculateLineTotals(out tranTotal, out lineTotal);


    return true;
}

}
}

这是痕迹...

5/22/2019 4:38:19 PM错误: 错误:“ TranDate”不能为空。在PX.Data.PXDBDefaultAttribute.RowPersisting(PXCache发送者,PXRowPersistingEventArgs e)    在PX.Data.PXCache.OnRowPersisting(对象项,PXDBOperation操作)    在PX.Data.PXCache 1.PersistUpdated(Object row, Boolean bypassInterceptor) at PX.Data.PXCache 1.Persist处(PXDBOperation操作)    在PX.Data.PXGraph.Persist(类型cacheType,PXDBOperation操作)    在PX.Data.PXGraph.Persist()    在PX.Data.PXSave 1.d__2.MoveNext() at PX.Data.PXAction 1.d__32.MoveNext()    在PX.Data.PXAction`1.d__32.MoveNext()    在PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName,String [] sortcolumns,Boolean []降序,Object []搜索,Object []参数,PXFilterRow []过滤器,DataSourceSelectArguments参数,Boolean&closeWindowRequired,Int32&adapterStartRow,Int32&adapterTotalRows )    在PX.Web.UI.PXBaseDataSource.ExecuteSelect(字符串viewName,DataSourceSelectArguments参数,PXDSSelectArguments pxarguments)

0 个答案:

没有答案
相关问题