public static void Process(SOOrder doc)
        {
            List <SOOrder> list = new List <SOOrder>();

            list.Add(doc);
            Process(list, false);
        }
Example #2
0
        protected virtual void FinalizeDO()
        {
            SOOrder    row    = Base.Document.Current;
            SOOrderExt rowExt = PXCache <SOOrder> .GetExtension <SOOrderExt>(row);

            string soNumber           = row.OrderNbr;
            string actualEffortResult = actualEffort(row.OrderNbr);

            if (actualEffortResult != "OK")
            {
                throw new PXException(actualEffortResult);
            }

            string finalizeDOResult = finalizeEllipseProject(row.OrderNbr);

            if (finalizeDOResult != "OK")
            {
                throw new PXException(finalizeDOResult);
            }

            Base.Document.Cache.SetValueExt <SOOrderExt.usrFinalized>(row, true);
            Base.Document.Cache.Update(row);

            //Base.Caches[typeof(SOOrder)].SetValueExt<SOOrderExt.usrFinalized>(row, true);
            //Base.Caches[typeof(SOOrder)].Update(rowExt);
            Base.Save.Press();
        }
 protected virtual IAddressBase GetToAddress(SOOrder order)
 {
     if (order.WillCall == true)
     {
         return(GetFromAddress(order));
     }
     else
     {
         return(((SOShippingAddress)PXSelect <SOShippingAddress, Where <SOShippingAddress.addressID, Equal <Required <SOOrder.shipAddressID> > > > .Select(Base, order.ShipAddressID)).With(ValidAddressFrom <SOOrder.shipAddressID>));
     }
 }
        protected virtual IAddressBase GetFromAddress(SOOrder order)
        {
            var branch = PXSelectJoin <Branch, InnerJoin <BAccountR, On <BAccountR.bAccountID, Equal <Branch.bAccountID> >,
                                                          InnerJoin <Address, On <Address.addressID, Equal <BAccountR.defAddressID> > > >,
                                       Where <Branch.branchID, Equal <Required <Branch.branchID> > > > .Select(Base, order.BranchID)
                         .RowCast <Address>()
                         .FirstOrDefault()
                         .With(ValidAddressFrom <BAccountR.defAddressID>);

            return(branch);
        }
Example #5
0
        protected virtual void SOOrder_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            SOOrder doc = (SOOrder)e.Row;

            if (e.Operation == PXDBOperation.Update)
            {
                if (doc.ShipmentCntr < 0 || doc.OpenShipmentCntr < 0 || doc.ShipmentCntr < doc.BilledCntr + doc.ReleasedCntr && doc.Behavior == SOBehavior.SO)
                {
                    throw new PXSetPropertyException(Messages.InvalidShipmentCounters);
                }
            }
        }
Example #6
0
        protected virtual void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            SOOrder row = (SOOrder)e.Row;

            if (row == null)
            {
                return;
            }
            SOOrderExt sOOrderExt = row.GetExtension <SOOrderExt>();

            this.finalizeDO.SetEnabled(row.OrderType == SOOrderTypeConstants.SalesOrder && row.Status == SOOrderStatus.Completed && row.Hold == false && sOOrderExt.UsrFinalized == false);
        }
Example #7
0
        public virtual List <PXResult <SOOrderShipment, SOOrder> > UpdateOrderShipments(ARRegister arDoc, HashSet <object> processed)
        {
            bool isCancellationInvoice = (arDoc.IsCancellation == true);
            bool isCorrectionInvoice   = (arDoc.IsCorrection == true);
            var  boundInvoice          = isCancellationInvoice
                                ? ARInvoice.PK.Find(this, arDoc.OrigDocType, arDoc.OrigRefNbr)
                                : arDoc;

            var orderShipments = this.Items.View.SelectMultiBound(new object[] { boundInvoice })
                                 .Cast <PXResult <SOOrderShipment, SOOrder> >()
                                 .ToList();

            foreach (var ordershipment in orderShipments)
            {
                SOOrderShipment copy = PXCache <SOOrderShipment> .CreateCopy(ordershipment);

                if (isCancellationInvoice)
                {
                    ARInvoice existingCorrectionInvoice = PXSelect <ARInvoice,
                                                                    Where <ARInvoice.origDocType, Equal <Current <ARInvoice.origDocType> >,
                                                                           And <ARInvoice.origRefNbr, Equal <Current <ARInvoice.origRefNbr> >,
                                                                                And <ARInvoice.isCorrection, Equal <True> > > > >
                                                          .SelectSingleBound(this, new[] { arDoc });

                    copy.InvoiceType = existingCorrectionInvoice?.DocType;
                    copy.InvoiceNbr  = existingCorrectionInvoice?.RefNbr;
                }
                copy.InvoiceReleased = !isCancellationInvoice;

                this.Items.Update(copy);

                if (!isCancellationInvoice && !isCorrectionInvoice)
                {
                    SOOrder     order = ordershipment;
                    SOOrderType otype = SOOrderType.PK.Find(this, order.OrderType);
                    if ((order.Completed == true || otype.RequireShipping == false) && order.BilledCntr <= 1 && order.ShipmentCntr <= order.BilledCntr + order.ReleasedCntr)
                    {
                        foreach (SOAdjust adj in this.Adjustments.Select(order.OrderType, order.OrderNbr))
                        {
                            SOAdjust adjcopy = PXCache <SOAdjust> .CreateCopy(adj);

                            adjcopy.CuryAdjdAmt = 0m;
                            adjcopy.CuryAdjgAmt = 0m;
                            adjcopy.AdjAmt      = 0m;
                            this.Adjustments.Update(adjcopy);
                        }
                    }
                }
                processed.Add(arDoc);
            }
            return(orderShipments);
        }
Example #8
0
        protected void SOOrder_Status_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            SOOrder sOOrder = (SOOrder)e.Row;

            if (sOOrder.Status == SOOrderStatus.Open && sOOrder.OrderType == SOOrderTypeConstants.SalesOrder)
            {
                String soNbr = sOOrder.OrderNbr;
                if (sOOrder.OrderNbr != null)
                {
                    createDO(sOOrder);
                }
            }
        }
Example #9
0
        protected virtual IEnumerable innerLabel(PXAdapter adapter)
        {
            var _reportID   = "lm601002";
            var _CurrentRow = Base.GetCacheCurrent <AMProdItem>().Current;

            PXResultset <InventoryItem> data =
                SelectFrom <InventoryItem>
                .LeftJoin <INItemXRef> .On <INItemXRef.inventoryID.IsEqual <InventoryItem.inventoryID> >
                .LeftJoin <CSAnswers> .On <InventoryItem.noteID.IsEqual <CSAnswers.refNoteID> >
                .Where <InventoryItem.inventoryID.IsEqual <P.AsInt> > .View.Select(Base, _CurrentRow.InventoryID);

            SOOrder soData = soOrderData.Select(
                _CurrentRow.GetExtension <AMProdItemExt>().UsrSOOrderNbr,
                _CurrentRow.GetExtension <AMProdItemExt>().UsrSOOrderType);

            SOLine soLineData =
                SelectFrom <SOLine>
                .Where <SOLine.orderNbr.IsEqual <P.AsString>
                        .And <SOLine.orderType.IsEqual <P.AsString> >
                        .And <SOLine.lineNbr.IsEqual <P.AsInt> > >
                .View.Select(Base,
                             _CurrentRow.GetExtension <AMProdItemExt>().UsrSOOrderNbr,
                             _CurrentRow.GetExtension <AMProdItemExt>().UsrSOOrderType,
                             _CurrentRow.GetExtension <AMProdItemExt>().UsrSOLineNbr);

            var _customer = (soOrderData.Cache.GetValueExt(soData, PX.Objects.CS.Messages.Attribute + "ENDC") as PXFieldState).Value.ToString();
            var ENDCDescr = new PXGraph().Select <CSAttributeDetail>().Where(x => x.ValueID == _customer).FirstOrDefault()?.Description;

            ENDCDescr = ENDCDescr ?? _customer;

            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                ["OrderType"]      = _CurrentRow.OrderType,
                ["ProdOrdID"]      = _CurrentRow.ProdOrdID,
                ["Customer"]       = ENDCDescr,
                ["CustomerPartNo"] = soLineData?.AlternateID,
                ["Description"]    = data.FirstOrDefault().GetItem <InventoryItem>().Descr,
                ["Resistor"]       = data.RowCast <CSAnswers>().Where(x => x.AttributeID == "RESISTOR").FirstOrDefault()?.Value,
                ["DATE"]           = null
            };

            throw new PXReportRequiredException(parameters, _reportID, string.Format("Report {0}", _reportID));
        }
