如何将自定义字段值从销售订单详细信息粘贴到货件和AR发票?

时间:2018-02-13 02:28:34

标签: acumatica acumatica-kb

我在SOLine,SOShipLine和ARTran DAC中创建了一个名为专家的自定义数据库绑定字段:

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
    public class usrSpecialist : IBqlField { }

    [PXDBString(60)]
    [PXUIField(DisplayName = "Specialist")]
    public string UsrSpecialist { get; set; }
}

public class SOShipLineExt : PXCacheExtension<PX.Objects.SO.SOShipLine>
{
    public class usrSpecialist : IBqlField { }

    [PXDBString(60)]
    [PXUIField(DisplayName = "Specialist")]
    public string UsrSpecialist { get; set; }
}

public class ARTranExt : PXCacheExtension<PX.Objects.AR.ARTran>
{
    public class usrSpecialist : IBqlField { }

    [PXDBString(60)]
    [PXUIField(DisplayName = "Specialist")]
    public string UsrSpecialist { get; set; }
}

如何将自定义字段值从销售订单详细信息粘贴到货件和AR发票?

1 个答案:

答案 0 :(得分:1)

要将自定义字段值从SOLine粘贴到SOShipLine ,您应该为 SOShipmentEntry BLC创建一个扩展名,并覆盖 CreateShipmentFromSchedules 方法,如下所示在以下示例中:

public class SOShipmentEntry_Extension : PXGraphExtension<PX.Objects.SO.SOShipmentEntry>
{
    public delegate bool CreateShipmentFromSchedulesDel(
        PXResult<SOShipmentPlan, SOLineSplit, SOLine, InventoryItem, INLotSerClass, INSite, SOShipLine> res,
        SOShipLine newline, SOOrderType ordertype, string operation, DocumentList<SOShipment> list);

    [PXOverride]
    public bool CreateShipmentFromSchedules(
        PXResult<SOShipmentPlan, SOLineSplit, SOLine, InventoryItem, INLotSerClass, INSite, SOShipLine> res,
        SOShipLine newline, SOOrderType ordertype, string operation, DocumentList<SOShipment> list,
        CreateShipmentFromSchedulesDel del)
    {
        SOLine line = (SOLine)res;
        PXFieldDefaulting specialistFieldDefaulting = new PXFieldDefaulting((s, a) =>
        {
            if (line != null)
            {
                a.NewValue = line.GetExtension<SOLineExt>().UsrSpecialist;
                a.Cancel = true;
            }
        });

        bool result;
        Base.FieldDefaulting.AddHandler<SOShipLineExt.usrSpecialist>(specialistFieldDefaulting);
        try
        {
            result = del(res, newline, ordertype, operation, list);
        }
        finally
        {
            Base.FieldDefaulting.RemoveHandler<SOShipLineExt.usrSpecialist>(specialistFieldDefaulting);
        }
        return result;
    }
}

这是新创建的货件应如下所示: enter image description here 执行以下销售订单的创建装运操作后: enter image description here

要将自定义字段值粘贴到ARTran ,您应该为 SOInvoiceEntry BLC创建一个扩展名,并覆盖 CreateTranFromShipLine 方法。

因为在销售订单(SO301000)和发货(SO302000)屏幕上找到的准备发票按钮可用于根据货件详细信息或直接从销售创建新的AR发票这些订单的订单详细信息,订单类型不处理货件(“订单类型”屏幕上未选中“处理货件”选项),验证当前销售订单的类型是否处理货件是必要的。对于订单类型,即处理货件,我们会将自定义字段值从SOShipLine粘贴到ARTran。否则,自定义字段值将从SOLine粘贴到ARTran。

public class SOInvoiceEntry_Extension : PXGraphExtension<PX.Objects.SO.SOInvoiceEntry>
{
    public delegate ARTran CreateTranFromShipLineDel(ARInvoice newdoc, SOOrderType ordertype, string operation,
        SOLine orderline, ref SOShipLine shipline);

    [PXOverride]
    public ARTran CreateTranFromShipLine(ARInvoice newdoc, SOOrderType ordertype, string operation,
        SOLine orderline, ref SOShipLine shipline, CreateTranFromShipLineDel del)
    {
        var arTran = del(newdoc, ordertype, operation, orderline, ref shipline);
        PXCache<ARTran>.GetExtension<ARTranExt>(arTran).UsrSpecialist = ordertype.RequireShipping == true ?
            shipline.GetExtension<SOShipLineExt>().UsrSpecialist :
            orderline.GetExtension<SOLineExt>().UsrSpecialist;
        return arTran;
    }
}

以下是新AR发票的示例: enter image description here 准备下面的装运: enter image description here

这就是新的AR发票应该是这样的: enter image description here 执行订单类型的销售订单的准备发票操作后,不处理货件: enter image description here

有关如何将AR发票详细信息中的自定义字段值直接粘贴到GL事务中的示例,请检查this answer

相关问题