示例#1
0
        protected virtual void INLocation_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            INLocation l = (INLocation)e.Row;

            if (this.site.Current == null || l == null)
            {
                return;
            }
            if (site.Cache.GetStatus(this.site.Current) == PXEntryStatus.Deleted)
            {
                return;
            }
            INSite s = PXCache <INSite> .CreateCopy(this.site.Current);

            if (s.DropShipLocationID == l.LocationID)
            {
                s.DropShipLocationID = null;
            }
            if (s.ReceiptLocationID == l.LocationID)
            {
                s.ReceiptLocationID = null;
            }
            if (s.ShipLocationID == l.LocationID)
            {
                s.ShipLocationID = null;
            }
            if (s.ReturnLocationID == l.LocationID)
            {
                s.ReturnLocationID = null;
            }
            this.site.Update(s);
        }
示例#2
0
        protected virtual void INItemClass_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            INSetup iNSetupRec = (INSetup)PXSelect <INSetup, Where <INSetup.dfltItemClassID, Equal <Current <INItemClass.itemClassID> > > > .SelectWindowed(this, 0, 1);

            if (iNSetupRec != null)
            {
                throw new PXException(Messages.ThisItemClassCanNotBeDeletedBecauseItIsUsedIn, "Inventory Setup");
            }

            InventoryItem inventoryItemRec = (InventoryItem)PXSelect <InventoryItem, Where <InventoryItem.itemClassID, Equal <Current <INItemClass.itemClassID> > > > .SelectWindowed(this, 0, 1);

            if (inventoryItemRec != null)
            {
                throw new PXException(Messages.ThisItemClassCanNotBeDeletedBecauseItIsUsedIn, "Inventory Item: " + inventoryItemRec.InventoryCD);
            }

            INLocation iNLocationRec = (INLocation)PXSelect <INLocation, Where <INLocation.primaryItemClassID, Equal <Current <INItemClass.itemClassID> > > > .SelectWindowed(this, 0, 1);

            if (iNLocationRec != null)
            {
                INSite iNSiteRec = (INSite)PXSelect <INSite, Where <INSite.siteID, Equal <Required <INSite.siteID> > > > .Select(this, iNLocationRec.SiteID);

                throw new PXException(Messages.ThisItemClassCanNotBeDeletedBecauseItIsUsedIn, "Warehouse/Location: " + (iNSiteRec.SiteCD ?? "") + "/" + iNLocationRec.LocationCD);
            }
        }
