예제 #1
0
 private async void SaveAsycudaSalesAllocation(AsycudaSalesAllocations allo)
 {
     using (var ctx = new AsycudaSalesAllocationsService())
     {
         await ctx.UpdateAsycudaSalesAllocations(allo).ConfigureAwait(false);
     }
 }
예제 #2
0
 private async Task SaveAllocation(AsycudaSalesAllocations ssa)
 {
     using (var ctx = new AsycudaSalesAllocationsService())
     {
         await ctx.UpdateAsycudaSalesAllocations(ssa).ConfigureAwait(false);
     }
 }
예제 #3
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);
        }
예제 #4
0
 public async Task SaveAsycudaSalesAllocations(AsycudaSalesAllocations i)
 {
     if (i == null)
     {
         return;
     }
     using (var ctx = new AsycudaSalesAllocationsService())
     {
         await ctx.UpdateAsycudaSalesAllocations(i).ConfigureAwait(false);
     }
 }
예제 #5
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;
            }
        }
예제 #6
0
        private async Task AddExceptionAllocation(EntryDataDetails saleitm, string error)
        {
            var ssa = new AsycudaSalesAllocations()
            {
                EntryDataDetailsId = saleitm.EntryDataDetailsId,
                //EntryDataDetails = saleitm,
                Status        = error,
                TrackingState = TrackingState.Added
            };

            await SaveAllocation(ssa).ConfigureAwait(false);

            saleitm.AsycudaSalesAllocations.Add(ssa);
        }
        private void SetXBond(AsycudaSalesAllocations ssa, List <global::AllocationDS.Business.Entities.xcuda_PreviousItem> plst, bool returnsNExt = false)
        {
            var amt = ssa.QtyAllocated;

            foreach (var pitm in plst)
            {
                if (pitm.QtyAllocated == null)
                {
                    pitm.QtyAllocated = 0;
                }
                var atot = pitm.Suplementary_Quantity - pitm.QtyAllocated;
                if (atot == 0 && amt > 0 && returnsNExt == false)
                {
                    continue;
                }

                if (returnsNExt == true && atot == 0 && amt > 0 && pitm != plst.Last())
                {
                    continue;
                }

                if (ssa.EntryDataDetails.Sales.EntryDataDate < pitm.xcuda_Item.AsycudaDocument.AssessmentDate)
                {
                    continue;
                }



                if (amt <= atot)
                {
                    pitm.QtyAllocated += amt;
                    ssa.xbondEntry.Clear();
                    ssa.xbondEntry.Add(pitm.xcuda_Item);
                    pitm.xcuda_Item.xSalesAllocations.Add(ssa);
                    break;
                }
                else
                {
                    pitm.QtyAllocated += atot;
                    ssa.xbondEntry.Clear();
                    ssa.xbondEntry.Add(pitm.xcuda_Item);
                    pitm.xcuda_Item.xSalesAllocations.Add(ssa);
                    amt -= atot;
                }
            }
        }
예제 #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);
        }
예제 #9
0
        //public CreateErrOPS CreateErrOps
        //{
        //    get { return CreateErrOPS.Instance; }
        //}

        //public CreateIncompOPSClass CreateIncompOpsClass
        //{
        //    get { return _createIncompOpsClass; }
        //}

        public async Task ClearAllocation(AsycudaSalesAllocations allo)
        {
            /////////// took out entrydatadetails update

            if (allo.EntryDataDetails != null && (allo.EntryDataDetails.TrackingState != TrackingState.Deleted))
            {
                allo.EntryDataDetails.QtyAllocated = 0;
                allo.EntryDataDetails = null;
            }

            if (allo.PreviousDocumentItem != null)
            {
                using (var ctx = new xcuda_ItemService())
                {
                    var res = await ctx.Getxcuda_ItemByKey(allo.PreviousItem_Id.ToString()).ConfigureAwait(false);

                    res.DFQtyAllocated = 0;
                    res.DPQtyAllocated = 0;

                    foreach (var sitm in res.SubItems)
                    {
                        sitm.QtyAllocated = 0;
                    }

                    foreach (var ed in res.xcuda_PreviousItems.Select(x => x.xcuda_PreviousItem))
                    {
                        ed.QtyAllocated = 0;
                    }
                    await ctx.Updatexcuda_Item(res).ConfigureAwait(false);
                }

                allo.PreviousDocumentItem = null;
            }


            using (var ctx = new AsycudaSalesAllocationsService())
            {
                await ctx.DeleteAsycudaSalesAllocations(allo.AllocationId.ToString()).ConfigureAwait(false);
            }
        }
예제 #10
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;
            }
        }