Exemple #1
0
        protected virtual void SOOrder_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            SOOrderRUTROT row    = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>((SOOrder)e.Row);
            SOOrderRUTROT oldRow = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>((SOOrder)e.OldRow);

            RRManager.RUTROTDeductibleUpdated(row, oldRow, Rutrots.SelectSingle());
        }
Exemple #2
0
        public virtual void CopyOrderProc(SOOrder order, CopyParamFilter copyFilter, CopyOrderProcDelegate baseMethod)
        {
            RUTROT rutrotRecord = null;
            PXResultset <RUTROTDistribution> rutrotDistribution = null;
            SOOrderRUTROT orderRR = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(order);

            if (RUTROTHelper.IsRUTROTcompatibleType(order.OrderType) && orderRR?.IsRUTROTDeductible == true)
            {
                rutrotRecord       = Rutrots.SelectSingle();
                rutrotDistribution = RRDistribution.Select();
            }

            baseMethod(order, copyFilter);
            if (RUTROTHelper.IsRUTROTcompatibleType(copyFilter.OrderType) && rutrotRecord != null && rutrotDistribution != null)
            {
                rutrotRecord                      = (RUTROT)Rutrots.Cache.CreateCopy(rutrotRecord);
                rutrotRecord.RefNbr               = Base.Document.Current.OrderNbr;
                rutrotRecord.DocType              = Base.Document.Current.OrderType;
                rutrotRecord.CuryDistributedAmt   = 0m;
                rutrotRecord.CuryUndistributedAmt = 0m;
                rutrotRecord                      = Rutrots.Update(rutrotRecord);
                foreach (RUTROTDistribution distribution in rutrotDistribution)
                {
                    RUTROTDistribution new_distribution = (RUTROTDistribution)RRDistribution.Cache.CreateCopy(distribution);
                    new_distribution.RefNbr  = null;
                    new_distribution.DocType = null;
                    RRDistribution.Insert(new_distribution);
                }
            }
            else
            {
                Base.Document.Cache.SetValueExt <SOOrderRUTROT.isRUTROTDeductible>(Base.Document.Current, false);
                Base.Document.Update(Base.Document.Current);
            }
        }
        public virtual void InvoiceCreated(ARInvoice invoice, SOOrder source, SOInvoiceEntry.InvoiceCreatedDelegate baseMethod)
        {
            baseMethod(invoice, source);

            SOOrderRUTROT orderRR = PXCache <SOOrder> .GetExtension <SOOrderRUTROT>(source);

            if (orderRR?.IsRUTROTDeductible == true && invoice != null)
            {
                ARInvoiceRUTROT invoiceRR = PXCache <ARInvoice> .GetExtension <ARInvoiceRUTROT>(invoice);

                Base.Document.SetValueExt <ARInvoiceRUTROT.isRUTROTDeductible>(invoice, true);
                Base.Document.Update(invoice);

                RUTROT rutrot = PXSelect <RUTROT,
                                          Where <RUTROT.docType, Equal <Required <SOOrder.orderType> >,
                                                 And <RUTROT.refNbr, Equal <Required <SOOrder.orderNbr> > > > > .Select(Base, source.OrderType, source.OrderNbr);

                rutrot = RUTROTHelper.CreateCopy(Base.Rutrots.Cache, rutrot, invoice.DocType, invoice.RefNbr);
                rutrot = Base.Rutrots.Update(rutrot);

                foreach (RUTROTDistribution rutrotDetail in PXSelect <RUTROTDistribution,
                                                                      Where <RUTROTDistribution.docType, Equal <Required <SOOrder.orderType> >,
                                                                             And <RUTROTDistribution.refNbr, Equal <Required <SOOrder.orderNbr> > > > > .Select(Base, source.OrderType, source.OrderNbr))
                {
                    RUTROTDistribution new_detail = (RUTROTDistribution)Base.RRDistribution.Cache.CreateCopy(rutrotDetail);
                    new_detail.RefNbr  = null;
                    new_detail.DocType = null;
                    Base.RRDistribution.Insert(new_detail);
                }
            }
        }