Example #10
0
        public virtual void CompleteSOLinesAndSplits(ARRegister ardoc, List <PXResult <SOOrderShipment, SOOrder> > orderShipments)
        {
            if (ardoc.IsCancellation == true || ardoc.IsCorrection == true)
            {
                return;
            }

            foreach (PXResult <SOOrderShipment, SOOrder> orderShipment in orderShipments)
            {
                SOOrder     order     = orderShipment;
                SOOrderType orderType = SOOrderType.PK.Find(this, order.OrderType);
                if (orderType.RequireShipping == false)
                {
                    PXDatabase.Update <SOLine>(
                        new PXDataFieldAssign <SOLine.completed>(true),
                        new PXDataFieldRestrict <SOLine.completed>(false),
                        new PXDataFieldRestrict <SOLine.orderType>(PXDbType.VarChar, 2, order.OrderType, PXComp.EQ),
                        new PXDataFieldRestrict <SOLine.orderNbr>(PXDbType.NVarChar, 15, order.OrderNbr, PXComp.EQ));
                    PXDatabase.Update <SOLineSplit>(
                        new PXDataFieldAssign <SOLineSplit.completed>(true),
                        new PXDataFieldRestrict <SOLineSplit.completed>(false),
                        new PXDataFieldRestrict <SOLineSplit.orderType>(PXDbType.VarChar, 2, order.OrderType, PXComp.EQ),
                        new PXDataFieldRestrict <SOLineSplit.orderNbr>(PXDbType.NVarChar, 15, order.OrderNbr, PXComp.EQ));
                }
            }
            PXUpdateJoin <
                Set <SOLine.completed, True>,
                SOLine,
                InnerJoin <ARTran, On <ARTran.sOOrderType, Equal <SOLine.orderType>,
                                       And <ARTran.sOOrderNbr, Equal <SOLine.orderNbr>,
                                            And <ARTran.sOOrderLineNbr, Equal <SOLine.lineNbr> > > > >,
                Where <SOLine.lineType, Equal <SOLineType.miscCharge>,
                       And <SOLine.completed, Equal <False>,
                            And <ARTran.tranType, Equal <Required <ARTran.tranType> >,
                                 And <ARTran.refNbr, Equal <Required <ARTran.refNbr> > > > > > >
            .Update(this,
                    ardoc.DocType,
                    ardoc.RefNbr);
        }
        public virtual IEnumerable orders()
        {
            PXUIFieldAttribute.SetDisplayName <SOOrder.customerID>(Caches[typeof(SOOrder)], Messages.CustomerID);

            List <SOOrder> ret = new List <SOOrder>();

            SOOrderFilter filter = PXCache <SOOrderFilter> .CreateCopy(Filter.Current);

            if (filter.Action == "<SELECT>")
            {
                return(ret);
            }

            string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID");

            if (_ActionChanged)
            {
                Orders.Cache.Clear();
            }

            foreach (SOOrder order in Orders.Cache.Updated)
            {
                ret.Add(order);
            }

            PXSelectBase <SOOrder> cmd;

            switch (actionID)
            {
            case "1":
                cmd = new PXSelectJoinGroupBy <SOOrder,
                                               InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                          LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                    InnerJoin <SOShipmentPlan, On <SOOrder.orderType, Equal <SOShipmentPlan.orderType>, And <SOOrder.orderNbr, Equal <SOShipmentPlan.orderNbr> > >,
                                                                               LeftJoin <SOOrderShipment, On <SOOrderShipment.orderType, Equal <SOShipmentPlan.orderType>, And <SOOrderShipment.orderNbr, Equal <SOShipmentPlan.orderNbr>, And <SOOrderShipment.siteID, Equal <SOShipmentPlan.siteID>, And <SOOrderShipment.confirmed, Equal <boolFalse> > > > > > > > >,
                                               Where <SOShipmentPlan.inclQtySOBackOrdered, Equal <short0>, And <SOOrderShipment.shipmentNbr, IsNull> >,
                                               Aggregate <
                                                   GroupBy <SOOrder.orderType,
                                                            GroupBy <SOOrder.orderNbr> > > >(this);

                if (filter.DateSel == "S")
                {
                    cmd.WhereAnd <Where <SOShipmentPlan.planDate, LessEqual <Current <SOOrderFilter.endDate> > > >();

                    if (filter.StartDate != null)
                    {
                        cmd.WhereAnd <Where <SOShipmentPlan.planDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    }

                    filter.DateSel = string.Empty;
                }
                break;

            case "3":
                cmd = new PXSelectJoinGroupBy <SOOrder,
                                               InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                          LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                    LeftJoin <SOOrderShipment, On <SOOrderShipment.orderType, Equal <SOOrder.orderType>, And <SOOrderShipment.orderNbr, Equal <SOOrder.orderNbr> > >,
                                                                              LeftJoin <ARInvoice, On <ARInvoice.docType, Equal <SOOrderShipment.invoiceType>, And <ARInvoice.refNbr, Equal <SOOrderShipment.invoiceNbr> > > > > > >,
                                               Where <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                      And2 <Where <SOOrderType.requireShipping, Equal <boolFalse>, Or <SOOrder.shipmentCntr, Equal <short0>, And <SOOrder.openLineCntr, Equal <short0> > > >,
                                                            And <ARInvoice.refNbr, IsNull> > >,
                                               Aggregate <
                                                   GroupBy <SOOrder.orderType,
                                                            GroupBy <SOOrder.orderNbr> > > >(this);
                break;

            case "3.5":
                cmd = new PXSelectJoinGroupBy <SOOrder,
                                               InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                          LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.orderType, Equal <SOOrder.orderType>, And <SOOrderShipment.orderNbr, Equal <SOOrder.orderNbr> > >,
                                                                               LeftJoin <ARInvoice, On <ARInvoice.docType, Equal <SOOrderShipment.invoiceType>, And <ARInvoice.refNbr, Equal <SOOrderShipment.invoiceNbr> > > > > > >,
                                               Where <SOOrderShipment.confirmed, Equal <boolTrue>,
                                                      And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                           And <ARInvoice.refNbr, IsNull> > >,
                                               Aggregate <
                                                   GroupBy <SOOrder.orderType,
                                                            GroupBy <SOOrder.orderNbr> > > >(this);
                break;

            default:
                if (!string.IsNullOrEmpty(filter.Action) && filter.Action.StartsWith("PrepareInvoice", StringComparison.OrdinalIgnoreCase))
                {
                    cmd = new PXSelectJoinGroupBy <SOOrder,
                                                   InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType>, And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate> > >,
                                                              LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> >,
                                                                        LeftJoin <SOOrderShipment, On <SOOrderShipment.orderType, Equal <SOOrder.orderType>, And <SOOrderShipment.orderNbr, Equal <SOOrder.orderNbr> > >,
                                                                                  LeftJoin <ARInvoice, On <ARInvoice.docType, Equal <SOOrderShipment.invoiceType>, And <ARInvoice.refNbr, Equal <SOOrderShipment.invoiceNbr> > > > > > >,
                                                   Where <SOOrder.hold, Equal <boolFalse>, And <SOOrder.cancelled, Equal <boolFalse>,
                                                                                                And <Where <Sub <Sub <Sub <SOOrder.shipmentCntr,
                                                                                                                           SOOrder.openShipmentCntr>,
                                                                                                                      SOOrder.billedCntr>,
                                                                                                                 SOOrder.releasedCntr>, Greater <short0>,
                                                                                                            Or2 <Where <SOOrder.orderQty, Equal <decimal0>,
                                                                                                                        And <SOOrder.curyUnbilledMiscTot, Greater <decimal0> > >,
                                                                                                                 Or <Where <SOOrderType.requireShipping, Equal <boolFalse>, And <ARInvoice.refNbr, IsNull> > > > > > > >,
                                                   Aggregate <
                                                       GroupBy <SOOrder.orderType,
                                                                GroupBy <SOOrder.orderNbr> > > >(this);
                }
                else
                {
                    cmd = new PXSelectJoin <SOOrder, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                                LeftJoin <Carrier, On <SOOrder.shipVia, Equal <Carrier.carrierID> > > > >(this);
                }
                break;
            }

            switch (filter.DateSel)
            {
            case "S":
                cmd.WhereAnd <Where <SOOrder.shipDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                break;

            case "C":
                cmd.WhereAnd <Where <SOOrder.cancelDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                break;

            case "O":
                cmd.WhereAnd <Where <SOOrder.orderDate, LessEqual <Current <SOOrderFilter.endDate> > > >();
                break;
            }

            if (filter.StartDate != null)
            {
                switch (filter.DateSel)
                {
                case "S":
                    cmd.WhereAnd <Where <SOOrder.shipDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;

                case "C":
                    cmd.WhereAnd <Where <SOOrder.cancelDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;

                case "O":
                    cmd.WhereAnd <Where <SOOrder.orderDate, GreaterEqual <Current <SOOrderFilter.startDate> > > >();
                    break;
                }
            }

            if (filter.SiteID != null)
            {
                switch (actionID)
                {
                case "1":
                    cmd.WhereAnd <Where <SOShipmentPlan.siteID, Equal <Current <SOOrderFilter.siteID> > > >();
                    break;
                }
            }

            if (!string.IsNullOrEmpty(filter.CarrierPluginID))
            {
                cmd.WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOOrderFilter.carrierPluginID> > > >();
            }

            if (!string.IsNullOrEmpty(filter.ShipVia))
            {
                cmd.WhereAnd <Where <SOOrder.shipVia, Equal <Current <SOOrderFilter.shipVia> > > >();
            }

            if (filter.CustomerID != null)
            {
                cmd.WhereAnd <Where <SOOrder.customerID, Equal <Current <SOOrderFilter.customerID> > > >();
            }

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <PXFilterRow> newFilters = new List <PXFilterRow>();

            foreach (PXFilterRow f in PXView.Filters)
            {
                if (f.DataField.ToLower() == "behavior")
                {
                    f.DataField = "SOOrderType__Behavior";
                }
                newFilters.Add(f);
            }

            foreach (PXResult <SOOrder, SOOrderType> res in cmd.View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows))
            {
                SOOrder order = res;
                SOOrder cached;

                order.Behavior         = ((SOOrderType)res).Behavior;
                order.ARDocType        = ((SOOrderType)res).ARDocType;
                order.DefaultOperation = ((SOOrderType)res).DefaultOperation;

                if ((cached = (SOOrder)Orders.Cache.Locate(order)) == null || Orders.Cache.GetStatus(cached) == PXEntryStatus.Notchanged)
                {
                    ret.Add(order);
                }
            }

            PXView.StartRow = 0;

            Orders.Cache.IsDirty = false;

            return(ret);
        }
        public virtual IEnumerable orders()
        {
            PXUIFieldAttribute.SetDisplayName <SOOrder.customerID>(Caches[typeof(SOOrder)], Messages.CustomerID);

            SOOrderFilter filter = PXCache <SOOrderFilter> .CreateCopy(Filter.Current);

            if (filter.Action == "<SELECT>")
            {
                yield break;
            }

            string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID");

            if (_ActionChanged)
            {
                Orders.Cache.Clear();
            }

            PXSelectBase <SOOrder> cmd;

            const string ActionIdCreateShipment = "1";

            switch (actionID)
            {
            case ActionIdCreateShipment:
                cmd = BuildCommandCreateShipment(filter);
                break;

            case var action when !string.IsNullOrEmpty(filter.Action) && filter.Action.StartsWith("PrepareInvoice", StringComparison.OrdinalIgnoreCase):
                cmd = BuildCommandPrepareInvoice();
                break;

            default:
                cmd = BuildCommandDefault();
                break;
            }

            AddCommonFilters(filter, cmd);

            PXFilterRow[] newFilters = AlterFilters();

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            foreach (PXResult <SOOrder, SOOrderType> res in cmd.View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters, ref startRow, PXView.MaximumRows, ref totalRows))
            {
                SOOrder order = res;
                SOOrder cached;

                order.Behavior         = ((SOOrderType)res).Behavior;
                order.ARDocType        = ((SOOrderType)res).ARDocType;
                order.DefaultOperation = ((SOOrderType)res).DefaultOperation;

                if ((cached = (SOOrder)Orders.Cache.Locate(order)) != null)
                {
                    order.Selected = cached.Selected;
                }

                yield return(order);
            }

            PXView.StartRow = 0;

            Orders.Cache.IsDirty = false;
        }
