Esempio n. 1
0
        /// <summary> SOPackageDetailEx_qty Updated Event </summary>
        protected void _(Events.FieldUpdated <SOPackageDetail.qty> e)
        {
            var _splitLineNbr = e.Cache.GetExtension <SOPackageDetailExt>(e.Row).UsrShipmentSplitLineNbr;

            if (e.NewValue == null || _splitLineNbr == null)
            {
                return;
            }

            if ((decimal?)e.NewValue == 0)
            {
                e.Cache.SetValueExt <SOPackageDetail.weight>(e.Row, 0);
                return;
            }

            var row = (SOPackageDetailEx)e.Row;

            var _shipLine = Base.Transactions.Cache.Cached.RowCast <SOShipLine>().Where(x => x.LineNbr == _splitLineNbr).SingleOrDefault();
            PXResult <InventoryItem, CSAnswers> _sotockItemData = GetStockInfo(_shipLine.InventoryID.Value, _QTYINBOX);
            decimal _qtyInBox = 1;

            try
            {
                _qtyInBox = decimal.Parse(_sotockItemData.GetItem <CSAnswers>()?.Value);
            }
            catch (Exception)
            {
                _qtyInBox = 1;
            }

            e.Cache.SetValueExt <SOPackageDetail.weight>(e.Row, row.Qty * _sotockItemData.GetItem <InventoryItem>().BaseItemWeight / _qtyInBox);
        }
Esempio n. 2
0
        public override object Map(KCMapObjectRequest request)
        {
            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(request.Target))
            {
                PXResult <KCMapping> exportMappingRow = _mappingMaint.ExportMappingRow.Select(request.EntityType, property.Name, request.ViewName).FirstOrDefault();
                if (exportMappingRow == null)
                {
                    continue;
                }
                KCMapping mapping = exportMappingRow.GetItem <KCMapping>();
                KCAcumaticaMappingField acumaticaField = exportMappingRow.GetItem <KCAcumaticaMappingField>();
                string formula = mapping.RuleType == KCRuleTypesConstants.Expression
                              ? mapping.SourceExpression
                              : acumaticaField?.FieldName;

                IDictionary <string, object> mappingValue = GetMappingValue(request, property);
                if (mappingValue == null || (property.PropertyType != typeof(bool?) && property.PropertyType != typeof(bool) && mappingValue.GetValue(formula) == null))
                {
                    continue;
                }
                MapField(request.EntityType, request.Target, property, mappingValue, formula);
            }

            return(request.Target);
        }
Esempio n. 3
0
        public override object Map(KCMapObjectRequest request)
        {
            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(request.Target))
            {
                PXResult <KCMapping> importMappingRow = _mappingMaint.ImportMappingRow.Select(request.EntityType, property.Name, request.ViewName).FirstOrDefault();
                if (importMappingRow == null)
                {
                    continue;
                }
                KCMapping mapping = importMappingRow.GetItem <KCMapping>();
                KCChannelAdvisorMappingField caField = importMappingRow.GetItem <KCChannelAdvisorMappingField>();
                string formula = mapping.RuleType == KCRuleTypesConstants.Expression
                              ? mapping.SourceExpression
                              : caField?.FieldName;

                IDictionary <string, object> mappingValue = GetMappingValue(request, property);
                if (string.IsNullOrWhiteSpace(formula) ||
                    mappingValue == null ||
                    (mapping.RuleType == KCRuleTypesConstants.Simple && mappingValue.GetValue(formula) == null))
                {
                    continue;
                }
                MapField(request.EntityType, request.Target, property, mappingValue, formula);
            }

            return(request.Target);
        }
            protected override InventoryMapValue CreateInventoryMapValue(int?inventoryID, PXResult <CSAnswers, CSAttributeGroup, InventoryItem> result)
            {
                var ret = base.CreateInventoryMapValue(inventoryID, result);

                ret.SiteStatus     = result.GetItem <INSiteStatus>();
                ret.LocationStatus = (Header.Current.LocationID != null) ? result.GetItem <INLocationStatus>() : null;
                return(ret);
            }
        private static void ProcessJointPayeePayment(JointCheckPrintModel printModel, PXResult jointPayeePayment)
        {
            var jointPayee     = jointPayeePayment.GetItem <JointPayee>();
            var vendor         = jointPayeePayment.GetItem <Vendor>();
            var jointPayeeName = GetJointPayeeNameIfNew(printModel, jointPayee, vendor);

            if (jointPayeeName == string.Empty)
            {
                return;
            }
            UpdateJointCheckPrintModelWithNewPayee(printModel, jointPayee, vendor);
            AddJointPayeeName(printModel, jointPayeeName);
        }