Exemple #4
0
        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);
                    }
                }
            }
        }
Exemple #5
0
        public virtual void InvoiceOrder(DateTime invoiceDate, PXResult <SOOrderShipment, SOOrder, CurrencyInfo, SOAddress, SOContact, SOOrderType> order, PXResultset <SOShipLine, SOLine> details, Customer customer, DocumentList <ARInvoice, SOInvoice> list, InvoiceOrderDelegate baseMethod)
        {
            baseMethod(invoiceDate, order, details, customer, list);
            SOOrder       soorder = (SOOrder)order;
            SOOrderRUTROT orderRR = PXCache <SOOrder> .GetExtension <SOOrderRUTROT>(soorder);

            if (orderRR?.IsRUTROTDeductible == true && Base.Document.Current != null)
            {
                Base.Document.SetValueExt <ARInvoiceRUTROT.isRUTROTDeductible>(Base.Document.Current, true);
                Base.Document.Update(Base.Document.Current);

                RUTROT rutrot = PXSelect <RUTROT, Where <RUTROT.docType, Equal <Required <SOOrder.orderType> >,
                                                         And <RUTROT.refNbr, Equal <Required <SOOrder.orderNbr> > > > > .Select(Base, soorder.OrderType, soorder.OrderNbr);

                rutrot                      = (RUTROT)Base.Rutrots.Cache.CreateCopy(rutrot);
                rutrot.DocType              = Base.Document.Current.DocType;
                rutrot.RefNbr               = Base.Document.Current.RefNbr;
                rutrot.CuryDistributedAmt   = 0m;
                rutrot.CuryUndistributedAmt = 0m;
                rutrot                      = Base.Rutrots.Update(rutrot);
                RecalcFormulas(rutrot, PXCache <ARInvoice> .GetExtension <ARInvoiceRUTROT>(Base.Document.Current));
                foreach (RUTROTDistribution rutrotDetail in PXSelect <RUTROTDistribution, Where <RUTROTDistribution.docType, Equal <Required <SOOrder.orderType> >,
                                                                                                 And <RUTROTDistribution.refNbr, Equal <Required <SOOrder.orderNbr> > > > > .Select(Base, soorder.OrderType, soorder.OrderNbr))
                {
                    RUTROTDistribution new_detail = (RUTROTDistribution)Base.RRDistribution.Cache.CreateCopy(rutrotDetail);
                    new_detail.RefNbr  = null;
                    new_detail.DocType = null;
                    Base.RRDistribution.Insert(new_detail);
                }

                Base.Save.Press();
            }
        }
Exemple #6
0
        protected virtual void SOOrder_IsRUTROTDeductible_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            SOOrder row = (SOOrder)e.Row;

            if (row != null)
            {
                SOOrderRUTROT rowRR = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(row);
                if (rowRR.IsRUTROTDeductible == true)
                {
                    row.BillSeparately = true;
                }
            }
        }
Exemple #7
0
        protected virtual void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseMethod)
        {
            baseMethod(cache, e);
            SOOrderRUTROT doc = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(e.Row as SOOrder);

            if (doc == null)
            {
                return;
            }
            PXUIFieldAttribute.SetEnabled <SOOrder.billSeparately>(cache, e.Row, doc.IsRUTROTDeductible != true);

            RRManager.Update((SOOrder)e.Row);
            UpdateLinesControls(doc.IsRUTROTDeductible == true);
        }
Exemple #8
0
        protected virtual void SOOrder_CuryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            var row = (SOOrder)e.Row;

            if (row == null)
            {
                return;
            }

            SOOrderRUTROT doc = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(row);

            if (!RUTROTHelper.CurrenciesMatch(RUTROTHelper.GetBranchRUTROT(Base), doc))
            {
                doc.IsRUTROTDeductible = false;
            }
        }
