Ejemplo n.º 1
0
        public void OnUpdate(eStoreDbContext db, DailySale dailySale)
        {
            //TODO:SaleManager:OnUpdate
            var oldSale = db.DailySales.Find(dailySale.DailySaleId);

            UpDateAmount(db, oldSale, true);

            if (oldSale.IsSaleReturn)
            {
                // SaleRetun
            }
            else
            {
                // Normal Bill
                if (oldSale.IsDue)
                {
                    if (!dailySale.IsDue)
                    {
                        UpdateSalesRetun(db, oldSale, true);
                    }
                    else
                    {
                    }
                }
                else
                { //TODO: Add due
                }

                UpDateAmount(db, oldSale, true);
                UpDateAmount(db, dailySale, false);
            }

            //TODO: SaleBot.NotifySale(db, dailySale.SalesmanId, dailySale.Amount);
        }
Ejemplo n.º 2
0
 private void UpDateAmount(AprajitaRetailsContext db, DailySale dailySale, bool IsEdit)
 {
     if (IsEdit)
     {
         if (dailySale.PayMode == PayModes.Cash && dailySale.CashAmount > 0)
         {
             CashTrigger.UpdateCashInHand(db, dailySale.SaleDate, 0 - dailySale.CashAmount);
         }
         //TODO: in future make it more robust
         if (dailySale.PayMode != PayModes.Cash && dailySale.PayMode != PayModes.Coupons && dailySale.PayMode != PayModes.Points)
         {
             CashTrigger.UpdateCashInBank(db, dailySale.SaleDate, 0 - (dailySale.Amount - dailySale.CashAmount));
         }
     }
     else
     {
         if (dailySale.PayMode == PayModes.Cash && dailySale.CashAmount > 0)
         {
             CashTrigger.UpdateCashInHand(db, dailySale.SaleDate, dailySale.CashAmount);
         }
         //TODO: in future make it more robust
         if (dailySale.PayMode != PayModes.Cash && dailySale.PayMode != PayModes.Coupons && dailySale.PayMode != PayModes.Points)
         {
             CashTrigger.UpdateCashInBank(db, dailySale.SaleDate, dailySale.Amount - dailySale.CashAmount);
         }
     }
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("DailySaleId,SaleDate,InvNo,Amount,PayMode,CashAmount,SalesmanId,IsDue,IsManualBill,IsTailoringBill,IsSaleReturn,Remarks,StoreId")] DailySale dailySale)
        {
            if (id != dailySale.DailySaleId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.Update(dailySale);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DailySaleExists(dailySale.DailySaleId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SalesmanId"] = new SelectList(db.Salesmen, "SalesmanId", "SalesmanName", dailySale.SalesmanId);
            return(PartialView(dailySale));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <DailySale> > PostDailySale(DailySale dailySale)
        {
            _context.DailySales.Add(dailySale);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDailySale", new { id = dailySale.DailySaleId }, dailySale));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PutDailySale(int id, DailySale dailySale)
        {
            if (id != dailySale.DailySaleId)
            {
                return(BadRequest());
            }

            _context.Entry(dailySale).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DailySaleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 6
0
        private void UpdateDueAmount(AprajitaRetailsContext db, DailySale dailySale, bool IsEdit)
        {
            if (IsEdit)
            {
                var dId = db.DuesLists.Where(c => c.DailySaleId == dailySale.DailySaleId).FirstOrDefault();
                if (dId != null)
                {
                    db.DuesLists.Remove(dId);
                }
                else
                {
                    //TODO: Handle this
                }
            }
            else
            {
                decimal dueAmt;
                if (dailySale.Amount != dailySale.CashAmount)
                {
                    dueAmt = dailySale.Amount - dailySale.CashAmount;
                }
                else
                {
                    dueAmt = dailySale.Amount;
                }

                DuesList dl = new DuesList()
                {
                    Amount = dueAmt, DailySale = dailySale, DailySaleId = dailySale.DailySaleId
                };
                db.DuesLists.Add(dl);
            }
        }
Ejemplo n.º 7
0
 private void UpdateSalesRetun(eStoreDbContext db, DailySale dailySale, bool IsEdit)
 {
     if (IsEdit)
     {
         if (dailySale.PayMode == PayMode.Cash && dailySale.CashAmount > 0)
         {
             CashTrigger.UpDateCashOutHand(db, dailySale.SaleDate, 0 - dailySale.CashAmount);
         }
         //TODO: in future make it more robust
         if (dailySale.PayMode != PayMode.Cash && dailySale.PayMode != PayMode.Coupons && dailySale.PayMode != PayMode.Points)
         {
             CashTrigger.UpDateCashOutBank(db, dailySale.SaleDate, 0 - (dailySale.Amount - dailySale.CashAmount));
         }
         //dailySale.Amount = 0 - dailySale.Amount;
     }
     else
     {
         if (dailySale.PayMode == PayMode.Cash && dailySale.CashAmount > 0)
         {
             CashTrigger.UpDateCashOutHand(db, dailySale.SaleDate, dailySale.CashAmount);
         }
         //TODO: in future make it more robust
         if (dailySale.PayMode != PayMode.Cash && dailySale.PayMode != PayMode.Coupons && dailySale.PayMode != PayMode.Points)
         {
             CashTrigger.UpDateCashOutBank(db, dailySale.SaleDate, dailySale.Amount - dailySale.CashAmount);
         }
         dailySale.Amount = 0 - dailySale.Amount;
     }
 }
Ejemplo n.º 8
0
        public void OnDelete(eStoreDbContext db, DailySale dailySale)
        {
            //TODO: Handle for Dues
            if (dailySale.IsSaleReturn)
            {
                UpdateSalesRetun(db, dailySale, true);
            }
            else
            {
                if (dailySale.IsDue)
                {
                    UpdateDueAmount(db, dailySale, true);
                }
                else
                {
                    //TODO: Add this option in Create and Edit also
                    // Handle when payment is done by Coupons and Points.
                    // Need to create table to create Coupn and Royalty point.
                    // Points will go in head for Direct Expenses
                    // Coupon Table will be colloum for TAS Coupon and Apajita Retails.

                    //TODO: Need to handle is.
                    // If payment is cash and cashamount is zero then need to handle this option also
                    // may be error entry , might be due.

                    // throw new Exception();
                }

                UpDateAmount(db, dailySale, true);
            }
        }
        /// <summary>
        /// ProcessAccounts Handle Cash/Bank flow and update related tables
        /// </summary>
        /// <param name="dailySale"></param>
        private void ProcessAccounts(DailySale dailySale)
        {
            if (!dailySale.IsSaleReturn)
            {
                if (!dailySale.IsDue)
                {
                    if (dailySale.PayMode == PayModes.Cash && dailySale.CashAmount > 0)
                    {
                        Utils.UpDateCashInHand(db, dailySale.SaleDate, dailySale.CashAmount);
                    }
                    //TODO: in future make it more robust
                    if (dailySale.PayMode != PayModes.Cash && dailySale.PayMode != PayModes.Coupons && dailySale.PayMode != PayModes.Points)
                    {
                        Utils.UpDateCashInBank(db, dailySale.SaleDate, dailySale.Amount - dailySale.CashAmount);
                    }
                }
                else
                {
                    decimal dueAmt;
                    if (dailySale.Amount != dailySale.CashAmount)
                    {
                        dueAmt = dailySale.Amount - dailySale.CashAmount;
                    }
                    else
                    {
                        dueAmt = dailySale.Amount;
                    }

                    DuesList dl = new DuesList()
                    {
                        Amount = dueAmt, DailySale = dailySale, DailySaleId = dailySale.DailySaleId
                    };
                    db.DuesLists.Add(dl);

                    if (dailySale.PayMode == PayModes.Cash && dailySale.CashAmount > 0)
                    {
                        Utils.UpDateCashInHand(db, dailySale.SaleDate, dailySale.CashAmount);
                    }
                    //TODO: in future make it more robust
                    if (dailySale.PayMode != PayModes.Cash && dailySale.PayMode != PayModes.Coupons && dailySale.PayMode != PayModes.Points)
                    {
                        Utils.UpDateCashInBank(db, dailySale.SaleDate, dailySale.CashAmount);  //TODO: Here adding card amount in cash amoutn
                    }
                }
            }
            else
            {
                if (dailySale.PayMode == PayModes.Cash && dailySale.CashAmount > 0)
                {
                    Utils.UpDateCashOutHand(db, dailySale.SaleDate, dailySale.CashAmount);
                }
                //TODO: in future make it more robust
                if (dailySale.PayMode != PayModes.Cash && dailySale.PayMode != PayModes.Coupons && dailySale.PayMode != PayModes.Points)
                {
                    Utils.UpDateCashOutBank(db, dailySale.SaleDate, dailySale.Amount - dailySale.CashAmount);
                }
                dailySale.Amount = 0 - dailySale.Amount;
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            DailySale dailySale = db.DailySales.Find(id);

            db.DailySales.Remove(dailySale);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: DailySales/Create
        public ActionResult Create()
        {
            ViewBag.SalesmanId = new SelectList(db.Salesmen, "SalesmanId", "SalesmanName");
            DailySale dailySale = new DailySale();

            dailySale.SaleDate = DateTime.Today;
            //return View();
            return(PartialView(dailySale));
        }
Ejemplo n.º 12
0
        private void UpdateDueAmount(eStoreDbContext db, DailySale dailySale, bool IsEdit)
        {
            if (IsEdit)
            {
                var dId = db.DuesLists.Where(c => c.DailySaleId == dailySale.DailySaleId).FirstOrDefault();
                if (dId != null)
                {
                    db.DuesLists.Remove(dId);
                    decimal dueAmt;
                    if (dailySale.Amount != dailySale.CashAmount)
                    {
                        dueAmt = dailySale.Amount - dailySale.CashAmount;
                    }
                    else
                    {
                        dueAmt = dailySale.Amount;
                    }

                    DuesList dl = new DuesList()
                    {
                        Amount      = dueAmt,
                        DailySale   = dailySale,
                        DailySaleId = dailySale.DailySaleId,
                        StoreId     = dailySale.StoreId
                        ,
                        IsPartialRecovery = false,
                        IsRecovered       = false,
                        UserId            = dailySale.UserId
                    };
                    db.DuesLists.Add(dl);
                }
                else
                {
                    //TODO: Handle this
                }
            }
            else
            {
                decimal dueAmt;
                if (dailySale.Amount != dailySale.CashAmount)
                {
                    dueAmt = dailySale.Amount - dailySale.CashAmount;
                }
                else
                {
                    dueAmt = dailySale.Amount;
                }

                DuesList dl = new DuesList()
                {
                    Amount = dueAmt, DailySale = dailySale, DailySaleId = dailySale.DailySaleId, StoreId = dailySale.StoreId
                    , IsPartialRecovery = false, IsRecovered = false, UserId = dailySale.UserId
                };
                db.DuesLists.Add(dl);
            }
        }
 public ActionResult Edit([Bind(Include = "DailySaleId,SaleDate,InvNo,Amount,PayMode,CashAmount,SalesmanId,IsDue,IsManualBill,IsTailoringBill,IsSaleReturn,Remarks")] DailySale dailySale)
 {
     if (ModelState.IsValid)
     {
         //TODO: check is required if Amount is changed so need to verify with old data.
         //TODO: Rectifed This  ProcessAccounts(dailySale);
         db.Entry(dailySale).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SalesmanId = new SelectList(db.Salesmen, "SalesmanId", "SalesmanName", dailySale.SalesmanId);
     return(View(dailySale));
 }
Ejemplo n.º 14
0
        public async Task <IActionResult> Create([Bind("DailySaleId,SaleDate,InvNo,Amount,PayMode,CashAmount,SalesmanId,IsDue,IsManualBill,IsTailoringBill,IsSaleReturn,Remarks")] DailySale dailySale)
        {
            if (ModelState.IsValid)
            {
                db.Add(dailySale);
                new SalesManager().OnInsert(db, dailySale);
                await db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData ["SalesmanId"] = new SelectList(db.Salesmen, "SalesmanId", "SalesmanName", dailySale.SalesmanId);
            return(PartialView(dailySale));
        }
Ejemplo n.º 15
0
        private static void AddDiscounts(DiscountApplier discountApplier)
        {
            var firstPurchaseDiscount = new FirstPurchaseDiscount(discountApplier);

            firstPurchaseDiscount.Add();

            var flashSale = new FlashSale(discountApplier, 5000);

            flashSale.Add();

            var dailySale = new DailySale(discountApplier);

            dailySale.Add();
        }
        public ActionResult Create([Bind(Include = "DailySaleId,SaleDate,InvNo,Amount,PayMode,CashAmount,SalesmanId,IsDue,IsManualBill,IsTailoringBill,IsSaleReturn,Remarks")] DailySale dailySale)
        {
            if (ModelState.IsValid)
            {
                ProcessAccounts(dailySale);
                db.DailySales.Add(dailySale);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SalesmanId = new SelectList(db.Salesmen, "SalesmanId", "SalesmanName", dailySale.SalesmanId);
            return(View(dailySale));
            //return PartialView(dailySale);
        }
        // GET: DailySales/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DailySale dailySale = db.DailySales.Find(id);

            if (dailySale == null)
            {
                return(HttpNotFound());
            }
            // return View(dailySale);
            return(PartialView(dailySale));
        }
        // GET: DailySales/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DailySale dailySale = db.DailySales.Find(id);

            if (dailySale == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SalesmanId = new SelectList(db.Salesmen, "SalesmanId", "SalesmanName", dailySale.SalesmanId);
            //return View(dailySale);
            return(PartialView(dailySale));
        }
Ejemplo n.º 19
0
        public bool SaveData(DailySaleDM data)
        {
            bool      status    = false;
            DailySale dailySale = new DailySale()
            {
                ID          = -1,
                Discount    = data.Discount,
                Fabric      = data.Fabric,
                Amount      = data.Amount,
                InvoiceNo   = data.InvoiceNo,
                RMZ         = data.RMZ,
                SaleDate    = data.SaleDate,
                Tailoring   = data.Tailoring,
                PaymentMode = data.PaymentMode,
                CustomerID  = GetCustomerID(data.CustomerMobileNo)
            };

            if (DB.InsertData(dailySale) > 0)
            {
                status = true;
                Logs.LogMe("DailySale is added!");
            }
            if (data.NewCustomer == 1)
            {
                NewCustomer newCust = new NewCustomer()
                {
                    CustomerID       = dailySale.CustomerID,
                    ID               = -1,
                    InvoiceNo        = data.InvoiceNo,
                    OnDate           = data.SaleDate,
                    CustomerFullName = data.CustomerFullName
                };
                NewCustomerDB nDB = new NewCustomerDB();
                if (nDB.Insert(newCust) > 0)
                {
                    status = true;
                }
                else
                {
                    if (status)
                    {
                        Logs.LogMe("New Customer Data not able to add!");
                    }
                }
            }
            return(status);
        }
Ejemplo n.º 20
0
        private async System.Threading.Tasks.Task <SortedDictionary <int, string> > AddDailySalesAsync(SortedList <int, string> smList)
        {
            var ws = xS.GetWS("DailySales");
            var nonEmptyDataRows = ws.RowsUsed();
            int Row = 6;//Title
            //DailySaleId	SaleDate	InvNo	Amount	PayMode	CashAmount	SalesmanId	IsDue	IsManualBill
            //IsTailoringBill	IsSaleReturn	Remarks	IsMatchedWithVOy	EDCTranscationId	MixAndCouponPaymentId	StoreId	UserName
            SortedDictionary <int, string> SaleList = new SortedDictionary <int, string>();

            foreach (var dR in nonEmptyDataRows)
            {
                if (dR.RowNumber() > Row)
                {
                    SaleList.Add(dR.Cell(1).GetValue <int>(), dR.Cell(3).GetValue <string>());
                    DailySale dL = new DailySale
                    {
                        //DailySaleId = dR.Cell(1).GetValue<int>(),
                        SaleDate         = dR.Cell(2).GetDateTime(),
                        InvNo            = dR.Cell(3).GetValue <string>(),
                        Amount           = dR.Cell(4).GetValue <decimal>(),
                        PayMode          = dR.Cell(5).GetValue <PayMode>(),
                        CashAmount       = dR.Cell(6).GetValue <decimal>(),
                        SalesmanId       = dR.Cell(7).GetValue <int>(),
                        IsDue            = dR.Cell(8).GetBoolean(),
                        IsManualBill     = dR.Cell(9).GetBoolean(),
                        IsTailoringBill  = dR.Cell(10).GetBoolean(),
                        IsSaleReturn     = dR.Cell(11).GetBoolean(),
                        Remarks          = dR.Cell(12).GetValue <string>(),
                        IsMatchedWithVOy = dR.Cell(13).GetBoolean(),
                        //EDCTranscationId = dR.Cell(14).GetValue<int>(),
                        //MixAndCouponPaymentId = dR.Cell(15).GetValue<int>(),
                        StoreId     = dR.Cell(16).GetValue <int>(),
                        UserId      = dR.Cell(17).GetValue <string>(),
                        EntryStatus = 0,
                        IsReadOnly  = true
                    };
                    dL.SalesmanId = await GetSMId(smList.GetValueOrDefault(dL.SalesmanId));

                    Console.WriteLine("SM:# " + dL.SalesmanId);
                    db.DailySales.Add(dL);
                }
            }
            await db.SaveChangesAsync();

            return(SaleList);
        }
Ejemplo n.º 21
0
        private void ShowDailySaleData(DailySale saleD)
        {
            TXTBillAmount.Text = "" + saleD.Amount;

            string s1 = viewModel.GetCustomerName(saleD.CustomerID);

            string[] s = s1.Split(' ');
            CBMobileNo.Text      = s[0];
            s[0]                 = "";
            TXTCustomerName.Text = String.Join(" ", s);
            Logs.LogMe("CustN=" + s1);
            //TODO: get Customer Details from Customer Table
            TXTDiscount.Text            = "" + saleD.Discount;
            NUDFabric.Text              = "" + saleD.Fabric;
            TXTInvoiceNo.Text           = saleD.InvoiceNo;
            CBPaymentMode.SelectedIndex = saleD.PaymentMode - 1;
            NUDRmz.Text       = "" + saleD.RMZ;
            DTPDate.Value     = saleD.SaleDate;
            NUDTailoring.Text = "" + saleD.Tailoring;
        }
Ejemplo n.º 22
0
 public void OnInsert(AprajitaRetailsContext db, DailySale dailySale)
 {
     if (!dailySale.IsSaleReturn)
     {
         if (!dailySale.IsDue)
         {
             UpDateAmount(db, dailySale, false);
         }
         else
         {
             UpdateDueAmount(db, dailySale, false);
             UpDateAmount(db, dailySale, false);
         }
     }
     else
     {
         UpdateSalesRetun(db, dailySale, false);
     }
     SaleBot.NotifySale(db, dailySale.SalesmanId, dailySale.Amount);
 }
Ejemplo n.º 23
0
 public void OnInsert(eStoreDbContext db, DailySale dailySale)
 {
     if (!dailySale.IsSaleReturn)
     { //Normal Bill
         if (!dailySale.IsDue)
         {
             //Paid Bill
             UpDateAmount(db, dailySale, false);
         }
         else
         {
             //Due Bill
             UpdateDueAmount(db, dailySale, false);
             UpDateAmount(db, dailySale, false);
         }
     }
     else
     {
         //Sale Return Bill
         UpdateSalesRetun(db, dailySale, false);
     }
     //TODO: SaleBot.NotifySale(db, dailySale.SalesmanId, dailySale.Amount);
 }
 private void ProcessAccountDelete(DailySale dailySale)
 {
     if (dailySale.PayMode == PayModes.Cash && dailySale.CashAmount > 0)
     {
         Utils.UpDateCashInHand(db, dailySale.SaleDate, 0 - dailySale.CashAmount);
     }
     else if (dailySale.PayMode != PayModes.Cash && dailySale.PayMode != PayModes.Coupons && dailySale.PayMode != PayModes.Points)
     {
         Utils.UpDateCashInBank(db, dailySale.SaleDate, 0 - dailySale.CashAmount);
     }
     else
     {
         //TODO: Add this option in Create and Edit also
         // Handle when payment is done by Coupons and Points.
         //Need to create table to create Coupn and Royalty point.
         // Points will go in head for Direct Expenses
         // Coupon Table will be colloum for TAS Coupon and Apajita Retails.
         //TODO: Need to handle is.
         // If payment is cash and cashamount is zero then need to handle this option also
         // may be error entry , might be due.
         throw new Exception();
     }
 }
 public ReportManagerControler(DailySale dailySale)
 {
     this.dailySale    = dailySale;
     reportManagerImpl = new ReportManagerImpl(dailySale);
 }
        private void CreateDailySale(AprajitaRetailsContext db, VoyagerContext voyager, RegularInvoice inv)
        {
            var dSale = db.DailySales.Where(c => c.InvNo == inv.InvoiceNo).FirstOrDefault();

            if (dSale != null)
            {
                dSale.IsMatchedWithVOy = true;
                if (dSale.Amount != inv.TotalBillAmount)
                {
                    dSale.Remarks         += "Amount doesn't match";
                    dSale.IsMatchedWithVOy = false;
                    db.Entry(dSale).State  = EntityState.Modified;
                }

                if (dSale.PayMode == PayModes.Cash)
                {
                    if (inv.PaymentDetail.PayMode != SalePayMode.Cash)
                    {
                        dSale.Remarks         += "payment mode doesn't match";
                        dSale.IsMatchedWithVOy = false;
                        db.Entry(dSale).State  = EntityState.Modified;
                    }

                    if (dSale.CashAmount != inv.TotalBillAmount)
                    {
                        dSale.Remarks         += "cash amount doesn't match";
                        dSale.IsMatchedWithVOy = false;
                        db.Entry(dSale).State  = EntityState.Modified;
                    }
                }
                else if (dSale.PayMode == PayModes.Card)
                {
                    if (inv.PaymentDetail.PayMode != SalePayMode.Card)
                    {
                        dSale.Remarks         += "payment mode doesn't match";
                        dSale.IsMatchedWithVOy = false;
                        db.Entry(dSale).State  = EntityState.Modified;
                    }
                }

                if (dSale.SaleDate != inv.OnDate)
                {
                    dSale.Remarks         += "Date doesn't match";
                    dSale.IsMatchedWithVOy = false;
                    db.Entry(dSale).State  = EntityState.Modified;
                }
            }
            else
            {
                DailySale dailySale = new DailySale
                {
                    Amount           = inv.TotalBillAmount,
                    InvNo            = inv.InvoiceNo,
                    SaleDate         = inv.OnDate,
                    IsDue            = false,
                    IsManualBill     = false,
                    Remarks          = "AutoGenerated",
                    CashAmount       = 0,
                    IsMatchedWithVOy = true,
                    IsSaleReturn     = false,
                    IsTailoringBill  = false
                };
                dailySale.SalesmanId = db.Salesmen.Where(c => c.SalesmanName == inv.SaleItems.First().Salesman.SalesmanName).Select(c => c.SalesmanId).FirstOrDefault();
                if (dailySale.SalesmanId <= 0)
                {
                    dailySale.SalesmanId = CreateSalesman(db, inv.SaleItems.First().Salesman.SalesmanName);
                }
                // Payment Mode.
                if (inv.PaymentDetail.PayMode == SalePayMode.Cash)
                {
                    dailySale.PayMode    = PayModes.Cash;
                    dailySale.CashAmount = inv.TotalBillAmount;
                }
                else if (inv.PaymentDetail.PayMode == SalePayMode.Card)
                {
                    dailySale.PayMode = PayModes.Card;
                }
                else if (inv.PaymentDetail.PayMode == SalePayMode.Mix)
                {
                    dailySale.PayMode  = PayModes.MixPayments;
                    dailySale.Remarks += " Mix Payments. Update based on real Data";
                }
                else if (inv.PaymentDetail.PayMode == SalePayMode.SR)
                { // Sale Return flag is marked
                    dailySale.PayMode      = PayModes.Cash;
                    dailySale.CashAmount   = inv.TotalBillAmount;
                    dailySale.IsSaleReturn = true;
                }
                //IsTailoring
                if (inv.SaleItems.First().ProductItem != null && inv.SaleItems.First().ProductItem.Categorys == ProductCategorys.Tailoring)
                {
                    dailySale.IsTailoringBill = true;
                }
                else if (inv.SaleItems.First().ProductItem == null)
                {
                    if (voyager.ProductItems.Find(inv.SaleItems.First().ProductItemId).Categorys == ProductCategorys.Tailoring)
                    {
                        dailySale.IsTailoringBill = true;
                    }
                }
                db.DailySales.Add(dailySale);
            }
            db.SaveChanges();
        }
Ejemplo n.º 27
0
 public ReportManagerImpl(DailySale dailySale)
 {
     this.dailySale            = dailySale;
     sellingInvoiceManagerImpl = new SellingInvoiceManagerImpl();
     paymentManagerImpl        = new PaymentManagerImpl();
 }