Example #13
0
        string createProjectEstimate(SOOrder sOOrder)
        {
            string transID = "";
            string result  = "";

            try
            {
                ClientConversation.authenticate(userName, password);
                TransactionService transactionService = new TransactionService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}TransactionService"
                };
                PLNSC.TransactionRef.OperationContext transContext = new PLNSC.TransactionRef.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance
                };

                transID = transactionService.begin(transContext);

                EPEmployee ePEmployee = PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > .Select(Base, sOOrder.OwnerID);

                string estimatorId = ePEmployee != null ? ePEmployee.AcctCD : "ADMIN";

                ProjectEstimateService projectEstimateService = new ProjectEstimateService()
                {
                    Timeout = transactionService.Timeout,
                    Url     = $"{urlPrefix(dbName)}ProjectEstimateService"
                };

                PLNSC.ProjectEstimateRef.OperationContext projectEstimateOperationContext = new PLNSC.ProjectEstimateRef.OperationContext()
                {
                    district     = transContext.district,
                    position     = transContext.position,
                    maxInstances = transContext.maxInstances
                };

                //ProjectEstimateDTO[] projectEstimateDTOs = new ProjectEstimateDTO[1];
                ProjectEstimateDTO projectEstimateDTO = new ProjectEstimateDTO()
                {
                    districtCode                       = transContext.district,
                    projectNo                          = sOOrder.OrderNbr.Trim(),
                    estimateBuildMethod                = "T",
                    estimatorId                        = estimatorId,
                    directEstimateCost                 = Math.Round(sOOrder.OrderTotal ?? 0, 2),
                    directEstimateCostSpecified        = true,
                    directUnallocFinPeriodEst          = Math.Round(sOOrder.OrderTotal ?? 0, 2),
                    directUnallocFinPeriodEstSpecified = true,
                    estimateSpreadCode                 = "A",
                    budgetCode                         = "RAB"
                };
                ProjectEstimateServiceResult projectEstimateServiceResult = projectEstimateService.update(projectEstimateOperationContext, projectEstimateDTO);
                //ProjectEstimateServiceResult[] projectEstimateServiceResults = projectEstimateService.multipleUpdate(projectEstimateOperationContext, projectEstimateDTOs);

                //ProjectEstimateServiceResult projectEstimateServiceResult = projectEstimateServiceResults[0];

                Error[] errors = projectEstimateServiceResult.errors;

                if (errors.Length > 0)
                {
                    result = errors[0].messageText.Trim();
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Example #14
0
        protected GetTaxRequest BuildGetTaxRequestWithFRTCate <TLineAmt, TLineQty, TDocDiscount>(SOOrder order, string docCode, string debugMethodName)
            where TLineAmt : IBqlField
            where TLineQty : IBqlField
            where TDocDiscount : IBqlField
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            Debug.Indent();

            if (order == null)
            {
                throw new PXArgumentException(nameof(order));
            }

            Customer cust = (Customer)Base.customer.View.SelectSingleBound(new object[] { order });
            Location loc  = (Location)Base.location.View.SelectSingleBound(new object[] { order });

            IAddressBase fromAddress = GetFromAddress(order);
            IAddressBase toAddress   = GetToAddress(order);

            Debug.Print($"{DateTime.Now.TimeOfDay} Select Customer, Location, Addresses in {sw.ElapsedMilliseconds} millisec");

            if (fromAddress == null)
            {
                throw new PXException(Messages.FailedGetFromAddressSO);
            }

            if (toAddress == null)
            {
                throw new PXException(Messages.FailedGetToAddressSO);
            }

            GetTaxRequest request = new GetTaxRequest();

            request.CompanyCode        = Base1.CompanyCodeFromBranch(order.TaxZoneID, order.BranchID);
            request.CurrencyCode       = order.CuryID;
            request.CustomerCode       = cust.AcctCD;
            request.TaxRegistrationID  = loc?.TaxRegistrationID;
            request.OriginAddress      = AddressConverter.ConvertTaxAddress(fromAddress);
            request.DestinationAddress = AddressConverter.ConvertTaxAddress(toAddress);
            request.DocCode            = docCode;
            request.DocDate            = order.OrderDate.GetValueOrDefault();
            request.LocationCode       = GetExternalTaxProviderLocationCode <SOLine, SOLine.FK.Order.SameAsCurrent, SOLine.siteID>(order);

            Sign docSign = Sign.Plus;

            request.CustomerUsageType = order.AvalaraCustomerUsageType;

            if (!string.IsNullOrEmpty(order.ExternalTaxExemptionNumber))
            {
                request.ExemptionNo = order.ExternalTaxExemptionNumber;
            }

            SOOrderType orderType = (SOOrderType)Base.soordertype.View.SelectSingleBound(new object[] { order });

            if (orderType.DefaultOperation == SOOperation.Receipt)
            {
                request.DocType = TaxDocumentType.ReturnOrder;
                docSign         = Sign.Minus;
            }
            else
            {
                request.DocType = TaxDocumentType.SalesOrder;
            }

            PXSelectBase <SOLine> select = new PXSelectJoin <SOLine, LeftJoin <InventoryItem, On <SOLine.FK.InventoryItem>,
                                                                               LeftJoin <Account, On <Account.accountID, Equal <SOLine.salesAcctID> > > >,
                                                             Where <SOLine.orderType, Equal <Current <SOOrder.orderType> >,
                                                                    And <SOLine.orderNbr, Equal <Current <SOOrder.orderNbr> > > >,
                                                             OrderBy <Asc <SOLine.orderType,
                                                                           Asc <SOLine.orderNbr,
                                                                                Asc <SOLine.lineNbr> > > > >(Base);

            PXCache documentCache = Base.Caches[typeof(SOOrder)];

            request.Discount = (documentCache.GetValue <TDocDiscount>(order) as decimal?) ?? 0m;

            Stopwatch sw2 = new Stopwatch();

            sw2.Start();

            // Add additional condition to skip the calculation including the freight amount. Per YJ's request.
            if (order.CuryFreightTot > 0 && !string.IsNullOrEmpty(order.FreightTaxCategoryID))
            {
                var line = new TaxCartItem();
                line.Index              = short.MinValue;
                line.Quantity           = 1;
                line.UOM                = "EA";
                line.Amount             = docSign * order.CuryFreightTot.GetValueOrDefault();
                line.Description        = PXMessages.LocalizeNoPrefix(Messages.FreightDesc);
                line.DestinationAddress = request.DestinationAddress;
                line.OriginAddress      = request.OriginAddress;
                line.ItemCode           = "N/A";
                line.Discounted         = false;
                line.TaxCode            = order.FreightTaxCategoryID;

                request.CartItems.Add(line);
            }

            PXCache lineCache = Base.Caches[typeof(SOLine)];

            foreach (PXResult <SOLine, InventoryItem, Account> res in select.View.SelectMultiBound(new object[] { order }))
            {
                SOLine        tran             = (SOLine)res;
                InventoryItem item             = (InventoryItem)res;
                Account       salesAccount     = (Account)res;
                bool          lineIsDiscounted = request.Discount > 0m &&
                                                 ((tran.DocumentDiscountRate ?? 1m) != 1m || (tran.GroupDiscountRate ?? 1m) != 1m);

                var line = new TaxCartItem();
                line.Index = tran.LineNbr ?? 0;

                decimal lineAmount = (lineCache.GetValue <TLineAmt>(tran) as decimal?) ?? 0m;
                decimal lineQty    = (lineCache.GetValue <TLineQty>(tran) as decimal?) ?? 0m;

                line.Amount = orderType.DefaultOperation != tran.Operation
                                        ? Sign.Minus * docSign * lineAmount
                                        : docSign * lineAmount;

                line.Description        = tran.TranDesc;
                line.DestinationAddress = AddressConverter.ConvertTaxAddress(Base1.GetToAddress(order, tran));
                line.OriginAddress      = AddressConverter.ConvertTaxAddress(Base1.GetFromAddress(order, tran));
                line.ItemCode           = item.InventoryCD;
                line.Quantity           = Math.Abs(lineQty);
                line.UOM        = tran.UOM;
                line.Discounted = lineIsDiscounted;
                line.RevAcct    = salesAccount.AccountCD;

                line.TaxCode           = tran.TaxCategoryID;
                line.CustomerUsageType = tran.AvalaraCustomerUsageType;

                if (tran.Operation == SOOperation.Receipt && tran.InvoiceDate != null)
                {
                    line.TaxOverride.Reason          = Messages.ReturnReason;
                    line.TaxOverride.TaxDate         = tran.InvoiceDate.Value;
                    line.TaxOverride.TaxOverrideType = TaxOverrideType.TaxDate;
                }

                request.CartItems.Add(line);
            }

            sw2.Stop();
            Debug.Print($"{DateTime.Now.TimeOfDay} Select detail lines in {sw2.ElapsedMilliseconds} millisec.");

            Debug.Unindent();
            sw.Stop();
            Debug.Print($"{DateTime.Now.TimeOfDay} {debugMethodName}() in {sw.ElapsedMilliseconds} millisec.");

            return(request);
        }
Example #15
0
 public GetTaxRequest BuildGetTaxRequestOpen(SOOrder order, BuildGetTaxRequestOpenDelegate baseMethod) =>
 BuildGetTaxRequestWithFRTCate <SOLine.curyOpenAmt, SOLine.openQty, SOOrder.curyOpenDiscTotal>(order, $"SO.{order.OrderType}.{order.OrderNbr}", nameof(BuildGetTaxRequestOpen));
