处理多张发票,并在一份报告中显示所有发票,就像打印发票/备忘录报告在Acumatica中的工作方式一样
基本上,我想在打印发票和备忘录屏幕上创建一个新的操作按钮,以打印所选发票的报告 我们创建新操作按钮的原因是,这里我们需要为每个发票(SO类型)打印不同的格式,所以当用户在网格中选择3个不同的记录时 例如 1.INV1234,所以类型是TS,然后我需要打印xyz报告 2.INV9875,这还没有通过创建,所以我需要打印ABC报告 3.CRM4567和SO类型为TS(类似于上述1个选项) 所以这里1和3应该在一页中打印(就像默认acumatica中的处理按钮一样) 2选项报告应在新选项卡中打印 如果我得到一个示例代码,在一页中打印同一个报告,在另一个选项卡中打印另一个报告就可以了 下面是代码处理多张发票,并在一份报告中显示所有发票,就像打印发票/备忘录报告在Acumatica中的工作方式一样,acumatica,acumatica-kb,Acumatica,Acumatica Kb,基本上,我想在打印发票和备忘录屏幕上创建一个新的操作按钮,以打印所选发票的报告 我们创建新操作按钮的原因是,这里我们需要为每个发票(SO类型)打印不同的格式,所以当用户在网格中选择3个不同的记录时 例如 1.INV1234,所以类型是TS,然后我需要打印xyz报告 2.INV9875,这还没有通过创建,所以我需要打印ABC报告 3.CRM4567和SO类型为TS(类似于上述1个选项) 所以这里1和3应该在一页中打印(就像默认acumatica中的处理按钮一样) 2选项报告应在新选项卡中打印 如果
public PXAction<PrintInvoicesFilter> PrintReport;
[PXUIField(DisplayName = "Print Sales Invoice with Price", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton]
public virtual IEnumerable printReport(PXAdapter adapter, [PXString] string reportID)
{
PXReportRequiredException ex = null;
foreach (ARInvoice doc in Base.ARDocumentList.Cache.Cached)
{
var parameters = new Dictionary<string, string>();
if (doc.Selected == true)
{
ARTran TranData = PXSelectReadonly<ARTran, Where<ARTran.tranType, Equal<Required<ARTran.tranType>>,
And<ARTran.refNbr, Equal<Required<ARTran.refNbr>>>>>.Select(Base, doc.DocType, doc.RefNbr);
if (TranData != null)
{
if (TranData.SOOrderType == "WS" || TranData.SOOrderType == "WO" || TranData.SOOrderType == "TS" || TranData.SOOrderType == "IM")
{
if (reportID == null) reportID = "KR501011";
if (reportID == "KR501011")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501011", parameters,false);
}
if (TranData.SOOrderType == "RX")
{
if (reportID == null) reportID = "KR501016";
if (reportID == "KR501016")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501016", parameters,false);
}
if (string.IsNullOrEmpty(TranData.SOOrderType))
{
if (reportID == null) reportID = "KR501038";
if (reportID == "KR501038")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501038", parameters,false);
}
}
}
}
if (ex != null)
{
ex.Mode = PXBaseRedirectException.WindowMode.New;
ex.SeparateWindows = false;
throw ex;
}
公共行动打印报告;
[PXUIField(DisplayName=“打印带价格的销售发票”,MapEnableRights=PXCacheRights.Select,MapViewRights=PXCacheRights.Select)]
[查看按钮]
公共虚拟IEnumerable打印报告(PXAdapter适配器,[PXString]字符串报告ID)
{
PXReportRequiredException ex=null;
foreach(Base.ARDocumentList.Cache.Cached中的ARInvoice文档)
{
var参数=新字典();
如果(doc.Selected==true)
{
ARTran TranData=PXSelectReadonly.Select(基本、doc.DocType、doc.RefNbr);
if(transdata!=null)
{
如果(TranData.SOOrderType==“WS”| | TranData.SOOrderType==“WO”| | TranData.SOOrderType==“TS”| | TranData.SOOrderType==“IM”)
{
如果(reportID==null)reportID=“KR501011”;
如果(报告ID==“KR501011”)
{
参数[“DocType”]=doc.DocType;
参数[“RefNbr”]=doc.RefNbr;
}
ex=PXReportRequiredException.CombineReport(例如,“KR501011”,参数,false);
}
如果(TranData.SOOrderType==“RX”)
{
如果(reportID==null)reportID=“KR501016”;
如果(报告ID==“KR501016”)
{
参数[“DocType”]=doc.DocType;
参数[“RefNbr”]=doc.RefNbr;
}
ex=PXReportRequiredException.CombineReport(例如,“KR501016”,参数,false);
}
if(string.IsNullOrEmpty(TranData.SOOrderType))
{
如果(reportID==null)reportID=“KR501038”;
如果(reportID==“KR501038”)
{
参数[“DocType”]=doc.DocType;
参数[“RefNbr”]=doc.RefNbr;
}
ex=PXReportRequiredException.CombineReport(例如,“KR501038”,参数,false);
}
}
}
}
如果(ex!=null)
{
ex.Mode=PXBaseRedirectException.WindowMode.New;
例如,SeparateWindows=false;
掷骰子;
}
提前感谢。重定向到多个报告或在单个文档中组合多个报告只能通过方法
PXReportRequiredException.CombineReport
实现
重定向异常有两个选项可用于控制报告的组合方式:
PXReportRequiredException ex = null;
if(row.ARRefNumber != null)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary["DocType"] = row.ARDocType;
dictionary["RefNbr"] = row.ARRefNumber;
ex = PXReportRequiredException.CombineReport(ex, row.ARBatchNumber == null ? "AR610500" : "AR622000", dictionary, false);
}
if (row.APRefNumber != null)
{
APInvoice inv = PXSelectorAttribute.Select<DocHeader.aPRefNumber>(Document.Cache, row) as APInvoice;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary["DocType"] = row.APDocType;
dictionary["RefNbr"] = row.APRefNumber;
dictionary["PeriodTo"] = PX.Objects.GL.OpenPeriodAttribute.FormatForDisplay(inv.FinPeriodID);
dictionary["PeriodFrom"] = PX.Objects.GL.OpenPeriodAttribute.FormatForDisplay(inv.FinPeriodID);
ex = PXReportRequiredException.CombineReport(ex, row.APBatchNumber == null ? "AP610500" : "AP622000", dictionary, false);
}
if (ex != null)
{
ex.Mode = PXBaseRedirectException.WindowMode.New;
ex.SeparateWindows = true;
throw ex;
}
PXReportRequiredException ex=null;
if(row.ARRefNumber!=null)
{
字典=新字典();
字典[“DocType”]=row.ARDocType;
字典[“RefNbr”]=行.ARRefNumber;
ex=PXReportRequiredException.CombineReport(ex,row.ARBatchNumber==null?“AR610500”:“AR622000”,dictionary,false);
}
if(row.APRefNumber!=null)
{
APInvoice inv=PXSelectorAttribute。选择(Document.Cache,row)作为APInvoice;
字典=新字典();
字典[“DocType”]=row.APDocType;
字典[“RefNbr”]=行.APRefNumber;
dictionary[“PeriodTo”]=PX.Objects.GL.OpenPeriodAttribute.FormatForDisplay(inv.FinPeriodID);
dictionary[“PeriodFrom”]=PX.Objects.GL.OpenPeriodAttribute.FormatForDisplay(inv.FinPeriodID);
ex=PXReportRequiredException.CombineReport(ex,row.APBatchNumber==null?“AP610500”:“AP622000”,dictionary,false);
}
如果(ex!=null)
{
ex.Mode=PXBaseRedirectException.WindowMode.New;
例如,SeparateWindows=true;
掷骰子;
}
重定向到多个报告或在一个文档中组合多个报告只能通过方法PXReportRequiredException.CombineReport
实现
重定向异常有两个选项可用于控制报告的组合方式: