Example #1
0
 public int GetQuantityReceived()
 {
     return(POItems
            .Where(x => x.Active)
            .Where(x => x.PurchaseOrder.Active)
            .Where(x => x.PurchaseOrder.StatusLUID != PurchaseOrder.PurchaseOrderStatusCancelledLUID())
            .Select(x => x.ReceiptItems.Where(ri => ri.Active).Where(ri => ri.Receipt.Active).Select(ri => ri.QuantityReceived).Sum()).Sum());
 }
Example #2
0
        private Dictionary <string, string> Validate()
        {
            Dictionary <string, string> ValErrors = new Dictionary <string, string>();

            if (PurchaseOrderID <= 0)
            {
                ValErrors.Add("PurchaseOrderID", "Purchase Order ID is required.");
            }
            else if (PurchaseOrder == null || PurchaseOrder.PurchaseOrderID <= 0)
            {
                ValErrors.Add("Purchase Order", string.Format("Could not find purchase order {0}.", PurchaseOrderID));
            }

            if (ItemID <= 0)
            {
                ValErrors.Add("ItemID", "Requisition Item ID is required.");
            }
            else if (RequisitionItem == null || RequisitionItem.ItemID <= 0)
            {
                ValErrors.Add("ItemID", string.Format("Could not find requisition item {0}.", ItemID));
            }

            if (PurchaseOrderItemID > 0 &&
                RequisitionItem.POItems
                .Where(x => x.PurchaseOrderID != PurchaseOrderID && x.Active)
                .Where(x => x.PurchaseOrder.Active)
                .Where(x => x.PurchaseOrder.StatusLUID != PurchaseOrder.PurchaseOrderStatusCancelledLUID())
                .Select(x => x.Quantity).Sum() + Quantity > RequisitionItem.Quantity)
            {
                ValErrors.Add("Quantity", string.Format("Quantity added for item {0} is greater than the item's quantity that is not added to a PO. Verify and retry", RequisitionItem.Description));
            }
            else if (PurchaseOrderItemID == 0 &&
                     RequisitionItem.POItems
                     .Where(x => x.Active)
                     .Where(x => x.PurchaseOrder.Active)
                     .Where(x => x.PurchaseOrder.StatusLUID != PurchaseOrder.PurchaseOrderStatusCancelledLUID())
                     .Select(x => x.Quantity).Sum() + Quantity > RequisitionItem.Quantity)
            {
                ValErrors.Add("Quantity", string.Format("Quantity added for item {0}  is greater than the items quantity that is not added to a PO.", RequisitionItem.Description));
            }

            //if (Price < 0)
            //    ValErrors.Add("Price", "Price must be equal to or greater than 0.");

            if (Quantity == 0)
            {
                ValErrors.Add("Quantity", "Quantity is required.");
            }

            return(ValErrors);
        }
Example #3
0
        public bool CanBeDeleted()
        {
            bool Deleteable = true;

            if (Deleteable && POItems.Where(poi => poi.Active == true).Where(poi => poi.PurchaseOrder.Active).Where(poi => poi.PurchaseOrder.StatusLUID != PurchaseOrder.PurchaseOrderStatusCancelledLUID()).Count() > 0)
            {
                Deleteable = false;
            }
            return(Deleteable);
        }