Example #16
0
        string modifyProject(SOOrder sOOrder)
        {
            int?customerSalesAcctId;
            int?customerSalesSubId;
            int?cogsAcctId;
            int?cogsSubId;
            int?invtAcctId;
            int?invtSubId;
            int?cARAccountID;

            string cogsAcctCd      = "";
            string cogsSubCd       = "";
            string invtAcctCd      = "";
            string invtSubCd       = "";
            string custSalesAcctCD = "";
            string custSalesSubCD  = "";
            string cARAccountCD    = string.Empty;
            string custCD          = "";
            string transID         = "";

            string result = "";

            try
            {
                ClientConversation.authenticate(userName, password);
                TransactionService transactionService = new TransactionService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}TransactionService"
                };
                PLNSC.TransactionRef.OperationContext transContext = new PLNSC.TransactionRef.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance
                };

                transID = transactionService.begin(transContext);

                BAccount2 customer = PXSelect <BAccount2,
                                               Where <BAccount2.bAccountID, Equal <Required <BAccount2.bAccountID> >,
                                                      And <BAccount2.defLocationID, Equal <Required <BAccount2.defLocationID> >,
                                                           And <BAccount.type, Equal <Required <BAccount.type> > > > > > .Select(Base, sOOrder.CustomerID, sOOrder.CustomerLocationID, "CU");

                Location custLocation = PXSelect <Location,
                                                  Where <Location.bAccountID, Equal <Required <Location.bAccountID> >,
                                                         And <Location.locationID, Equal <Required <Location.locationID> > > > > .Select(Base, sOOrder.CustomerID, sOOrder.CustomerLocationID);

                customerSalesAcctId = custLocation.CSalesAcctID;
                customerSalesSubId  = custLocation.CSalesSubID;
                cARAccountID        = custLocation.CARAccountID;

                Account custSalesAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, customerSalesAcctId);

                Account custARAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, cARAccountID);

                Sub custSalesSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, customerSalesSubId);

                custSalesAcctCD = custSalesAccount.AccountCD;
                custSalesSubCD  = custSalesSub.SubCD;
                cARAccountCD    = custARAccount.AccountCD;
                custCD          = customer.AcctCD.Trim();

                foreach (SOLine soLine in Base.Transactions.Select(sOOrder.OrderNbr))
                {
                    InventoryItem inventoryItem = PXSelect <InventoryItem,
                                                            Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, soLine.InventoryID);

                    cogsAcctId = inventoryItem.COGSAcctID;
                    cogsSubId  = inventoryItem.COGSSubID;
                    invtAcctId = inventoryItem.InvtAcctID;
                    invtSubId  = inventoryItem.InvtSubID;

                    if (cogsAcctId == null && cogsSubId == null)
                    {
                        throw new PXException(CustomMessage.COGSAccountEmpty);
                    }

                    Account itemInvtAcct = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, invtAcctId);

                    Sub itemInvtSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, invtSubId);

                    Account invtCogsAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, cogsAcctId);

                    Sub invtCogsSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, cogsSubId);

                    cogsAcctCd = invtCogsAccount.AccountCD;
                    cogsSubCd  = invtCogsSub.SubCD;
                    invtAcctCd = itemInvtAcct.AccountCD;
                    invtSubCd  = itemInvtSub.SubCD;

                    if (cogsAcctId != null && cogsSubId != null)
                    {
                        break;
                    }
                }

                EPEmployee ePEmployee = PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > .Select(Base, sOOrder.OwnerID);

                string   originatorId         = ePEmployee != null ? ePEmployee.AcctCD : "ADMIN";
                string   stockItemAccount     = custSalesSubCD.Substring(0, 11).Trim() + cogsSubCd.Substring(11, 4).Trim(); // + cogsAcctCd.Trim();
                string   nonStockItemAccount  = cogsSubCd.Trim();                                                           // + cogsAcctCd.Trim();
                string   itemInventoryAccount = invtSubCd.Trim() + invtAcctCd.Trim();
                DateTime actStartDate         = sOOrder.OrderDate ?? DateTime.Now;
                string   raisedDate           = actStartDate.ToString("yyyyMMdd");
                string   planFinishDate       = (sOOrder.RequestDate ?? actStartDate.AddDays(60)).ToString("yyyyMMdd");

                try
                {
                    //ClientConversation.authenticate(userName, password);
                    PLNSC.ProjectService.OperationContext projectOperationContext = new PLNSC.ProjectService.OperationContext()
                    {
                        district     = districtCode,
                        position     = positionID,
                        maxInstances = maxInstance,
                        transaction  = transID
                    };

                    ProjectService projectService = new ProjectService()
                    {
                        Timeout = sessionTimeout,
                        Url     = $"{urlPrefix(dbName)}ProjectService"
                    };

                    ProjectServiceModifyRequestDTO projectRequest = new ProjectServiceModifyRequestDTO()
                    {
                        districtCode       = "SC01",
                        projectNo          = sOOrder.OrderNbr,
                        projDesc           = sOOrder.OrderDesc,
                        originatorId       = originatorId,
                        raisedDate         = raisedDate,
                        planFinDate        = planFinishDate,
                        accountCode        = cARAccountCD,
                        accountCodeEnabled = true
                    };

                    ProjectServiceModifyReplyDTO             projectReply       = projectService.modify(projectOperationContext, projectRequest);
                    PLNSC.ProjectService.WarningMessageDTO[] warningMessageDTOs = projectReply.warningsAndInformation;

                    if (warningMessageDTOs.Length > 0)
                    {
                        result = warningMessageDTOs[0].message;
                        transContext.transaction = transID;
                        transactionService.rollback(transContext);
                    }
                    else
                    {
                        result = "OK";
                        transContext.transaction = transID;
                        transactionService.commit(transContext);
                    }
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Example #17
0
        string recordProjectActuals(SOOrder sOOrder)
        {
            string result  = "";
            string transID = "";

            try
            {
                ClientConversation.authenticate(userName, password);
                TransactionService transactionService = new TransactionService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}TransactionService"
                };
                PLNSC.TransactionRef.OperationContext transContext = new PLNSC.TransactionRef.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance
                };

                transID = transactionService.begin(transContext);

                string raisedDate = (sOOrder.OrderDate ?? DateTime.Now).ToString("yyyyMMdd");

                PLNSC.ProjectService.OperationContext projectOperationContext = new PLNSC.ProjectService.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance,
                    transaction  = transID
                };

                ProjectService projectService = new ProjectService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}ProjectService"
                };

                ProjectServiceActualsRequestDTO projectServiceActualsRequestDTO = new ProjectServiceActualsRequestDTO()
                {
                    actualStrDate = raisedDate,
                    districtCode  = "SC01",
                    projectNo     = sOOrder.OrderNbr.Trim()
                };

                ProjectServiceActualsReplyDTO            projectServiceActualsReplyDTO = projectService.actuals(projectOperationContext, projectServiceActualsRequestDTO);
                PLNSC.ProjectService.WarningMessageDTO[] actualErrors = projectServiceActualsReplyDTO.warningsAndInformation;
                if (actualErrors.Length > 0)
                {
                    result = actualErrors[0].message;
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Example #18
0
        string authoriseProject(SOOrder sOOrder)
        {
            string result  = "";
            string transID = "";

            try
            {
                ClientConversation.authenticate(userName, password);
                TransactionService transactionService = new TransactionService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}TransactionService"
                };
                PLNSC.TransactionRef.OperationContext transContext = new PLNSC.TransactionRef.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance
                };

                transID = transactionService.begin(transContext);

                PLNSC.ProjectService.OperationContext projectOperationContext = new PLNSC.ProjectService.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance,
                    transaction  = transID
                };

                ProjectService projectService = new ProjectService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}ProjectService"
                };

                ProjectServiceAuthoriseRequestDTO projectServiceAuthoriseRequestDTO = new ProjectServiceAuthoriseRequestDTO()
                {
                    authsdBy  = "ADMIN",
                    projectNo = sOOrder.OrderNbr.Trim()
                };

                ProjectServiceAuthoriseReplyDTO projectServiceAuthoriseReplyDTO = projectService.authorise(projectOperationContext, projectServiceAuthoriseRequestDTO);

                PLNSC.ProjectService.WarningMessageDTO[] authErrors = projectServiceAuthoriseReplyDTO.warningsAndInformation;

                if (authErrors.Length > 0)
                {
                    result = authErrors[0].message;
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Example #19
0
        string modifyProjectRefCodes(SOOrder sOOrder)
        {
            string transID = "";
            string result  = "";

            try
            {
                ClientConversation.authenticate(userName, password);
                TransactionService transactionService = new TransactionService()
                {
                    Timeout = sessionTimeout,
                    Url     = $"{urlPrefix(dbName)}TransactionService"
                };
                PLNSC.TransactionRef.OperationContext transContext = new PLNSC.TransactionRef.OperationContext()
                {
                    district     = districtCode,
                    position     = positionID,
                    maxInstances = maxInstance
                };

                transID = transactionService.begin(transContext);

                BAccount2 customer = PXSelect <BAccount2,
                                               Where <BAccount2.bAccountID, Equal <Required <BAccount2.bAccountID> >,
                                                      And <BAccount2.defLocationID, Equal <Required <BAccount2.defLocationID> >,
                                                           And <BAccount.type, Equal <Required <BAccount.type> > > > > > .Select(Base, sOOrder.CustomerID, sOOrder.CustomerLocationID, "CU");

                string custCD = customer.AcctCD.Trim();

                PLNSC.RefCodesRef.OperationContext refCodesOperation = new PLNSC.RefCodesRef.OperationContext()
                {
                    district     = transContext.district,
                    position     = transContext.position,
                    maxInstances = transContext.maxInstances
                };

                RefCodesService refCodesService = new RefCodesService()
                {
                    Timeout = transactionService.Timeout,
                    Url     = $"{urlPrefix(dbName)}RefCodesService"
                };

                RefCodesServiceModifyRequestDTO refCodesServiceModifyRequestDTO = new RefCodesServiceModifyRequestDTO()
                {
                    entityType  = "PRJ",
                    entityValue = transContext.district.Trim() + sOOrder.OrderNbr.Trim(),
                    refNo       = "001",
                    seqNum      = "001",
                    refCode     = sOOrder.CustomerOrderNbr.Trim()
                };

                RefCodesServiceModifyReplyDTO         refCodesServiceModifyReplyDTO = refCodesService.modify(refCodesOperation, refCodesServiceModifyRequestDTO);
                PLNSC.RefCodesRef.WarningMessageDTO[] refCodesErrors = refCodesServiceModifyReplyDTO.warningsAndInformation;
                if (refCodesErrors.Length > 0)
                {
                    result = refCodesErrors[0].message;
                    transactionService.rollback(transContext);
                }
                else
                {
                    if (sOOrder.CustomerID != null)
                    {
                        RefCodesServiceModifyRequestDTO refCodesServiceModifyRequestDTO2 = new RefCodesServiceModifyRequestDTO()
                        {
                            entityType  = "PRJ",
                            entityValue = transContext.district.Trim() + sOOrder.OrderNbr.Trim(),
                            refNo       = "002",
                            seqNum      = "001",
                            refCode     = custCD
                        };

                        RefCodesServiceModifyReplyDTO         refCodesServiceModifyReplyDTO2 = refCodesService.modify(refCodesOperation, refCodesServiceModifyRequestDTO2);
                        PLNSC.RefCodesRef.WarningMessageDTO[] refCodesErrors2 = refCodesServiceModifyReplyDTO2.warningsAndInformation;
                        if (refCodesErrors2.Length > 0)
                        {
                            result = refCodesErrors2[0].message;
                            transContext.transaction = transID;
                            transactionService.rollback(transContext);
                        }
                        else
                        {
                            result = "OK";
                            transContext.transaction = transID;
                            transactionService.commit(transContext);
                        }
                    }
                    else
                    {
                        result = "OK";
                        transContext.transaction = transID;
                        transactionService.commit(transContext);
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Example #20
0
        protected string GetExternalTaxProviderLocationCode <TLine, TLineDocFK, TLineSiteID>(SOOrder document)
            where TLine : class, IBqlTable, new()
            where TLineDocFK : IParameterizedForeignKeyBetween <TLine, SOOrder>, new()
            where TLineSiteID : IBqlField
        {
            TLine lineWithSite = PXSelect <TLine, Where2 <TLineDocFK, And <TLineSiteID, IsNotNull> > > .SelectSingleBound(Base, new[] { document });

            if (lineWithSite == null)
            {
                return(null);
            }

            var site = PX.Objects.IN.INSite.PK.Find(Base, (int?)Base.Caches <TLine>().GetValue <TLineSiteID>(lineWithSite));

            return(site?.SiteCD);
        }
Example #21
0
 public GetTaxRequest BuildGetTaxRequest(SOOrder order, BuildGetTaxRequestDelegate baseMethod) =>
 BuildGetTaxRequestWithFRTCate <SOLine.curyLineAmt, SOLine.orderQty, SOOrder.curyDiscTot>(order, $"SO.{order.OrderType}.{order.OrderNbr}", nameof(BuildGetTaxRequest));
        protected virtual void SOOrderType_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            SOOrderType ordertype = (SOOrderType)e.Row;

            SOOrderType link = references.SelectWindowed(0, 1, ordertype.OrderType);
            bool        isTemplateUpdatable = ordertype.IsSystem == false && link == null && ordertype.OrderType != null;

            PXUIFieldAttribute.SetEnabled <SOOrderType.template>(sender, e.Row, isTemplateUpdatable);

            SOOrderTypeOperation def = this.defaultOperation.Select(ordertype.OrderType, ordertype.DefaultOperation);

            if (def == null)
            {
                def = new SOOrderTypeOperation();
            }
            PXUIFieldAttribute.SetEnabled <SOOrderType.billSeparately>(sender, e.Row, ordertype.ARDocType != ARDocType.NoUpdate);
            PXUIFieldAttribute.SetEnabled <SOOrderType.invoiceNumberingID>(sender, e.Row, ordertype.ARDocType != ARDocType.NoUpdate);


            if (ordertype.ARDocType == ARDocType.NoUpdate)
            {
                INTranType.CustomListAttribute listattr = new INTranType.SONonARListAttribute();
                PXStringListAttribute.SetList <SOOrderTypeOperation.iNDocType>(this.operations.Cache, null, listattr.AllowedValues, listattr.AllowedLabels);
            }
            else
            {
                INTranType.CustomListAttribute listattr = new INTranType.SOListAttribute();
                PXStringListAttribute.SetList <SOOrderTypeOperation.iNDocType>(this.operations.Cache, null, listattr.AllowedValues, listattr.AllowedLabels);
            }

            SOOrder order =
                PXSelectJoin <SOOrder,
                              InnerJoin <INItemPlan, On <INItemPlan.refNoteID, Equal <SOOrder.noteID> > >,
                              Where <SOOrder.orderType, Equal <Required <SOOrder.orderType> >,
                                     And <Where <INItemPlan.planType, Equal <INPlanConstants.plan60>,
                                                 Or <INItemPlan.planType, Equal <INPlanConstants.plan66>,
                                                     Or <INItemPlan.planType, Equal <INPlanConstants.plan68> > > > > > >
                .SelectWindowed(this, 0, 1, ordertype.OrderType);

            //PXUIFieldAttribute.SetEnabled<SOOrderType.requireLocation>(sender, ordertype, order == null && isTemplateUpdatable);
            //PXUIFieldAttribute.SetEnabled<SOOrderType.requireLocation>(sender, e.Row, def.INDocType != INTranType.NoUpdate && isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.requireShipping>(sender, e.Row, def.INDocType != INTranType.NoUpdate && def.INDocType != INTranType.Transfer && isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.aRDocType>(sender, e.Row, def.INDocType != INTranType.Transfer && isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.behavior>(sender, e.Row, isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.defaultOperation>(sender, e.Row, isTemplateUpdatable && ordertype.Behavior == SOBehavior.RM);
            PXUIFieldAttribute.SetVisible <SOOrderTypeOperation.active>(operations.Cache, null, ordertype.Behavior == SOBehavior.RM || ordertype.Behavior == SOBehavior.IN);
            PXUIFieldAttribute.SetVisible <SOOrderTypeOperation.autoCreateIssueLine>(operations.Cache, null, ordertype.Behavior == SOBehavior.RM);

            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLineNotesToInvoiceOnlyNS>(sender, ordertype, ordertype.CopyLineNotesToInvoice == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLineFilesToInvoiceOnlyNS>(sender, ordertype, ordertype.CopyLineFilesToInvoice == true);

            PXUIFieldAttribute.SetEnabled <SOOrderType.requireAllocation>(sender, ordertype, ordertype.RequireShipping == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.requireLotSerial>(sender, ordertype, ordertype.RequireShipping == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLotSerialFromShipment>(sender, ordertype, ordertype.RequireShipping == true);

            PXUIFieldAttribute.SetEnabled <SOOrderType.useDiscountSubFromSalesSub>(sender, ordertype, ordertype.PostLineDiscSeparately == true);

            PXUIFieldAttribute.SetVisible <SOOrderType.recalculateDiscOnPartialShipment>(sender, e.Row, PXAccess.FeatureInstalled <FeaturesSet.inventory>() && PXAccess.FeatureInstalled <FeaturesSet.customerDiscounts>());

            bool allowUserDefinedOrderTypes = PXAccess.FeatureInstalled <FeaturesSet.userDefinedOrderTypes>();

            soordertype.AllowInsert      = allowUserDefinedOrderTypes;
            currentordertype.AllowInsert = allowUserDefinedOrderTypes;
            bool allowUpdateOrderTypes = allowUserDefinedOrderTypes || sender.GetStatus(e.Row) != PXEntryStatus.Inserted;

            soordertype.AllowUpdate      = allowUpdateOrderTypes;
            currentordertype.AllowUpdate = allowUpdateOrderTypes;

            PXUIFieldAttribute.SetVisible <SOOrderType.commitmentTracking>(sender, e.Row, CommitmentTracking);
            if (!PXAccess.FeatureInstalled <FeaturesSet.inventory>())
            {
                PXDefaultAttribute.SetDefault <SOOrderType.behavior>(sender, SOBehavior.IN);
                PXStringListAttribute.SetList <SOOrderType.behavior>(sender, null, new string[] { SOBehavior.IN, SOBehavior.QT, SOBehavior.CM },
                                                                     new string[] { Messages.INName, Messages.QTName, Messages.CMName });
            }
        }
Example #23
0
 public GetTaxRequest BuildGetTaxRequestUnbilled(SOOrder order, BuildGetTaxRequestUnbilledDelegate baseMethod) =>
 BuildGetTaxRequestWithFRTCate <SOLine.curyUnbilledAmt, SOLine.unbilledQty, SOOrder.curyUnbilledDiscTotal>(order, $"{order.OrderType}.{order.OrderNbr}.Open", nameof(BuildGetTaxRequestUnbilled));
Example #24
0
        public static void CreateShipment(System.Collections.Generic.List <SOShipmentPlan> list)
        {
            int num1 = 0;

            try
            {
                SOShipmentEntry instance = PXGraph.CreateInstance <SOShipmentEntry>();
                DocumentList <PX.Objects.SO.SOShipment> list1 = new DocumentList <PX.Objects.SO.SOShipment>((PXGraph)instance);
                Dictionary <long, PXResult <SOShipmentPlan, PX.Objects.SO.SOOrder> > dictionary = new Dictionary <long, PXResult <SOShipmentPlan, PX.Objects.SO.SOOrder> >();
                SOShipmentPlan        soShipmentPlan1 = new SOShipmentPlan();
                PX.Objects.SO.SOOrder soOrder         = new PX.Objects.SO.SOOrder();
                for (int index = 0; index < list.Count; ++index)
                {
                    SOShipmentPlan        i0 = list[index];
                    PX.Objects.SO.SOOrder i1 = SelectFrom <PX.Objects.SO.SOOrder> .Where <PX.Objects.SO.SOOrder.orderType.IsEqual <P.AsString>
                                                                                          .And <PX.Objects.SO.SOOrder.orderNbr.IsEqual <P.AsString> > > .View.Select((PXGraph)instance, (object)i0.OrderType, (object)i0.OrderNbr);

                    int?nullable1;
                    int?customerLocationId;
                    int?nullable2;
                    int num2;
                    if (num1 != 0)
                    {
                        int num3 = num1;
                        nullable1          = i1.CustomerID;
                        customerLocationId = i1.CustomerLocationID;
                        nullable2          = nullable1.HasValue & customerLocationId.HasValue ? new int?(nullable1.GetValueOrDefault() + customerLocationId.GetValueOrDefault()) : new int?();
                        int valueOrDefault = nullable2.GetValueOrDefault();
                        num2 = num3 == valueOrDefault & nullable2.HasValue ? 1 : 0;
                    }
                    else
                    {
                        num2 = 1;
                    }
                    if (num2 == 0)
                    {
                        throw new PXException("Please Only Select The Same Customer ID & Location For One Shipment");
                    }
                    nullable2          = i1.CustomerID;
                    customerLocationId = i1.CustomerLocationID;
                    int?nullable3;
                    if (!(nullable2.HasValue & customerLocationId.HasValue))
                    {
                        nullable1 = new int?();
                        nullable3 = nullable1;
                    }
                    else
                    {
                        nullable3 = new int?(nullable2.GetValueOrDefault() + customerLocationId.GetValueOrDefault());
                    }
                    nullable1 = nullable3;
                    num1      = nullable1.Value;
                    dictionary.Add(i0.PlanID.Value, new PXResult <SOShipmentPlan, PX.Objects.SO.SOOrder>(i0, i1));
                }
                PX.Objects.SO.SOOrder order = new PX.Objects.SO.SOOrder();
                foreach (PXResult <SOShipmentPlan, PX.Objects.SO.SOOrder> pxResult in dictionary.Values)
                {
                    SOShipmentPlan soShipmentPlan2 = (SOShipmentPlan)pxResult;
                    if (order.OrderNbr != pxResult.GetItem <PX.Objects.SO.SOOrder>().OrderNbr)
                    {
                        order = (PX.Objects.SO.SOOrder)pxResult;
                        instance.GetExtension <SOShipmentEntry_Extension>().CreateShipment2(order, soShipmentPlan2.SiteID, soShipmentPlan2.PlanDate, new bool?(false), "I", list1, list);
                    }
                }
                throw new PXPopupRedirectException((PXGraph)instance, "Shipment <*> is created", true);
            }
            catch (Exception ex)
            {
                if (ex.Message.Equals("Shipment <*> is created"))
                {
                    PXProcessing.SetProcessed();
                }
                else
                {
                    PXProcessing.SetError(ex);
                }
                throw;
            }
        }
Example #25
0
 protected static void GenerateData(FLXSupplyDemandProc graph, FLXSupplyDemand record)
 {
     try
     {
         graph.SupplyDemandProc.Delete(record);
         graph.Save.Press();
         if (graph.SupplyDemandProc.Select().Count == 0)
         {
             int num = 1;
             foreach (PXResult <SOLine, PX.Objects.SO.SOOrder> pxResult in SelectFrom <SOLine> .InnerJoin <PX.Objects.SO.SOOrder> .On <SOLine.orderType.IsEqual <PX.Objects.SO.SOOrder.orderType>
                                                                                                                                       .And <SOLine.orderNbr.IsEqual <PX.Objects.SO.SOOrder.orderNbr> > >
                      .Where <SOLine.openQty.IsGreater <decimal0>
                              .And <Where <PX.Objects.SO.SOOrder.orderType.IsEqual <P.AsString>
                                           .Or <PX.Objects.SO.SOOrder.orderType.IsEqual <P.AsString>
                                                .Or <PX.Objects.SO.SOOrder.orderType.IsEqual <P.AsString> > > > > > .View.ReadOnly.Select((PXGraph)graph, (object)"SO", (object)"SF", (object)"SS"))
             {
                 PX.Objects.SO.SOOrder soOrder   = (PX.Objects.SO.SOOrder)pxResult;
                 SOLine          soLine          = (SOLine)pxResult;
                 SOLineExt       extension       = soLine.GetExtension <SOLineExt>();
                 FLXSupplyDemand flxSupplyDemand = new FLXSupplyDemand()
                 {
                     LineNbr       = new int?(num++),
                     InventoryID   = soLine.InventoryID,
                     Type          = "D",
                     OpenQty       = soLine.OpenQty,
                     OrderDate     = soLine.ShipDate,
                     SOOrderType   = soLine.OrderType,
                     SOOrderNbr    = soLine.OrderNbr,
                     SOOrderStatus = soOrder.Status,
                     EndCustomerID = extension.UsrEndCustomerID,
                     NonStockMPN   = extension.UsrNonStockItem,
                     ProjectNbr    = extension.UsrProjectNbr
                 };
                 graph.SupplyDemandProc.Insert(flxSupplyDemand);
             }
             foreach (PXResult <POLine, POOrder> pxResult in SelectFrom <POLine> .InnerJoin <POOrder> .On <POLine.orderType.IsEqual <POOrder.orderType>
                                                                                                           .And <POLine.orderNbr.IsEqual <POOrder.orderNbr> > >
                      .Where <POLine.openQty.IsGreater <decimal0> > .View.ReadOnly.Select((PXGraph)graph))
             {
                 POOrder         poOrder         = (POOrder)pxResult;
                 POLine          poLine          = (POLine)pxResult;
                 POLineExt       extension       = poLine.GetExtension <POLineExt>();
                 FLXSupplyDemand flxSupplyDemand = new FLXSupplyDemand()
                 {
                     LineNbr       = new int?(num++),
                     InventoryID   = poLine.InventoryID,
                     Type          = "S",
                     OpenQty       = poLine.OpenQty,
                     OrderDate     = poLine.RequestedDate,
                     POOrderType   = poLine.OrderType,
                     POOrderNbr    = poLine.OrderNbr,
                     POOrderStatus = poOrder.Status,
                     EndCustomerID = extension.UsrEndCustomerID,
                     NonStockMPN   = extension.UsrNonStockItem,
                     ProjectNbr    = extension.UsrProjectNbr
                 };
                 graph.SupplyDemandProc.Insert(flxSupplyDemand);
             }
         }
         graph.Save.Press();
     }
     catch (Exception ex)
     {
         PXProcessing.SetError <FLXSupplyDemand>(ex);
         throw;
     }
 }
Example #26
0
        public virtual IEnumerable createDO(SOOrder sOOrder)
        {
            bool       modifyFlag = false;
            SOOrderExt sOOrderExt = sOOrder.GetExtension <SOOrderExt>();

            if (sOOrder.OrderNbr == null)
            {
                return(null);
            }

            try
            {
                ClientConversation.authenticate(userName, password);
                loggedIn = true;
            }
            catch (Exception ex)
            {
                loggedIn = false;
                throw new PXException(ex.Message);
            }

            if (loggedIn == true)
            {
                string createProjectResult = createProject(sOOrder);
                if (createProjectResult != "OK")
                {
                    if (createProjectResult.Trim().Contains("PROJECT ALREADY EXISTS"))
                    {
                        string modifyProjectResult = modifyProject(sOOrder);
                        modifyFlag = true;
                        if (modifyProjectResult != "OK")
                        {
                            throw new PXException(modifyProjectResult);
                        }
                    }
                    else
                    {
                        throw new PXException(createProjectResult);
                    }
                }

                if (!modifyFlag)
                {
                    string authoriseProjectResult = authoriseProject(sOOrder);
                    if (authoriseProjectResult != "OK")
                    {
                        throw new PXException(authoriseProjectResult);
                    }
                }

                string modifyProjectRefCodesResult = modifyProjectRefCodes(sOOrder);
                if (modifyProjectRefCodesResult != "OK")
                {
                    throw new PXException(modifyProjectRefCodesResult);
                }

                string createProjectEstimateResult = createProjectEstimate(sOOrder);
                if (createProjectEstimateResult != "OK")
                {
                    throw new PXException(createProjectEstimateResult);
                }

                string recordProjectActualsResult = recordProjectActuals(sOOrder);
                if (recordProjectActualsResult != "OK")
                {
                    throw new PXException(recordProjectActualsResult);
                }
            }
            return(null);
        }
        public virtual IEnumerable orders()
        {
            PXUIFieldAttribute.SetDisplayName <SOShipment.shipVia_Carrier_description>(Caches[typeof(SOShipment)], Messages.CarrierDescr);
            PXUIFieldAttribute.SetDisplayName <SOShipment.siteID_INSite_descr>(Caches[typeof(SOShipment)], Messages.SiteDescr);
            PXUIFieldAttribute.SetDisplayName <SOShipment.customerID>(Caches[typeof(SOShipment)], Messages.CustomerID);

            SOShipmentFilter filter = Filter.Current;

            if (filter.Action == "<SELECT>")
            {
                yield break;
            }

            string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID");

            if (_ActionChanged)
            {
                Orders.Cache.Clear();
            }

            foreach (SOShipment order in Orders.Cache.Updated)
            {
                yield return(order);
            }

            PXSelectBase cmd;

            switch (actionID)
            {
            case "2":
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                         InnerJoin <SOShipLine, On <SOShipLine.shipmentNbr, Equal <SOShipment.shipmentNbr> >,
                                                                    InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOShipLine.origOrderType>, And <SOOrder.orderNbr, Equal <SOShipLine.origOrderNbr> > >,
                                                                               InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOShipLine.origOrderType> >,
                                                                                          InnerJoin <SOOrderTypeOperation,
                                                                                                     On <SOOrderTypeOperation.orderType, Equal <SOShipLine.origOrderType>,
                                                                                                         And <SOOrderTypeOperation.operation, Equal <SOShipment.operation> > >,
                                                                                                     InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                                                                LeftJoin <ARTran, On <ARTran.sOShipmentNbr, Equal <SOShipLine.shipmentNbr>, And <ARTran.sOShipmentType, NotEqual <SOShipmentType.dropShip>, And <ARTran.sOShipmentLineNbr, Equal <SOShipLine.lineNbr> > > > > > > > > > >,
                                               Where <SOShipment.confirmed, Equal <boolTrue>,
                                                      And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                           And <ARTran.refNbr, IsNull,
                                                                And <Match <INSite, Current <AccessInfo.userName> > > > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.insurance,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            case "3":
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                         InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                               InnerJoin <SOShipLine, On <SOShipLine.shipmentType, Equal <SOOrderShipment.shipmentType>, And <SOShipLine.shipmentNbr, Equal <SOOrderShipment.shipmentNbr>, And <SOShipLine.origOrderType, Equal <SOOrderShipment.orderType>, And <SOShipLine.origOrderNbr, Equal <SOOrderShipment.orderNbr> > > > >,
                                                                                          InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOShipLine.origOrderType>, And <SOOrder.orderNbr, Equal <SOShipLine.origOrderNbr> > >,
                                                                                                     InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> > > > > > > >,
                                               Where <SOShipment.confirmed, Equal <boolTrue>,
                                                      And <SOOrderShipment.invtRefNbr, IsNull,
                                                           And <SOShipLine.lineType, Equal <SOLineType.inventory>,
                                                                And <SOOrderType.iNDocType, NotEqual <INTranType.noUpdate>,
                                                                     And <Match <INSite, Current <AccessInfo.userName> > > > > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            case "6":
                cmd = new PXSelectJoinGroupBy <POReceipt,
                                               CrossJoin <SOOrder,
                                                          InnerJoin <POReceiptLine, On <POReceiptLine.receiptNbr, Equal <POReceipt.receiptNbr> >,
                                                                     InnerJoin <SOLine, On <SOLine.pOType, Equal <POReceiptLine.pOType>, And <SOLine.pONbr, Equal <POReceiptLine.pONbr>, And <SOLine.pOLineNbr, Equal <POReceiptLine.pOLineNbr>, And <SOLine.orderType, Equal <SOOrder.orderType>, And <SOLine.orderNbr, Equal <SOOrder.orderNbr> > > > > >,
                                                                                LeftJoin <ARTran, On <ARTran.sOShipmentNbr, Equal <POReceiptLine.receiptNbr>, And <ARTran.sOShipmentType, Equal <SOShipmentType.dropShip>, And <ARTran.sOShipmentLineNbr, Equal <POReceiptLine.lineNbr>, And <ARTran.sOOrderType, Equal <SOLine.orderType>, And <ARTran.sOOrderNbr, Equal <SOLine.orderNbr>, And <ARTran.sOOrderLineNbr, Equal <SOLine.lineNbr> > > > > > >,
                                                                                          InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOLine.orderType> >,
                                                                                                     InnerJoin <SOOrderTypeOperation,
                                                                                                                On <SOOrderTypeOperation.orderType, Equal <SOOrder.orderType>,
                                                                                                                    And <SOOrderTypeOperation.operation, Equal <SOLine.operation> > > > > > > > >,
                                               Where <POReceipt.released, Equal <boolTrue>,
                                                      And2 <Where <POReceiptLine.lineType, Equal <POLineType.goodsForDropShip>, Or <POReceiptLine.lineType, Equal <POLineType.nonStockForDropShip> > >,
                                                            And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>,
                                                                 And <ARTran.refNbr, IsNull> > > >,
                                               Aggregate <GroupBy <POReceipt.receiptNbr,
                                                                   GroupBy <POReceipt.createdByID,
                                                                            GroupBy <POReceipt.lastModifiedByID,
                                                                                     GroupBy <POReceipt.released,
                                                                                              GroupBy <POReceipt.ownerID,
                                                                                                       GroupBy <POReceipt.hold> > > > > > > >(this);
                break;

            case "9":
                cmd = new PXSelectJoinGroupBy <SOShipment, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                      LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                                                InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                                           InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > > > > > >,
                                               Where <SOShipment.labelsPrinted, Equal <False>, And <Match <INSite, Current <AccessInfo.userName> > > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;

            default:
                cmd = new PXSelectJoinGroupBy <SOShipment,
                                               LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                         InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >,
                                                                    InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >,
                                                                               InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > > > > > >,
                                               Where <Match <INSite, Current <AccessInfo.userName> > >,
                                               Aggregate <GroupBy <SOShipment.shipmentNbr,
                                                                   GroupBy <SOShipment.createdByID,
                                                                            GroupBy <SOShipment.lastModifiedByID,
                                                                                     GroupBy <SOShipment.confirmed,
                                                                                              GroupBy <SOShipment.ownerID,
                                                                                                       GroupBy <SOShipment.released,
                                                                                                                GroupBy <SOShipment.hold,
                                                                                                                         GroupBy <SOShipment.resedential,
                                                                                                                                  GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                           GroupBy <SOShipment.groundCollect,
                                                                                                                                                    GroupBy <SOShipment.saturdayDelivery,
                                                                                                                                                             GroupBy <SOShipment.shippedViaCarrier,
                                                                                                                                                                      GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this);
                break;
            }

            if (typeof(PXSelectBase <SOShipment>).IsAssignableFrom(cmd.GetType()))
            {
                ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, LessEqual <Current <SOShipmentFilter.endDate> > > >();

                if (filter.SiteID != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.siteID, Equal <Current <SOShipmentFilter.siteID> > > >();
                }

                if (!string.IsNullOrEmpty(filter.CarrierPluginID))
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOShipmentFilter.carrierPluginID> > > >();
                }

                if (!string.IsNullOrEmpty(filter.ShipVia))
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipVia, Equal <Current <SOShipmentFilter.shipVia> > > >();
                }

                if (filter.StartDate != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >();
                }

                if (filter.CustomerID != null)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.customerID, Equal <Current <SOShipmentFilter.customerID> > > >();
                }

                if (actionID == "7" && filter.ShowPrinted == false)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.labelsPrinted, Equal <False> > >();
                }

                if (filter.PackagingType == SOShipmentFilter.Manual)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, Equal <True> > >();
                }
                else if (filter.PackagingType == SOShipmentFilter.Auto)
                {
                    ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, NotEqual <True> > >();
                }


                int startRow  = PXView.StartRow;
                int totalRows = 0;

                foreach (object res in ((PXSelectBase <SOShipment>)cmd).View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows))
                {
                    SOShipment order = PXResult.Unwrap <SOShipment>(res);
                    SOOrder    so    = PXResult.Unwrap <SOOrder>(res);

                    if (order.BilledOrderCntr + order.UnbilledOrderCntr + order.ReleasedOrderCntr == 1)
                    {
                        order.CustomerOrderNbr = so.CustomerOrderNbr;
                    }

                    object item;
                    if ((item = (SOShipment)Orders.Cache.Locate(order)) == null || Orders.Cache.GetStatus(item) == PXEntryStatus.Notchanged)
                    {
                        yield return(order);
                    }
                }
                PXView.StartRow = 0;
            }

            if (typeof(PXSelectBase <POReceipt>).IsAssignableFrom(cmd.GetType()))
            {
                ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, LessEqual <Current <SOShipmentFilter.endDate> > > >();

                /*
                 * if (filter.SiteID != null)
                 * {
                 *      ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.siteID, Equal<Current<SOShipmentFilter.siteID>>>>();
                 * }
                 *
                 * if (!string.IsNullOrEmpty(filter.ShipVia))
                 * {
                 *      ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.shipVia, Equal<Current<SOShipmentFilter.shipVia>>>>();
                 * }
                 */

                if (filter.StartDate != null)
                {
                    ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >();
                }

                foreach (PXResult <POReceipt, SOOrder> res in ((PXSelectBase <POReceipt>)cmd).Select())
                {
                    SOShipment order = res;

                    if ((order = (SOShipment)Orders.Cache.Locate(order)) == null)
                    {
                        Orders.Cache.SetStatus(order = res, PXEntryStatus.Held);
                        yield return(order);
                    }
                    else if (Orders.Cache.GetStatus(order) == PXEntryStatus.Notchanged || Orders.Cache.GetStatus(order) == PXEntryStatus.Held)
                    {
                        yield return(order);
                    }
                }
            }
            Orders.Cache.IsDirty = false;
        }