Exemple #9
0
        public virtual void CopyOrderProc(SOOrder order, CopyParamFilter copyFilter, CopyOrderProcDelegate baseMethod)
        {
            List <RUTROTDistribution> rutrotDistribution = null;
            SOOrderRUTROT             orderRR            = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(order);

            if (RUTROTHelper.IsRUTROTcompatibleType(order.OrderType) && orderRR?.IsRUTROTDeductible == true)
            {
                rutrotDistribution = RRDistribution.Select().RowCast <RUTROTDistribution>().ToList();
            }

            baseMethod(order, copyFilter);
            if (RUTROTHelper.IsRUTROTcompatibleType(copyFilter.OrderType) && rutrotDistribution.Count > 0)
            {
                foreach (RUTROTDistribution distribution in rutrotDistribution)
                {
                    RUTROTDistribution new_distribution = (RUTROTDistribution)RRDistribution.Cache.CreateCopy(distribution);
                    new_distribution.RefNbr  = null;
                    new_distribution.DocType = null;
                    RRDistribution.Insert(new_distribution);
                }
            }
        }
Exemple #10
0
        public virtual void OrderCreated(SOOrder document, SOOrder source, SOOrderEntry.OrderCreatedDelegate baseMethod)
        {
            baseMethod(document, source);
            SOOrderRUTROT sourceRR = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(source);

            if (RUTROTHelper.IsRUTROTcompatibleType(source.OrderType) && sourceRR?.IsRUTROTDeductible == true)
            {
                if (RUTROTHelper.IsRUTROTcompatibleType(document.OrderType))
                {
                    RUTROT rutrotRecord = PXSelect <RUTROT,
                                                    Where <RUTROT.docType, Equal <Required <SOOrder.orderType> >,
                                                           And <RUTROT.refNbr, Equal <Required <SOOrder.orderNbr> > > > > .Select(this.Base, source.OrderType, source.OrderNbr);

                    rutrotRecord = RUTROTHelper.CreateCopy(Rutrots.Cache, rutrotRecord, Base.Document.Current.OrderType, Base.Document.Current.OrderNbr);
                    rutrotRecord = Rutrots.Update(rutrotRecord);
                }
                else
                {
                    Base.Document.Cache.SetValueExt <SOOrderRUTROT.isRUTROTDeductible>(document, false);
                    Base.Document.Update(document);
                }
            }
        }
Exemple #11
0
        protected virtual void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            SOLine         row      = e.Row as SOLine;
            SOLineRUTROT   rowRR    = RUTROTHelper.GetExtensionNullable <SOLine, SOLineRUTROT>(row);
            SOOrder        doc      = Base.Document.Current;
            SOOrderRUTROT  docRR    = RUTROTHelper.GetExtensionNullable <SOOrder, SOOrderRUTROT>(doc);
            RUTROTWorkType workType = PXSelect <RUTROTWorkType, Where <RUTROTWorkType.workTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this.Base, rowRR.RUTROTWorkTypeID);

            if (rowRR?.IsRUTROTDeductible == true && doc.Completed != true && rowRR?.RUTROTItemType != RUTROTItemTypes.OtherCost &&
                doc.Rejected != true && !RUTROTHelper.IsUpToDateWorkType(workType, doc.OrderDate ?? DateTime.Now))
            {
                sender.RaiseExceptionHandling <SOLineRUTROT.rUTROTWorkTypeID>(row, workType?.Description, new PXSetPropertyException(RUTROTMessages.ObsoleteWorkType));
            }
            else
            {
                sender.RaiseExceptionHandling <SOLineRUTROT.rUTROTWorkTypeID>(row, workType?.Description, null);
            }
            PXUIFieldAttribute.SetEnabled <SOLineRUTROT.isRUTROTDeductible>(Base.Transactions.Cache, row, row.IsStockItem != true && docRR.IsRUTROTDeductible == true);
        }