示例#3
0
        protected virtual void INLocation_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            INLocation row = e.Row as INLocation;

            if (row == null)
            {
                return;
            }

            if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete && row.ProjectID != null && row.TaskID == null && row.Active == true)
            {
                INLocation anotherWildcardLocation = PXSelect <INLocation, Where <INLocation.locationID, NotEqual <Required <INLocation.locationID> >,
                                                                                  And <INLocation.projectID, Equal <Required <INLocation.projectID> >, And <INLocation.taskID, IsNull, And <INLocation.active, Equal <True> > > > > > .Select(this, row.LocationID, row.ProjectID);

                if (anotherWildcardLocation != null)
                {
                    PMProject project = PXSelect <PMProject, Where <PMProject.contractID, Equal <Required <PMProject.contractID> > > > .Select(this, row.ProjectID);

                    INSite warehouse = PXSelect <INSite, Where <INSite.siteID, Equal <Required <INSite.siteID> > > > .Select(this, anotherWildcardLocation.SiteID);

                    if (sender.RaiseExceptionHandling <INLocation.projectID>(e.Row, project.ContractCD, new PXSetPropertyException(Messages.ProjectWildcardLocationIsUsedIn, PXErrorLevel.Error, warehouse.SiteCD, anotherWildcardLocation.LocationCD)))
                    {
                        throw new PXRowPersistingException(PXDataUtils.FieldName <INLocation.projectID>(), row.ProjectID, Messages.ProjectWildcardLocationIsUsedIn, warehouse.SiteCD, anotherWildcardLocation.LocationCD);
                    }
                }
            }
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                INItemSite itemSite = PXSelect <INItemSite, Where <INItemSite.siteID, Equal <Current <INSite.siteID> >,
                                                                   And <Where <INItemSite.dfltReceiptLocationID, Equal <Required <INItemSite.dfltReceiptLocationID> >,
                                                                               Or <INItemSite.dfltShipLocationID, Equal <Required <INItemSite.dfltShipLocationID> > > > > > > .Select(this, row.LocationID, row.LocationID);

                if (itemSite != null)
                {
                    InventoryItem initem = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, itemSite.InventoryID) ?? new InventoryItem();

                    if (sender.RaiseExceptionHandling <INLocation.locationID>(e.Row, row.LocationCD, new PXSetPropertyException(Messages.LocationInUseInItemWarehouseDetails, PXErrorLevel.Error, row.LocationCD.TrimEnd(), initem.InventoryCD.TrimEnd())))
                    {
                        throw new PXRowPersistingException(PXDataUtils.FieldName <INLocation.locationID>(), row.LocationID, Messages.LocationInUseInItemWarehouseDetails, row.LocationCD.TrimEnd(), initem.InventoryCD.TrimEnd());
                    }
                }

                INPIClassLocation piLocation = PXSelectJoin <INPIClassLocation, InnerJoin <INPIClass, On <INPIClass.pIClassID, Equal <INPIClassLocation.pIClassID> > >, Where <INPIClass.siteID, Equal <Current <INSite.siteID> >,
                                                                                                                                                                               And <INPIClassLocation.locationID, Equal <Required <INPIClassLocation.locationID> > > > > .Select(this, row.LocationID);

                if (piLocation != null)
                {
                    if (sender.RaiseExceptionHandling <INLocation.locationID>(e.Row, row.LocationCD, new PXSetPropertyException(Messages.LocationInUseInPIType, PXErrorLevel.Error, row.LocationCD.TrimEnd(), piLocation.PIClassID.TrimEnd())))
                    {
                        throw new PXRowPersistingException(PXDataUtils.FieldName <INLocation.locationID>(), row.LocationID, Messages.LocationInUseInPIType, row.LocationCD.TrimEnd(), piLocation.PIClassID.TrimEnd());
                    }
                }
            }
        }