Example #28
0
        /// <summary> Gnerate CA/UK csv data for FBM </summary>
        public virtual (StringBuilder csvText, string OrderNbr) CombineCSVForFBM(SOOrder _soOrder, string csvType)
        {
            StringBuilder sb   = new StringBuilder();
            string        line = string.Empty;

            var inventoryItems = SelectFrom <InventoryItem> .View.Select(Base).RowCast <InventoryItem>().ToList();

            var soLines = SelectFrom <SOLine> .Where <SOLine.orderNbr.IsEqual <P.AsString>
                                                      .And <SOLine.orderType.IsEqual <P.AsString> > >
                          .OrderBy <SOLine.lineNbr.Asc>
                          .View.Select(Base, _soOrder.OrderNbr, _soOrder.OrderType).RowCast <SOLine>();

            SOShipmentContact shipContact = SOShipmentContact.PK.Find(Base, _soOrder.ShipContactID);
            SOShipmentAddress shipAddress = SOShipmentAddress.PK.Find(Base, _soOrder.ShipAddressID);

            if (!soLines.Any())
            {
                throw new Exception("Can not find SOLine");
            }

            #region Header
            line += "\"CustomerCode\";\"OrderRefNo\";\"SKUCode\";\"Qty\";\"DeliveryReqDate\";\"ReceiverName\";\"ReceiverCountry\";\"ReceiverCity\";\"ReceiverPostCode\";\"ReceiverAddress\";\"ReceiverPhone\";\"BatchNumber\";\"Notes\"";
            if (csvType == "P3PL")
            {
                line += ";\"CarrierCode\";\"CarrierServiceCode\"";
            }
            sb.AppendLine(line);
            #endregion

            #region Row

            foreach (var item in soLines)
            {
                var _cd = inventoryItems.Where(x => x.InventoryID == item.InventoryID).FirstOrDefault()?.InventoryCD;
                line = string.Empty;
                // CustomerCode
                line += $"\"IPEVOMAN\";";
                // OrderRefNo
                line += $"\"{_soOrder.CustomerOrderNbr}\";";
                // SKUCode
                line += $"\"{_cd}\";";
                // Qty
                line += $"\"{item?.ShippedQty}\";";
                // DeliveryReqDate
                line += $"\"{DateTime.Now.ToString("yyyyMMdd")}\";";
                // ReceiverName
                line += $"\"{shipContact.Attention}/{shipContact.FullName}\";";
                // ReceiverCountry
                line += $"\"{shipAddress.CountryID}\";";
                // ReceiverCity
                line += $"\"{shipAddress.City}\";";
                // ReceiverPostCode
                line += $"\"{shipAddress.PostalCode}\";";
                // ReceiverAddress
                line += $"\"{(shipAddress?.AddressLine1 + shipAddress?.AddressLine2).Replace(',','/')}\";";
                // ReceiverPhone
                line += $"\"{shipContact.Phone1}\";";
                // BatchNumber
                line += $"\"{_soOrder.OrderNbr}\";";
                // Notes
                var note = string.Empty;
                if (_cd == "5-883-4-01-00" || _cd == "5-884-4-01-00")
                {
                    note = "VZ-R(sku#5-883-4-01-00) or VZ-X(sku#5-884-4-01-00) please scan the serial number for us.";
                }
                if (_soOrder?.OrderType == "FM" && !string.IsNullOrEmpty(_soOrder?.OrderDesc))
                {
                    note = _soOrder?.OrderDesc;
                }
                line += $"\"{note}\"";
                if (csvType == "P3PL")
                {
                    line += $";\"{string.Empty}\";\"{string.Empty}\"";
                }
                sb.AppendLine(line);
            }

            #endregion

            return(sb, _soOrder.OrderNbr);
        }
        protected virtual void SOOrderType_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            SOOrderType ordertype = (SOOrderType)e.Row;

            SOOrderType link = references.SelectWindowed(0, 1, ordertype.OrderType);

            PXUIFieldAttribute.SetEnabled <SOOrderType.template>(sender, e.Row, link == null);

            bool isTemplateUpdatable =
                link == null && ordertype.OrderType != null &&
                (ordertype.OrderType == ordertype.Template || ordertype.Template == null);

            SOOrderTypeOperation def = this.defaultOperation.Select(ordertype.OrderType, ordertype.DefaultOperation);

            if (def == null)
            {
                def = new SOOrderTypeOperation();
            }
            PXUIFieldAttribute.SetEnabled <SOOrderType.billSeparately>(sender, e.Row, ordertype.ARDocType != ARDocType.NoUpdate);
            PXUIFieldAttribute.SetEnabled <SOOrderType.invoiceNumberingID>(sender, e.Row, ordertype.ARDocType != ARDocType.NoUpdate);


            if (ordertype.ARDocType == ARDocType.NoUpdate)
            {
                INTranType.CustomListAttribute listattr = new INTranType.SONonARListAttribute();
                PXStringListAttribute.SetList <SOOrderTypeOperation.iNDocType>(this.operations.Cache, null, listattr.AllowedValues, listattr.AllowedLabels);
            }
            else
            {
                INTranType.CustomListAttribute listattr = new INTranType.SOListAttribute();
                PXStringListAttribute.SetList <SOOrderTypeOperation.iNDocType>(this.operations.Cache, null, listattr.AllowedValues, listattr.AllowedLabels);
            }

            SOOrder order =
                PXSelectJoin <SOOrder,
                              InnerJoin <INItemPlan, On <INItemPlan.refNoteID, Equal <SOOrder.noteID> > >,
                              Where <SOOrder.orderType, Equal <Required <SOOrder.orderType> >,
                                     And <Where <INItemPlan.planType, Equal <INPlanConstants.plan60>,
                                                 Or <INItemPlan.planType, Equal <INPlanConstants.plan66>,
                                                     Or <INItemPlan.planType, Equal <INPlanConstants.plan68> > > > > > >
                .SelectWindowed(this, 0, 1, ordertype.OrderType);

            //PXUIFieldAttribute.SetEnabled<SOOrderType.requireLocation>(sender, ordertype, order == null && isTemplateUpdatable);
            //PXUIFieldAttribute.SetEnabled<SOOrderType.requireLocation>(sender, e.Row, def.INDocType != INTranType.NoUpdate && isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.requireShipping>(sender, e.Row, def.INDocType != INTranType.NoUpdate && def.INDocType != INTranType.Transfer && isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.aRDocType>(sender, e.Row, def.INDocType != INTranType.Transfer && isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.behavior>(sender, e.Row, isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.defaultOperation>(sender, e.Row, isTemplateUpdatable && ordertype.Behavior == SOBehavior.RM);
            PXUIFieldAttribute.SetVisible <SOOrderTypeOperation.active>(operations.Cache, null, ordertype.Behavior == SOBehavior.RM || ordertype.Behavior == SOBehavior.IN);
            PXUIFieldAttribute.SetVisible <SOOrderTypeOperation.autoCreateIssueLine>(operations.Cache, null, ordertype.Behavior == SOBehavior.RM);

            PXPersistingCheck activeCheck = ordertype.Active == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing;

            PXDefaultAttribute.SetPersistingCheck <SOOrderType.salesSubMask>(sender, ordertype, activeCheck);
            //PXDefaultAttribute.SetPersistingCheck<SOOrderType.cOGSSubMask>(sender, ordertype, activeCheck);
            PXDefaultAttribute.SetPersistingCheck <SOOrderType.miscSubMask>(sender, ordertype, activeCheck);
            PXDefaultAttribute.SetPersistingCheck <SOOrderType.freightSubMask>(sender, ordertype, activeCheck);
            PXDefaultAttribute.SetPersistingCheck <SOOrderType.discSubMask>(sender, ordertype, activeCheck);
            PXDefaultAttribute.SetPersistingCheck <SOOrderType.freightAcctID>(sender, ordertype, activeCheck);
            PXDefaultAttribute.SetPersistingCheck <SOOrderType.freightSubID>(sender, ordertype, activeCheck);

            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLineNotesToInvoiceOnlyNS>(sender, ordertype, ordertype.CopyLineNotesToInvoice == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLineFilesToInvoiceOnlyNS>(sender, ordertype, ordertype.CopyLineFilesToInvoice == true);

            PXUIFieldAttribute.SetEnabled <SOOrderType.requireAllocation>(sender, ordertype, ordertype.RequireShipping == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.requireLotSerial>(sender, ordertype, ordertype.RequireShipping == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLotSerialFromShipment>(sender, ordertype, ordertype.RequireShipping == true);

            PXUIFieldAttribute.SetEnabled <SOOrderType.useDiscountSubFromSalesSub>(sender, ordertype, ordertype.PostLineDiscSeparately == true);

            bool allowUserDefinedOrderTypes = PXAccess.FeatureInstalled <FeaturesSet.userDefinedOrderTypes>();

            soordertype.AllowInsert      = allowUserDefinedOrderTypes;
            currentordertype.AllowInsert = allowUserDefinedOrderTypes;
            bool allowUpdateOrderTypes = allowUserDefinedOrderTypes || sender.GetStatus(e.Row) != PXEntryStatus.Inserted;

            soordertype.AllowUpdate      = allowUpdateOrderTypes;
            currentordertype.AllowUpdate = allowUpdateOrderTypes;
        }
Example #30
0
        /// <summary> Combine Yusen csv Detail (ORH、ORL、ORA、FTO、FTD)  </summary>
        public virtual (StringBuilder sb, int totalLine) CombineYusenDetailForFBM(StringBuilder sb, List <SOOrder> currtOrders, int totalLine)
        {
            for (int i = 0; i < currtOrders.Count; i++)
            {
                string  line           = string.Empty;
                SOOrder _soOrder       = currtOrders[i];
                var     inventoryItems = SelectFrom <InventoryItem> .View.Select(Base).RowCast <InventoryItem>().ToList();

                var soLines = SelectFrom <SOLine> .Where <SOLine.orderType.IsEqual <P.AsString>
                                                          .And <SOLine.orderNbr.IsEqual <P.AsString> > >
                              .OrderBy <SOLine.lineNbr.Asc>
                              .View.Select(Base, _soOrder.OrderType, _soOrder.OrderNbr).RowCast <SOLine>();

                SOShipmentContact shipContact = SOShipmentContact.PK.Find(Base, _soOrder.ShipContactID);
                SOShipmentAddress shipAddress = SOShipmentAddress.PK.Find(Base, _soOrder.ShipAddressID);

                if (!soLines.Any())
                {
                    throw new Exception("Can not find SOLine");
                }

                #region OrderHeader - ORH
                line  = string.Empty;
                line += $"{FillUpLen(10, "YS_OR_V01")}";
                line += $"{FillUpLen(3, "ORH")}";
                line += $"{FillUpLen(8, _soOrder?.OrderDate?.ToString("yyyyMMdd"))}";
                line += $"{FillUpLen(8, _soOrder?.RequestDate?.ToString("yyyyMMdd"))}";
                line += $"L";
                line += $"{FillUpLen(15, _soOrder?.OrderNbr)}";
                line += $"{FillUpLen(20, _soOrder?.CustomerOrderNbr)}";
                line += $"{FillUpLen(11, " ")}";
                line += $"{FillUpLen(40, (_soOrder.OrderDesc?.Length > 40 ? _soOrder?.OrderDesc.Substring(0, 40) : _soOrder?.OrderDesc))}";
                line += $"{FillUpLen(40, (_soOrder.OrderDesc?.Length > 40 ? _soOrder?.OrderDesc.Substring(40) : " "))}";
                line += $"{FillUpLen(5, "DPD")}";
                line += "\r\n";
                sb.Append(line);
                totalLine++;

                #endregion

                #region Physical delivery address – ORL
                line  = string.Empty;
                line += $"{FillUpLen(10, "YS_OR_V01")}";
                line += $"{FillUpLen(3, "ORL")}";
                line += $"{FillUpLen(10, " ")}";
                line += $"{FillUpLen(40, shipContact?.FullName)}";
                line += $"{FillUpLen(40, " ")}";
                line += (shipAddress?.AddressLine1 + shipAddress?.AddressLine2).Length > 30 ? $"{(shipAddress?.AddressLine1 + shipAddress?.AddressLine2).Substring(0, 30)}" : $"{FillUpLen(30, (shipAddress?.AddressLine1 + shipAddress?.AddressLine2))}";
                line += $"{FillUpLen(10, shipAddress?.PostalCode)}";
                line += $"{FillUpLen(30, shipAddress?.City)}";
                line += $"{FillUpLen(3, shipAddress?.CountryID)}";
                line += $"{FillUpLen(30, shipContact?.Attention)}";
                line += $"{FillUpLen(20, shipContact?.Phone1)}";
                line += $"{FillUpLen(40, shipContact?.Email)}";
                line += $"{FillUpLen(3, "DE")}";
                line += "\r\n";
                sb.Append(line);
                totalLine++;

                #endregion

                #region Articleline - ORA

                foreach (var item in soLines)
                {
                    line  = string.Empty;
                    line += $"{FillUpLen(10, "YS_OR_V01")}";
                    line += $"{FillUpLen(3, "ORA")}";
                    line += $"{FillUpLen(10, item?.LineNbr.ToString())}";
                    line += $"{FillUpLen(20, inventoryItems?.FirstOrDefault(x => x.InventoryID == item?.InventoryID).InventoryCD)}";
                    line += $"{FillUpLen(11, item?.OpenQty?.ToString())}";
                    line += $"{FillUpLen(25, " ")}";
                    line += $"{FillUpLen(25, " ")}";
                    line += "\r\n";
                    sb.Append(line);
                    totalLine++;
                }

                #endregion

                #region  Free Text Orderpick - FTO

                line  = string.Empty;
                line += $"{FillUpLen(10, "YS_OR_V01")}";
                line += $"{FillUpLen(3, "FTO")}";
                line += $"{FillUpLen(40, "")}";
                line += "\r\n";
                sb.Append(line);
                totalLine++;

                #endregion

                #region Free Text Delivery - FTD

                line  = string.Empty;
                line += $"{FillUpLen(10, "YS_OR_V01")}";
                line += $"{FillUpLen(3, "FTD")}";
                line += $"{FillUpLen(40, " ")}";
                line += "\r\n";
                sb.Append(line);
                totalLine++;

                #endregion
            }
            return(sb, totalLine);
        }