Ejemplo n.º 1
0
        private double GetAsycudaItmQtyToAllocate(xcuda_Item cAsycudaItm, EntryDataDetails saleitm, out SubItems subitm)
        {
            double asycudaItmQtyToAllocate;

            if (cAsycudaItm.SubItems.Any())
            {
                subitm = cAsycudaItm.SubItems.FirstOrDefault(x => x.ItemNumber == saleitm.ItemNumber);
                if (subitm != null)
                {
                    asycudaItmQtyToAllocate = subitm.Quantity - subitm.QtyAllocated;
                    if (Convert.ToDouble(asycudaItmQtyToAllocate) > (Convert.ToDouble(cAsycudaItm.ItemQuantity) - cAsycudaItm.QtyAllocated))
                    {
                        asycudaItmQtyToAllocate = cAsycudaItm.ItemQuantity - cAsycudaItm.QtyAllocated;
                    }
                }
                else
                {
                    asycudaItmQtyToAllocate = 0;
                }
            }
            else
            {
                asycudaItmQtyToAllocate = cAsycudaItm.ItemQuantity - cAsycudaItm.QtyAllocated;
                subitm = null;
            }

            return(asycudaItmQtyToAllocate);
        }
Ejemplo n.º 2
0
 private static async Task SaveXcuda_Item(xcuda_Item cAsycudaItm)
 {
     using (var ctx = new xcuda_ItemService())
     {
         await ctx.Updatexcuda_Item(cAsycudaItm).ConfigureAwait(false);
     }
 }
