public virtual void InsertSOAdjustments(SOOrder order, ARPaymentEntry docgraph, ARPayment payment, InsertSOAdjustmentsDelegate baseMethod) { baseMethod(order, docgraph, payment); SOOrderRUTROT orderRR = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(order); if (orderRR.IsRUTROTDeductible == true) { RUTROT rutrot = PXSelect <RUTROT, Where <RUTROT.docType, Equal <Required <SOOrder.orderType> >, And <RUTROT.refNbr, Equal <Required <SOOrder.orderNbr> > > > > .Select(Base, order.OrderType, order.OrderNbr); foreach (SOAdjust adj in docgraph.SOAdjustments.Select()) { SOAdjust other = PXSelectGroupBy <SOAdjust, Where <SOAdjust.voided, Equal <False>, And <SOAdjust.adjdOrderType, Equal <Required <SOAdjust.adjdOrderType> >, And <SOAdjust.adjdOrderNbr, Equal <Required <SOAdjust.adjdOrderNbr> >, And <Where <SOAdjust.adjgDocType, NotEqual <Required <SOAdjust.adjgDocType> >, Or <SOAdjust.adjgRefNbr, NotEqual <Required <SOAdjust.adjgRefNbr> > > > > > > >, Aggregate <GroupBy <SOAdjust.adjdOrderType, GroupBy <SOAdjust.adjdOrderNbr, Sum <SOAdjust.curyAdjdAmt, Sum <SOAdjust.adjAmt> > > > > > .Select(Base, adj.AdjdOrderType, adj.AdjdOrderNbr, adj.AdjgDocType, adj.AdjgRefNbr); if (other == null || other.AdjdOrderNbr == null) { docgraph.SOAdjustments.Cache.SetValueExt <SOAdjust.curyAdjgAmt>(adj, adj.CuryAdjgAmt - rutrot.CuryTotalAmt); docgraph.SOAdjustments.Update(adj); } } } }
public void CreatePaymentProcess(PrepareAndImportOrdersParams orderParams) { SOOrder order = orderParams.objSOOrderEntry.Document.Current; SOOrderAmazonExt OrderExt = order.GetExtension <SOOrderAmazonExt>(); if (orderParams.objSOOrderEntry.sosetup.Current != null) { SOSetupAmazonExt objSOOSetupext = orderParams.objSOOrderEntry.sosetup.Current.GetExtension <SOSetupAmazonExt>(); if (objSOOSetupext != null && !string.IsNullOrEmpty(objSOOSetupext.UsrAmazonPaymentMethodID)) { string paymentType = ARPaymentType.Payment; orderParams.paymentGraph.Clear(); ARPayment payment = new ARPayment() { DocType = paymentType }; payment = PXCache <ARPayment> .CreateCopy(orderParams.paymentGraph.Document.Insert(payment)); payment.CustomerID = order.CustomerID; payment.CustomerLocationID = order.CustomerLocationID; payment.PaymentMethodID = objSOOSetupext.UsrAmazonPaymentMethodID; payment.PMInstanceID = order.PMInstanceID; payment.CuryOrigDocAmt = 0m; payment.ExtRefNbr = OrderExt != null ? OrderExt.UsrAmazonOrderID : order.OrderNbr; payment.DocDesc = order.OrderDesc; payment = orderParams.paymentGraph.Document.Update(payment); SOAdjust adj = new SOAdjust() { AdjdOrderType = order.OrderType.Trim(), AdjdOrderNbr = order.OrderNbr.Trim() }; orderParams.paymentGraph.SOAdjustments.Insert(adj); if (payment.CuryOrigDocAmt == 0m) { payment.CuryOrigDocAmt = payment.CurySOApplAmt; payment = orderParams.paymentGraph.Document.Update(payment); } orderParams.paymentGraph.Actions.PressSave(); if (orderParams.paymentGraph.Actions.Contains("Release")) { orderParams.paymentGraph.Actions["Release"].Press(); } } } }
/// <summary> /// Manually create AR payment and related to specified sales order. /// </summary> public static void CreatePaymentProcess(SOOrder order) { ARPaymentEntry pymtEntry = PXGraph.CreateInstance <ARPaymentEntry>(); string paymentType = ARPaymentType.Payment; ARPayment payment = new ARPayment() { DocType = paymentType }; payment = PXCache <ARPayment> .CreateCopy(pymtEntry.Document.Insert(payment)); payment.CustomerID = order.CustomerID; payment.CustomerLocationID = order.CustomerLocationID; payment.PaymentMethodID = order.PaymentMethodID; payment.PMInstanceID = order.PMInstanceID; payment.CuryOrigDocAmt = 0m; payment.ExtRefNbr = order.CustomerRefNbr ?? order.OrderNbr; payment.DocDesc = order.OrderDesc; payment = pymtEntry.Document.Update(payment); SOAdjust adj = new SOAdjust() { AdjdOrderType = order.OrderType.Trim(), AdjdOrderNbr = order.OrderNbr.Trim() }; pymtEntry.SOAdjustments.Insert(adj); if (payment.CuryOrigDocAmt == 0m) { payment.CuryOrigDocAmt = payment.CurySOApplAmt; payment = pymtEntry.Document.Update(payment); } pymtEntry.Actions.PressSave(); //if (orderParams.paymentGraph.Actions.Contains("Release")) //{ // orderParams.paymentGraph.Actions["Release"].Press(); //} }