【发布时间】:2019-04-03 21:04:48
【问题描述】:
如果可能,我们有一项业务要求,将 SO 退货 COST 设置为未开票的原始成本。我们确定销售订单对于跟踪向我们的客户发放材料是必要的,而且我们是成本驱动的,而不是价格驱动的。我们使用 FIFO 成本核算,但 SO 退货订单似乎不会以原始 COST 退货,除非开具发票(我们也不会以传统方式这样做)。
我发现在确认装运和更新 IN 之前直接在数据库中设置 SO 装运行的单位/分机成本似乎可以提供所需的结果。应用自定义菜单选项来简化和强烈控制返回,我克隆了附近的代码作为基础。 === 之间的部分是我设置单位/分机成本的地方。 PXTrace 显示预期值,但在发货记录中显示为 0 美元。我想我可能需要“docgraph.Update(sOShipmentLine)”来保存它,但在这个范围内无法访问。
using (var ts = new PXTransactionScope())
{
PXTimeStampScope.SetRecordComesFirst(typeof(SOOrder), true);
//Reminder - SOShipmentEntry docgraph = PXGraph.CreateInstance<SOShipmentEntry>();
docgraph.CreateShipment(order, SiteID, filter.ShipDate, adapter.MassProcess, SOOperation.Receipt, created, adapter.QuickProcessFlow);
PXTrace.WriteError("Setting Cost");
//Set Cost on Shipment to Cost On SO Line
PXResultset<SOShipment> results =
PXSelectJoin<SOShipment,
InnerJoin <SOShipLine, On<SOShipLine.shipmentNbr, Equal<SOShipment.shipmentNbr>>,
InnerJoin <SOLine, On<SOLine.orderType, Equal<SOShipLine.origOrderType>,
And<SOLine.orderNbr, Equal<SOShipLine.origOrderNbr>, And<SOLine.lineNbr, Equal<SOShipLine.origLineNbr>>>>
>>,
Where<SOShipment.shipmentNbr, Equal<Required<SOShipment.shipmentNbr>>>>
.Select(docgraph, docgraph.Document.Current.ShipmentNbr);
PXTrace.WriteError("Shipment {0} - Records {1}", docgraph.Document.Current.ShipmentNbr, results.Count);
foreach (PXResult<SOShipment, SOShipLine, SOLine> record in results)
{
SOShipment shipment = (SOShipment)record;
SOShipLine shipmentLine = (SOShipLine)record;
SOLine sOLine = (SOLine)record;
==============================================
shipmentLine.UnitCost = GetReturnUnitCost(sOLine.OrigOrderType, sOLine.OrigOrderNbr, sOLine.OrigLineNbr, sOLine.CuryInfoID);
shipmentLine.ExtCost = shipmentLine.Qty * shipmentLine.UnitCost;
PXTrace.WriteError(string.Format("{0} {1}-{2} = {3} / {4}", shipmentLine.LineType, shipmentLine.ShipmentNbr, shipmentLine.LineNbr, shipmentLine.Qty, shipmentLine.UnitCost));
==============================================
}
PXAutomation.CompleteSimple(docgraph.Document.View);
var items = new List<object> { order };
PXAutomation.RemovePersisted(docgraph, typeof(SOOrder), items);
PXAutomation.RemoveProcessing(docgraph, typeof(SOOrder), items);
ts.Complete();
}
仍在学习曲线上,所以我希望解决方案对于更有经验的人来说可能简单明了。
【问题讨论】:
标签: acumatica