Ejemplo n.º 3
0
        private void SetPreviousItemXbond(AsycudaSalesAllocations ssa, xcuda_Item cAsycudaItm, string dfp, double amt)
        {
            try
            {
                if (BaseDataModel.Instance.CurrentApplicationSettings.AllowEntryDoNotAllocate != "Visible")
                {
                    return;
                }


                var alst = cAsycudaItm.xcuda_PreviousItems
                           .Where(x => x.DutyFreePaid == dfp && x.QtyAllocated <= x.Suplementary_Quantity)
                           .Where(x => x.xcuda_Item != null && x.xcuda_Item.AsycudaDocument != null)
                           .OrderBy(
                    x =>
                    x.xcuda_Item.AsycudaDocument.EffectiveRegistrationDate == null
                                        ? Convert.ToDateTime(x.xcuda_Item.AsycudaDocument.RegistrationDate)
                                        : x.xcuda_Item.AsycudaDocument.EffectiveRegistrationDate).ToList();
                foreach (var pitm in alst)
                {
                    if (pitm.QtyAllocated == null)
                    {
                        pitm.QtyAllocated = 0;
                    }
                    var atot = pitm.Suplementary_Quantity - Convert.ToSingle(pitm.QtyAllocated);
                    if (atot == 0)
                    {
                        continue;
                    }
                    if (amt <= atot)
                    {
                        pitm.QtyAllocated += amt;
                        ssa.xbondEntry.Add(pitm.xcuda_Item);
                        pitm.xcuda_Item.xSalesAllocations.Add(ssa);
                        break;
                    }
                    else
                    {
                        pitm.QtyAllocated += atot;
                        ssa.xbondEntry.Add(pitm.xcuda_Item);
                        pitm.xcuda_Item.xSalesAllocations.Add(ssa);
                        amt -= atot;
                    }
                }
            }
            catch (Exception Ex)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        private void AllocatePreviousItems(xcuda_Item cAsycudaItm)
        {
            foreach (var pitm in cAsycudaItm.xcuda_PreviousItems.OrderBy(x => x.xcuda_Item.AsycudaDocument.RegistrationDate))
            {
                if (pitm.QtyAllocated == null)
                {
                    pitm.QtyAllocated = 0;
                }
                var atot = pitm.Suplementary_Quantity - Convert.ToSingle(pitm.QtyAllocated);
                var ctot = cAsycudaItm.ItemQuantity - cAsycudaItm.QtyAllocated;
                if (ctot >= atot)
                {
                    if (pitm.DutyFreePaid == "Duty Free")
                    {
                        cAsycudaItm.DFQtyAllocated += atot;
                    }
                    else
                    {
                        cAsycudaItm.DPQtyAllocated += atot;
                    }

                    pitm.QtyAllocated += atot;
                }
                else
                {
                    if (pitm.DutyFreePaid == "Duty Free")
                    {
                        cAsycudaItm.DFQtyAllocated += ctot;
                    }
                    else
                    {
                        cAsycudaItm.DPQtyAllocated += ctot;
                    }

                    pitm.QtyAllocated += ctot;
                }
            }
        }
Ejemplo n.º 5
0
        private async Task <double> AllocateSaleItem(xcuda_Item cAsycudaItm, EntryDataDetails saleitm,
                                                     double saleitmQtyToallocate, SubItems subitm)
        {
            try
            {
                var dfp = ((Sales)saleitm.Sales).DutyFreePaid;
                // allocate Sale item
                var ssa = new AsycudaSalesAllocations
                {
                    EntryDataDetailsId = saleitm.EntryDataDetailsId,
                    PreviousItem_Id    = cAsycudaItm.Item_Id,
                    QtyAllocated       = 0,
                    TrackingState      = TrackingState.Added
                };



                if (cAsycudaItm.QtyAllocated >= 0 && saleitmQtyToallocate != 0 &&
                    cAsycudaItm.QtyAllocated <= Convert.ToDouble(cAsycudaItm.ItemQuantity))
                {
                    if (saleitmQtyToallocate > 0)
                    {
                        if (subitm != null)
                        {
                            subitm.QtyAllocated = subitm.QtyAllocated + saleitmQtyToallocate;
                        }

                        if (dfp == "Duty Free")
                        {
                            cAsycudaItm.DFQtyAllocated += saleitmQtyToallocate;
                        }
                        else
                        {
                            cAsycudaItm.DPQtyAllocated += saleitmQtyToallocate;
                        }

                        if (BaseDataModel.Instance.CurrentApplicationSettings.AllowEntryDoNotAllocate == "Visible")
                        {
                            SetPreviousItemXbond(ssa, cAsycudaItm, dfp, saleitmQtyToallocate);
                        }

                        saleitm.QtyAllocated += saleitmQtyToallocate;

                        ssa.QtyAllocated += saleitmQtyToallocate;

                        saleitmQtyToallocate -= saleitmQtyToallocate;
                    }
                    else
                    {
                        // returns
                        double mqty = 0;

                        if ((Convert.ToDouble(cAsycudaItm.QtyAllocated) == 0))
                        {
                            if (dfp == "Duty Free")
                            {
                                cAsycudaItm.DFQtyAllocated = cAsycudaItm.ItemQuantity;
                            }
                            else
                            {
                                cAsycudaItm.DPQtyAllocated = cAsycudaItm.ItemQuantity;
                            }
                            if (BaseDataModel.Instance.CurrentApplicationSettings.AllowEntryDoNotAllocate == "Visible")
                            {
                                SetPreviousItemXbond(ssa, cAsycudaItm, dfp, saleitmQtyToallocate);
                            }
                        }

                        if ((cAsycudaItm.QtyAllocated > Convert.ToDouble(saleitmQtyToallocate * -1)))
                        {
                            mqty = saleitmQtyToallocate * -1;
                        }
                        else
                        {
                            if (cAsycudaItm.QtyAllocated == 0)
                            {
                                mqty = cAsycudaItm.ItemQuantity;
                            }
                            else
                            {
                                mqty = cAsycudaItm.QtyAllocated;
                            }
                            //mqty = Convert.ToDouble(saleitmQtyToallocate * -1);
                        }

                        if (cAsycudaItm.QtyAllocated != 0)
                        {
                            if (subitm != null)
                            {
                                subitm.QtyAllocated = subitm.QtyAllocated - mqty;
                            }
                            if (dfp == "Duty Free")
                            {
                                cAsycudaItm.DFQtyAllocated -= mqty;
                            }
                            else
                            {
                                cAsycudaItm.DPQtyAllocated -= mqty;
                            }

                            if (BaseDataModel.Instance.CurrentApplicationSettings.AllowEntryDoNotAllocate == "Visible")
                            {
                                SetPreviousItemXbond(ssa, cAsycudaItm, dfp, -mqty);
                            }
                            saleitmQtyToallocate += mqty;

                            saleitm.QtyAllocated -= mqty;
                            ///saleitm.QtyAllocated + System.Convert.ToDouble(saleitmQtyToallocate);

                            ssa.QtyAllocated -= mqty; //Convert.ToDouble(saleitmQtyToallocate);
                        }
                    }
                }
                //saleitm.AsycudaSalesAllocations = new ObservableCollection<AsycudaSalesAllocations>(saleitm.AsycudaSalesAllocations){ssa};
                await SaveAllocation(ssa).ConfigureAwait(false);

                if (subitm != null)
                {
                    await SaveSubItem(subitm).ConfigureAwait(false);
                }
                await SaveXcuda_Item(cAsycudaItm).ConfigureAwait(false);
                await SaveEntryDataDetails(saleitm).ConfigureAwait(false);

                // saleitm.AsycudaSalesAllocations.Add(ssa);
                return(saleitmQtyToallocate);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 6
0
 private void ReturnsStepBack(List <xcuda_Item> asycudaEntries, ref int i, ref int CurrentAsycudaItemIndex, ref xcuda_Item cAsycudaItm, EntryDataDetails saleitm)
 {
     if (saleitm.Quantity < 0) // if is a return go to previous cAsycudaItem
     {
         while (cAsycudaItm.QtyAllocated == 0 && CurrentAsycudaItemIndex > 0)
         {
             CurrentAsycudaItemIndex -= 1;
             cAsycudaItm              = GetAsycudaEntries(asycudaEntries, CurrentAsycudaItemIndex);
             i = CurrentAsycudaItemIndex;
         }
     }
 }
Ejemplo n.º 7
0
        //System.Windows.Forms.MessageBox.


        public async Task ManuallyAllocate(AsycudaSalesAllocations currentAsycudaSalesAllocation, xcuda_Item PreviousItemEx)
        {
            double aqty;

            if (currentAsycudaSalesAllocation.EntryDataDetails.Quantity > (PreviousItemEx.ItemQuantity - PreviousItemEx.QtyAllocated))
            {
                aqty = PreviousItemEx.ItemQuantity - PreviousItemEx.QtyAllocated;
            }
            else
            {
                aqty = currentAsycudaSalesAllocation.EntryDataDetails.Quantity;
            }
            currentAsycudaSalesAllocation.PreviousItem_Id = PreviousItemEx.Item_Id;

            currentAsycudaSalesAllocation.QtyAllocated = aqty;
            currentAsycudaSalesAllocation.EntryDataDetails.QtyAllocated += aqty;
            if ((currentAsycudaSalesAllocation.EntryDataDetails.Sales as Sales).DutyFreePaid == "Duty Free")
            {
                PreviousItemEx.DFQtyAllocated += aqty;
            }
            else
            {
                PreviousItemEx.DPQtyAllocated += aqty;
            }

            currentAsycudaSalesAllocation.Status = "Manual Allocation";

            SaveAsycudaSalesAllocation(currentAsycudaSalesAllocation);
        }
Ejemplo n.º 8
0
        //System.Windows.Forms.MessageBox.


        public async Task ManuallyAllocate(AsycudaSalesAllocations currentAsycudaSalesAllocation, xcuda_Item PreviousItemEx)
        {
            double aqty;

            using (var ctx = new AllocationDSContext()
            {
                StartTracking = true
            })
            {
                var entryDataDetails =
                    ctx.EntryDataDetails.Include(x => x.Sales).First(
                        x => x.EntryDataDetailsId == currentAsycudaSalesAllocation.EntryDataDetailsId.Value);

                var asycudaItem = ctx.xcuda_Item.Include(x => x.xcuda_Tarification.xcuda_Supplementary_unit).First(x => x.Item_Id == PreviousItemEx.Item_Id);
                ctx.AsycudaSalesAllocations.Attach(currentAsycudaSalesAllocation);

                if (entryDataDetails.Quantity >=
                    (asycudaItem.ItemQuantity - asycudaItem.QtyAllocated))
                {
                    aqty = asycudaItem.ItemQuantity - asycudaItem.QtyAllocated;
                }
                else
                {
                    aqty = entryDataDetails.Quantity;
                }
                currentAsycudaSalesAllocation.PreviousItem_Id = asycudaItem.Item_Id;

                currentAsycudaSalesAllocation.QtyAllocated = aqty;
                entryDataDetails.QtyAllocated += aqty;
                if ((entryDataDetails.Sales as Sales).DutyFreePaid == "Duty Free")
                {
                    asycudaItem.DFQtyAllocated += aqty;
                }
                else
                {
                    asycudaItem.DPQtyAllocated += aqty;
                }

                currentAsycudaSalesAllocation.Status = "Manual Allocation";

                ctx.SaveChanges();
                currentAsycudaSalesAllocation.AcceptChanges();
            }
            // SaveAsycudaSalesAllocation(currentAsycudaSalesAllocation);
        }