【问题标题】:How to paste custom field values from Sales Order details to Shipment and AR Invoice?如何将销售订单详细信息中的自定义字段值粘贴到发货和 AR 发票?
【发布时间】:2018-02-13 02:28:34
【问题描述】:

我在 SOLine、SOShipLine 和 ARTran DAC 中创建了一个自定义的 DB 绑定字段,称为 Specialist

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 发票?

【问题讨论】:

    标签: acumatica acumatica-kb


    【解决方案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;
        }
    }
    

    新创建的 Shipment 应如下所示: 为以下销售订单执行创建装运操作后:

    要将自定义字段值粘贴到 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 发票示例: 为以下货件准备:

    新的 AR 发票应该是这样的: 为不处理发货的订单类型的销售订单执行准备发票操作后:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-06
      • 1970-01-01
      • 2019-04-01
      • 2015-12-10
      • 1970-01-01
      • 1970-01-01
      • 2017-06-18
      • 2020-02-08
      相关资源
      最近更新 更多