示例#4
0
        protected virtual bool ShowWarningProjectLowestPickPriority(INLocation row)
        {
            if (row.ProjectID == null)
            {
                return(false);
            }

            return(location.Select().RowCast <INLocation>().Any(l
                                                                => l.Active == true &&
                                                                l.ProjectID == null &&
                                                                l.PickPriority >= row.PickPriority));
        }
        protected virtual Dictionary <int, decimal> GetTranYTDCostTableByPeriod(string periodID)
        {
            if (string.IsNullOrEmpty(periodID))
            {
                throw new ArgumentNullException();
            }

            if (tranYTDCostTable != null)
            {
                return(tranYTDCostTable);
            }

            tranYTDCostTable = new Dictionary <int, decimal>();

            var select = new PXSelectJoinGroupBy <INItemCostHist,
                                                  InnerJoin <INItemCostHistByPeriod,
                                                             On <INItemCostHist.inventoryID, Equal <INItemCostHistByPeriod.inventoryID>,
                                                                 And <INItemCostHist.costSiteID, Equal <INItemCostHistByPeriod.costSiteID>,
                                                                      And <INItemCostHist.costSubItemID, Equal <INItemCostHistByPeriod.costSubItemID>,
                                                                           And <INItemCostHist.accountID, Equal <INItemCostHistByPeriod.accountID>,
                                                                                And <INItemCostHist.subID, Equal <INItemCostHistByPeriod.subID>,
                                                                                     And <INItemCostHist.finPeriodID, Equal <INItemCostHistByPeriod.lastActivityPeriod> > > > > > >,
                                                             LeftJoin <INLocation, On <INLocation.locationID, Equal <INItemCostHist.costSiteID>, And <INLocation.isCosted, Equal <True> > > > >,
                                                  Where <INItemCostHistByPeriod.finPeriodID, Equal <Required <INItemCostHistByPeriod.finPeriodID> > >,
                                                  Aggregate <
                                                      GroupBy <INItemCostHist.costSiteID,
                                                               GroupBy <INItemCostHist.inventoryID,
                                                                        GroupBy <INItemCostHist.finPeriodID,
                                                                                 Sum <INItemCostHist.tranYtdCost> > > > >
                                                  >(context);

            foreach (PXResult <INItemCostHist, INItemCostHistByPeriod, INLocation> res in select.Select(periodID))
            {
                INItemCostHist cost     = (INItemCostHist)res;
                INLocation     location = (INLocation)res;

                int?costSiteID = location.SiteID ?? cost.CostSiteID;
                if (costSiteID == siteID)
                {
                    if (!tranYTDCostTable.ContainsKey(cost.InventoryID.Value))
                    {
                        tranYTDCostTable.Add(cost.InventoryID.Value, cost.FinYtdCost.GetValueOrDefault());
                    }
                    else
                    {
                        tranYTDCostTable[cost.InventoryID.Value] += cost.FinYtdCost.GetValueOrDefault();
                    }
                }
            }

            return(tranYTDCostTable);
        }
        protected virtual void CheckLocationTaskRule(PXCache sender, INTran row)
        {
            if (row.TaskID != null)
            {
                INLocation selectedLocation = (INLocation)PXSelectorAttribute.Select(sender, row, sender.GetField(typeof(INTran.locationID)));

                if (selectedLocation != null && selectedLocation.TaskID != row.TaskID)
                {
                    sender.RaiseExceptionHandling <INTran.locationID>(row, selectedLocation.LocationCD,
                                                                      new PXSetPropertyException(Messages.LocationIsMappedToAnotherTask, PXErrorLevel.Warning));
                }
            }
        }
示例#7
0
        protected virtual void CheckLocationTaskRule(PXCache sender, INTran row)
        {
            if (row.TaskID != null)
            {
                INLocation selectedLocation = INLocation.PK.Find(sender.Graph, row.LocationID);

                if (selectedLocation != null && selectedLocation.TaskID != row.TaskID && (selectedLocation.TaskID != null || selectedLocation.ProjectID != null))
                {
                    sender.RaiseExceptionHandling <INTran.locationID>(row, selectedLocation.LocationCD,
                                                                      new PXSetPropertyException(IN.Messages.LocationIsMappedToAnotherTask, PXErrorLevel.Warning));
                }
            }
        }
示例#8
0
        public virtual void INLocation_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
        {
            INLocation row = (INLocation)e.Row;

            if (row != null)
            {
                INLocation located = (INLocation)sender.Locate(row);
                if (located != null)
                {
                    row.LocationID = located.LocationID;
                }
            }
        }
示例#9
0
        protected virtual void INLocation_ProjectID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            INLocation row = e.Row as INLocation;

            if (row == null)
            {
                return;
            }

            if (row.ProjectID != null)
            {
                sender.SetValueExt <INLocation.isCosted>(row, true);
            }
        }