Esempio n. 6
0
        protected override IDictionary <string, object> GetMappingValue(KCMapObjectRequest request, PropertyDescriptor property)
        {
            PXResult <KCMapping> exportMappingRow = _mappingMaint.ExportMappingRow.Select(request.EntityType, property.Name, request.ViewName).FirstOrDefault();

            if (exportMappingRow == null)
            {
                return(null);
            }
            KCMapping mapping = exportMappingRow.GetItem <KCMapping>();
            KCAcumaticaMappingField             acumaticaField = exportMappingRow.GetItem <KCAcumaticaMappingField>();
            List <Dictionary <string, object> > mappingValue   = MappingValues.GetValue(new KCMappingKey(acumaticaField.ViewDisplayName, request.Id));

            return(mappingValue?.FirstOrDefault());
        }
 public static T GetReservedProductAttributeValue <T>(KCAttributesMappingMaint graph, InventoryItem product, string ReservedAttributeName)
 {
     try
     {
         PXResult <KCAttribute> resAttr = graph.ReservedAttribute.Select(ReservedAttributeName, product.NoteID).FirstOrDefault();
         CSAnswers ans = resAttr?.GetItem <CSAnswers>();
         return(resAttr != null && ans != null ? (T)Convert.ChangeType(ans.Value, typeof(T)) : default);
        private bool DoesJointPayeeInternalIdMatchGenerationKey(PXResult jointPayeePayment)
        {
            var jointPayee = jointPayeePayment.GetItem <JointPayee>();

            return(jointPayee.JointPayeeInternalId != null &&
                   jointPayee.JointPayeeInternalId == generationKey.JointPayeeVendorId);
        }
Esempio n. 9
0
        /// <summary> Get Current Value to Report Parameter </summary>
        public Dictionary <string, string> GetCurrentRowToParameter(bool isOutter = false)
        {
            var _CurrentRow = this.GetCacheCurrent <LumShipmentPlan>().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(this, _CurrentRow.InventoryID);

            PXResult <AMProdItem, SOLine> soData =
                (PXResult <AMProdItem, SOLine>)SelectFrom <AMProdItem>
                .LeftJoin <SOLine> .On <AMProdItemExt.usrSOLineNbr.IsEqual <SOLine.lineNbr>
                                        .And <AMProdItemExt.usrSOOrderNbr.IsEqual <SOLine.orderNbr> >
                                        .And <AMProdItemExt.usrSOOrderType.IsEqual <SOLine.orderType> > >
                .Where <AMProdItem.prodOrdID.IsEqual <P.AsString> > .View.Select(this, _CurrentRow.ProdOrdID);

            var ENDCDescr = new PXGraph().Select <CSAttributeDetail>().Where(x => x.ValueID == _CurrentRow.Customer).FirstOrDefault()?.Description;

            ENDCDescr = ENDCDescr ?? _CurrentRow.Customer;

            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                ["ShipmentPlanID"] = _CurrentRow.ShipmentPlanID,
                ["ProdOrdID"]      = _CurrentRow.ProdOrdID,
                ["Customer"]       = ENDCDescr,
                ["CustomerPartNo"] = soData.GetItem <SOLine>()?.AlternateID,
                ["Description"]    = data.FirstOrDefault().GetItem <InventoryItem>().Descr,
                ["Resistor"]       = data.RowCast <CSAnswers>().Where(x => x.AttributeID == "RESISTOR").FirstOrDefault()?.Value,
                ["DATE"]           = _CurrentRow.PlannedShipDate?.ToString("yyyy/MM/dd")
            };

            return(parameters);
        }
Esempio n. 10
0
        private bool IsApplicable(PXResult result)
        {
            var order         = result.GetItem <POPrintOrder.POPrintOrderOwned>();
            var isSubcontract = order.OrderType == POOrderType.RegularSubcontract;

            return(Base is PrintSubcontract
                ? isSubcontract
                : !isSubcontract);
        }
Esempio n. 11
0
        protected virtual void _(Events.FieldUpdated <POLine.inventoryID> e)
        {
            PXResult _bubbleNumber = SelectFrom <InventoryItem> .
                                     LeftJoin <CSAnswers> .On <InventoryItem.noteID.IsEqual <CSAnswers.refNoteID> .
                                                               And <CSAnswers.attributeID.IsEqual <constBubbleNumber> > > .
                                     Where <InventoryItem.inventoryID.IsEqual <@P.AsInt> > .View.
                                     Select(Base, ((POLine)e.Row).InventoryID);

            e.Cache.SetValue <POLineExt.usrBubbleNumber>(e.Row, _bubbleNumber.GetItem <CSAnswers>().Value);
        }
Esempio n. 12
0
        private static bool IsRelatedToBill(PXResult jointPayeePaymentResult, APAdjust adjustment)
        {
            var jointPayeePayment = jointPayeePaymentResult.GetItem <JointPayeePayment>();
            var isRelatedToBill   = jointPayeePayment.PaymentDocType == adjustment.AdjdDocType &&
                                    jointPayeePayment.PaymentRefNbr == adjustment.AdjdRefNbr;

            return(adjustment.AdjdLineNbr != 0
                ? isRelatedToBill && jointPayeePayment.BillLineNumber == adjustment.AdjdLineNbr
                : isRelatedToBill);
        }
Esempio n. 13
0
        /// <summary>
        /// Checks if inventory item was updated
        /// </summary>
        /// <param name="result">PXResult&lt;InventoryItem, KCInventoryItem&gt;</param>
        protected override bool IsUpdated(PXResult <InventoryItem> result)
        {
            var product   = result.GetItem <InventoryItem>();
            var kcProduct = result.GetItem <KNSIKCInventoryItem>();

            if (product == null || kcProduct == null)
            {
                throw new ArgumentException($"{nameof(result)} must contain {nameof(InventoryItem)} and {nameof(KNSIKCInventoryItem)}");
            }

            return(kcProduct.UsrKCCASyncDate == null ||
                   IsProductUpdated(product, kcProduct) ||
                   IsKcProductUpdated(kcProduct) ||
                   IsImagePlacementUpdated(kcProduct) ||
                   IsAttributesMappingUpdated(kcProduct) ||
                   IsSiteMasterUpdated(kcProduct) ||
                   IsClassificationUpdated(kcProduct) ||
                   IsVariationRelationshipUpdated(product, kcProduct) ||
                   IsKitUpdated(product, kcProduct) ||
                   IsQuantityUpdated(kcProduct));
        }
        public static PIItemLocationInfo Create(PXResult result)
        {
            InventoryItem     inventoryItem   = result.GetItem <InventoryItem>();
            INSubItem         subItem         = result.GetItem <INSubItem>();
            INLocation        location        = result.GetItem <INLocation>();
            INLotSerialStatus lotSerialStatus = result.GetItem <INLotSerialStatus>();

            return(new PIItemLocationInfo
            {
                InventoryID = (int)inventoryItem.InventoryID,
                SubItemID = subItem?.SubItemID,
                LocationID = (int)location.LocationID,
                QueryResult = result,

                InventoryCD = inventoryItem.InventoryCD,
                SubItemCD = subItem?.SubItemCD,
                LocationCD = location.LocationCD,
                LotSerialNbr = lotSerialStatus?.LotSerialNbr,
                Description = inventoryItem.Descr
            });
        }
        public bool ParentIsGrouped(PXResultset <SOLine> lines, SOLinePCExt soLinePcExt)
        {
            if (soLinePcExt == null)
            {
                return(false);
            }

            PXResult <SOLine>  parent          = lines.FirstOrDefault(line => line.GetItem <SOLine>() != null && line.GetItem <SOLine>().LineNbr == soLinePcExt.UsrKNMasterLineNbr);
            InventoryItem      parentItem      = parent?.GetItem <InventoryItem>();
            InventoryItemPCExt parentItemPcExt = parentItem?.GetExtension <InventoryItemPCExt>();

            return(parentItemPcExt?.UsrKNCompositeType == KCConstants.GroupedProduct);
        }
Esempio n. 16
0
            private int RefreshTotal(string screenID, string viewName, out int read, out int unread)
            {
                read   = -1;
                unread = -1;
                string actualScreenID = PXContext.GetScreenID();

                using (new PXPreserveScope())
                {
                    try
                    {
                        PXContext.SetScreenID(screenID);
                        PXGraph graph = CreateGraph(screenID);
                        if (graph == null || graph.PrimaryView == null)
                        {
                            return(-1);
                        }
                        if (viewName == null)
                        {
                            viewName = graph.PrimaryView;
                        }
                        PXView view = graph.Views[viewName];

                        PXView        viewFilters;
                        PXFilterRow[] filters = null;
                        if (graph.Views.TryGetValue(viewName + PXFilterableAttribute.FilterHeaderName, out viewFilters))
                        {
                            foreach (FilterHeader fHeader in viewFilters.SelectMulti())
                            {
                                if (fHeader.IsDefault == true)
                                {
                                    int   s = 0;
                                    int   t = 0;
                                    IList f = graph.ExecuteSelect(viewName + PXFilterableAttribute.FilterRowName, new object[] { fHeader.FilterID },
                                                                  null, null, null,
                                                                  new PXFilterRow[] { new PXFilterRow(typeof(FilterRow.isUsed).Name, PXCondition.EQ, true, null) }, ref s, 0, ref t) as IList;
                                    if (f != null && f.Count > 0)
                                    {
                                        filters = new PXFilterRow[f.Count];

                                        PXCache frc = graph.Caches[typeof(FilterRow)];
                                        for (int i = 0; i < f.Count; i++)
                                        {
                                            FilterRow r      = (FilterRow)f[i];
                                            var       filter = new PXFilterRow(r.DataField, (PXCondition)r.Condition, frc.GetValueExt(r, "ValueSt"), frc.GetValueExt(r, "ValueSt2"));
                                            if (r.OpenBrackets != null)
                                            {
                                                filter.OpenBrackets = r.OpenBrackets.Value;
                                            }
                                            if (r.CloseBrackets != null)
                                            {
                                                filter.CloseBrackets = r.CloseBrackets.Value;
                                            }
                                            filter.OrOperator = r.Operator == 1;
                                            filters[i]        = filter;
                                        }
                                    }
                                    break;
                                }
                            }
                        }

                        int start = 0;
                        int total = 0;
                        read   = -1;
                        unread = -1;

                        using (var scope = new PXFieldScope(view, typeof(CRActivity.noteID), typeof(EPView.status)))
                            foreach (object record in view.Select(null, null, null, null, null, filters, ref start, 101, ref total))
                            {
                                PXResult result = record as PXResult;
                                if (result != null)
                                {
                                    EPView v = result.GetItem <EPView>();
                                    if (v != null)
                                    {
                                        if (v.Status != null && v.Status == EPViewStatusAttribute.VIEWED)
                                        {
                                            read += 1;
                                        }
                                        else
                                        {
                                            unread += 1;
                                        }
                                    }
                                }
                            }
                        if (read != -1 || unread != -1)
                        {
                            read   += 1;
                            unread += 1;
                        }
                        return(total);
                    }
                    finally
                    {
                        PXContext.SetScreenID(actualScreenID);
                    }
                }
            }
        protected virtual FinPeriod BuildFinPeriod(int?organizationID, object record)
        {
            if (organizationID == FinPeriod.organizationID.MasterValue &&
                MasterPeriodBasedOnOrganizationPeriods)
            {
                MasterFinPeriod baseFinPeriod = (record as PXResult).GetItem <MasterFinPeriod>();

                return(new FinPeriod()
                {
                    FinPeriodID = baseFinPeriod.FinPeriodID,
                    StartDateUI = baseFinPeriod.StartDateUI,
                    EndDateUI = baseFinPeriod.EndDateUI,
                    Descr = baseFinPeriod.Descr,
                    NoteID = baseFinPeriod.NoteID
                });
            }
            else
            {
                PXResult resultRecord = record as PXResult;

                FinPeriod orgFinPeriod = resultRecord != null
                                                                                                        ? resultRecord.GetItem <FinPeriod>()
                                                                                                        : (FinPeriod)record;

                return(new FinPeriod
                {
                    FinPeriodID = orgFinPeriod.FinPeriodID,
                    StartDateUI = orgFinPeriod.StartDateUI,
                    EndDateUI = orgFinPeriod.EndDateUI,
                    Descr = orgFinPeriod.Descr,
                    NoteID = orgFinPeriod.NoteID
                });
            }
        }