示例#10
0
        protected virtual void INLocation_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            INLocation row = e.Row as INLocation;

            if (row == null)
            {
                return;
            }

            if (row.PrimaryItemID != null && PXSelectorAttribute.Select <INLocation.primaryItemID>(sender, row) == null)
            {
                PXUIFieldAttribute.SetWarning <INLocation.primaryItemID>(sender, row, Messages.ItemWasDeleted);
            }
            PXUIFieldAttribute.SetEnabled <INLocation.isCosted>(sender, row, row.ProjectID == null);
        }
        protected override void ProcessLocationBarcode(string barcode)
        {
            INLocation location = ReadLocationByBarcode(HeaderView.Current.SiteID, barcode);

            if (location == null)
            {
                return;
            }

            Base.location.Current = location;
            HeaderSetter.Set(h => h.LocationID, location.LocationID);
            Report(Msg.LocationReady, location.LocationCD);

            SetScanState(ScanStates.Confirm);
        }
        /// <summary>
        /// Validates that there are no Quantities on hand on any Project Locations for the given Warehouse.
        /// </summary>
        /// <param name="site">Warehouse</param>
        public virtual void ValidateProjectLocation(INSite site, InventoryItem item)
        {
            var select = new PXSelectJoin <INLocationStatus,
                                           InnerJoin <INLocation, On <INLocation.locationID, Equal <INLocationStatus.locationID> > >,
                                           Where <INLocation.siteID, Equal <Required <INLocation.siteID> >,
                                                  And <INLocation.isCosted, Equal <True>,
                                                       And <INLocation.taskID, IsNotNull,
                                                            And <INLocationStatus.inventoryID, Equal <Required <INLocationStatus.inventoryID> >,
                                                                 And <INLocationStatus.qtyOnHand, NotEqual <decimal0> > > > > > >(this);

            var res = select.SelectWindowed(0, 1, site.SiteID, item.InventoryID);

            if (res.Count == 1)
            {
                INLocation loc = (PXResult <INLocationStatus, INLocation>)res.First();

                throw new PXException(Messages.StandardCostItemOnProjectLocation, loc.LocationCD);
            }
        }
        protected virtual void INItemSite_DfltShipLocationID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            INItemSite is_row = (INItemSite)e.Row;

            INLocation l = PXSelect <INLocation, Where <INLocation.locationID, Equal <Required <INLocation.locationID> > > > .Select(this, e.NewValue);

            if (l == null)
            {
                return;
            }
            if (!(l.SalesValid ?? true))
            {
                if (itemsiterecord.Ask(AP.Messages.Warning, Messages.IssuesAreNotAllowedFromThisLocationContinue, MessageButtons.YesNo, false) == WebDialogResult.No)
                {
                    e.NewValue = is_row.DfltShipLocationID;
                    e.Cancel   = true;
                }
            }
        }
        protected virtual IEnumerable internalResultRecords()
        {
            const bool useItemCostHistoryToOptimizeBalanceCalculation = true;             // false to debug and ensure that INItemCostHistory corresponds to INCostTran

            InventoryTranByAcctEnqFilter filter = Filter.Current;

            bool summaryByDay = filter.SummaryByDay ?? false;

            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.tranType>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.docRefNbr>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.subItemCD>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.siteID>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.locationID>(ResultRecords.Cache, null, !summaryByDay);

            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.accountID>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.subID>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.inventoryID>(ResultRecords.Cache, null, !summaryByDay);

            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.costAdj>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.finPerNbr>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.tranPerNbr>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.qty>(ResultRecords.Cache, null, !summaryByDay);
            PXUIFieldAttribute.SetVisible <InventoryTranByAcctEnqResult.unitCost>(ResultRecords.Cache, null, !summaryByDay);

            PXUIFieldAttribute.SetVisible(Tran.Cache, null, !summaryByDay);

            var resultList = new List <PXResult <InventoryTranByAcctEnqResult, INTran> >();

            decimal cumulativeBalance = 0m;

            if (filter.AccountID == null)
            {
                return(resultList);                 //empty
            }

            if (filter.FinPeriodID == null)
            {
                return(resultList);                 //empty
            }

            if (useItemCostHistoryToOptimizeBalanceCalculation)
            {
                PXSelectBase <INItemCostHist> cmd_CostHist = new PXSelectJoinGroupBy <INItemCostHist,

                                                                                      InnerJoin <Sub,
                                                                                                 On <Sub.subID, Equal <INItemCostHist.subID> > >,

                                                                                      Where <INItemCostHist.finPeriodID, Less <Current <InventoryTranByAcctEnqFilter.finPeriodID> > >,

                                                                                      Aggregate <
                                                                                          Sum <INItemCostHist.tranYtdCost,
                                                                                               Sum <INItemCostHist.tranBegCost,
                                                                                                    Sum <INItemCostHist.finYtdCost,
                                                                                                         Sum <INItemCostHist.finBegCost> > > > > >(this);

                //if (filter.AccountID != null) // checked above
                {
                    cmd_CostHist.WhereAnd <Where <INItemCostHist.accountID, Equal <Current <InventoryTranByAcctEnqFilter.accountID> > > >();
                }

                if (!SubCDUtils.IsSubCDEmpty(filter.SubCD))
                {
                    cmd_CostHist.WhereAnd <Where <Sub.subCD, Like <Current <InventoryTranByAcctEnqFilter.subCDWildcard> > > >();
                }

                PXResultset <INItemCostHist> costHistResult = (PXResultset <INItemCostHist>)cmd_CostHist.Select();
                if (costHistResult.Count == 1)                 // 0 is possible too
                {
                    if (filter.ByFinancialPeriod == true)
                    {
                        cumulativeBalance += (((INItemCostHist)costHistResult[0]).FinYtdCost ?? 0m) - (((INItemCostHist)costHistResult[0]).FinBegCost ?? 0m);
                    }
                    else
                    {
                        cumulativeBalance += (((INItemCostHist)costHistResult[0]).TranYtdCost ?? 0m) - (((INItemCostHist)costHistResult[0]).TranBegCost ?? 0m);
                    }
                }
            }

            PXSelectBase <INTranCost> cmd = new PXSelectReadonly2 <INTranCost,
                                                                   InnerJoin <INTran,
                                                                              On <INTran.tranType, Equal <INTranCost.tranType>,
                                                                                  And <INTran.refNbr, Equal <INTranCost.refNbr>,
                                                                                       And <INTran.lineNbr, Equal <INTranCost.lineNbr> > > >,
                                                                              InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <INTranCost.inventoryID>,
                                                                                                            And <Match <InventoryItem, Current <AccessInfo.userName> > > >,
                                                                                         InnerJoin <Sub, On <Sub.subID, Equal <INTranCost.invtSubID> >,
                                                                                                    InnerJoin <INSubItem, On <INSubItem.subItemID, Equal <INTranCost.costSubItemID> >,
                                                                                                               LeftJoin <INSite, On <INSite.siteID, Equal <INTranCost.costSiteID> >,
                                                                                                                         LeftJoin <INLocation, On <INLocation.locationID, Equal <INTranCost.costSiteID> >,
                                                                                                                                   LeftJoin <INCostStatus, On <INTranCost.costID, Equal <INCostStatus.costID> > > > > > > > >,
                                                                   Where <INSite.siteID, IsNull,
                                                                          Or <Match <INSite, Current <AccessInfo.userName> > > >,
                                                                   OrderBy <Asc <INTranCost.tranDate,
                                                                                 Asc <INTranCost.createdDateTime> > > >(this);

            //if (filter.FinPeriodID != null) // checked above
            if (filter.ByFinancialPeriod == true)
            {
                cmd.WhereAnd <Where <INTranCost.finPeriodID, Equal <Current <InventoryTranByAcctEnqFilter.finPeriodID> > > >();
            }
            else
            {
                cmd.WhereAnd <Where <INTranCost.tranPeriodID, Equal <Current <InventoryTranByAcctEnqFilter.finPeriodID> > > >();
            }

            //if (filter.AccountID != null) // checked above
            {
                cmd.WhereAnd <Where <INTranCost.invtAcctID, Equal <Current <InventoryTranByAcctEnqFilter.accountID> > > >();
            }

            if (!SubCDUtils.IsSubCDEmpty(filter.SubCD))
            {
                cmd.WhereAnd <Where <Sub.subCD, Like <Current <InventoryTranByAcctEnqFilter.subCDWildcard> > > >();
            }

            if (filter.EndDate != null)
            {
                cmd.WhereAnd <Where <INTranCost.tranDate, LessEqual <Current <InventoryTranByAcctEnqFilter.endDate> > > >();
            }
            if (filter.InventoryID != null)
            {
                cmd.WhereAnd <Where <INTranCost.inventoryID, Equal <Current <InventoryTranByAcctEnqFilter.inventoryID> > > >();
            }

            if (filter.SiteID != null)
            {
                cmd.WhereAnd <Where <INTranCost.costSiteID, Equal <Current <InventoryTranByAcctEnqFilter.siteID> > > >();
            }

            int gridLineNbr = 0;

            foreach (PXResult <INTranCost, INTran, InventoryItem, Sub, INSubItem, INSite, INLocation, INCostStatus> it in cmd.Select())
            {
                INTranCost   tc_rec = (INTranCost)it;
                INTran       t_rec  = (INTran)it;
                INSite       s_rec  = (INSite)it;
                INLocation   l_rec  = (INLocation)it;
                INSubItem    si_rec = (INSubItem)it;
                INCostStatus cs_rec = (INCostStatus)it;

                decimal rowCost = (tc_rec.InvtMult * tc_rec.TranCost) ?? 0m;

                if (tc_rec.TranDate < filter.StartDate)
                {
                    cumulativeBalance += rowCost;
                }
                else
                {
                    if (summaryByDay)
                    {
                        if ((resultList.Count > 0) && (((InventoryTranByAcctEnqResult)resultList[resultList.Count - 1]).TranDate == tc_rec.TranDate))
                        {
                            InventoryTranByAcctEnqResult lastItem = resultList[resultList.Count - 1];
                            if (rowCost >= 0)
                            {
                                lastItem.Debit += rowCost;
                            }
                            else
                            {
                                lastItem.Credit -= rowCost;
                            }
                            lastItem.EndBalance += rowCost;
                            resultList[resultList.Count - 1] = new PXResult <InventoryTranByAcctEnqResult, INTran>(lastItem, null);
                        }
                        else
                        {
                            InventoryTranByAcctEnqResult item = new InventoryTranByAcctEnqResult();
                            item.BegBalance = cumulativeBalance;
                            item.TranDate   = tc_rec.TranDate;
                            if (rowCost >= 0)
                            {
                                item.Debit  = rowCost;
                                item.Credit = 0m;
                            }
                            else
                            {
                                item.Debit  = 0m;
                                item.Credit = -rowCost;
                            }
                            item.EndBalance      = item.BegBalance + rowCost;
                            item.GridLineNbr     = ++gridLineNbr;
                            item.CreatedDateTime = tc_rec.CreatedDateTime;
                            resultList.Add(new PXResult <InventoryTranByAcctEnqResult, INTran>(item, null));
                        }
                        cumulativeBalance += rowCost;
                    }
                    else
                    {
                        InventoryTranByAcctEnqResult item = new InventoryTranByAcctEnqResult();
                        item.BegBalance = cumulativeBalance;
                        item.TranDate   = tc_rec.TranDate;
                        if (rowCost >= 0)
                        {
                            item.Debit  = rowCost;
                            item.Credit = 0m;
                        }
                        else
                        {
                            item.Debit  = 0m;
                            item.Credit = -rowCost;
                        }
                        item.EndBalance = item.BegBalance + rowCost;

                        item.AccountID   = tc_rec.InvtAcctID;
                        item.SubID       = tc_rec.InvtSubID;
                        item.TranType    = tc_rec.TranType;
                        item.DocType     = t_rec.DocType;
                        item.DocRefNbr   = tc_rec.RefNbr;
                        item.ReceiptNbr  = cs_rec.ReceiptNbr;
                        item.InventoryID = tc_rec.InventoryID;
                        item.SubItemCD   = si_rec.SubItemCD;
                        if (s_rec.SiteID != null)
                        {
                            item.SiteID     = s_rec.SiteID;
                            item.LocationID = null;
                        }
                        else
                        if (l_rec.LocationID != null)                                 //though it's more or less guaranteed
                        {
                            item.SiteID     = l_rec.SiteID;
                            item.LocationID = l_rec.LocationID;
                        }
                        item.TranDate        = tc_rec.TranDate;
                        item.FinPerNbr       = tc_rec.FinPeriodID;
                        item.TranPerNbr      = tc_rec.TranPeriodID;
                        item.Qty             = tc_rec.Qty * tc_rec.InvtMult;
                        item.UnitCost        = (tc_rec.Qty ?? 0m) == 0m ? null : ((tc_rec.TranCost ?? 0m) + (tc_rec.VarCost ?? 0m)) / tc_rec.Qty;
                        item.CostAdj         = tc_rec.CostRefNbr != tc_rec.RefNbr;
                        item.GridLineNbr     = ++gridLineNbr;
                        item.CreatedDateTime = tc_rec.CreatedDateTime;
                        resultList.Add(new PXResult <InventoryTranByAcctEnqResult, INTran>(item, t_rec));
                        cumulativeBalance += rowCost;
                    }
                }
            }
            return(resultList);
        }
示例#15
0
        protected virtual void INLocation_TaskID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            ///TODO: Redo this using Plans and Status tables once we have them in version 7.0

            INLocation row = e.Row as INLocation;

            if (row == null)
            {
                return;
            }

            PO.POReceiptLine unreleasedPO = PXSelect <PO.POReceiptLine,
                                                      Where <PO.POReceiptLine.taskID, Equal <Required <PO.POReceiptLine.taskID> >,
                                                             And <PO.POReceiptLine.released, Equal <False>,
                                                                  And <PO.POReceiptLine.locationID, Equal <Required <INLocation.locationID> > > > > > .SelectWindowed(this, 0, 1, row.TaskID, row.LocationID);

            if (unreleasedPO != null)
            {
                PMTask task = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(this, row.TaskID ?? e.NewValue);

                if (task != null)
                {
                    e.NewValue = task.TaskCD;
                }

                throw new PXSetPropertyException(Messages.TaskUsedInPO);
            }

            SO.SOShipLine unreleasedSO = PXSelect <SO.SOShipLine,
                                                   Where <SO.SOShipLine.taskID, Equal <Required <SO.SOShipLine.taskID> >,
                                                          And <SO.SOShipLine.released, Equal <False>,
                                                               And <SO.SOShipLine.locationID, Equal <Required <INLocation.locationID> > > > > > .SelectWindowed(this, 0, 1, row.TaskID, row.LocationID);

            if (unreleasedSO != null)
            {
                PMTask task = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(this, row.TaskID ?? e.NewValue);

                if (task != null)
                {
                    e.NewValue = task.TaskCD;
                }

                throw new PXSetPropertyException(Messages.TaskUsedInSO);
            }

            INLocationStatus locationStatus = PXSelect <INLocationStatus, Where <INLocationStatus.siteID, Equal <Required <INLocationStatus.siteID> >,
                                                                                 And <INLocationStatus.locationID, Equal <Required <INLocationStatus.locationID> >,
                                                                                      And <INLocationStatus.qtyOnHand, NotEqual <decimal0> > > > > .SelectWindowed(this, 0, 1, row.SiteID, row.LocationID);

            if (locationStatus != null)
            {
                PMTask task = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(this, row.TaskID ?? e.NewValue);

                if (task != null)
                {
                    e.NewValue = task.TaskCD;
                }

                throw new PXSetPropertyException(Messages.TaskUsedInIN);
            }
        }