Example #1
0
        // GET: InvoiceController/Create
        public ActionResult Create()
        {
            var vendors   = _vendorsRepository.FindAll();
            var vendorsId = vendors.Select(q => new SelectListItem {
                Text = q.VendorName, Value = q.ID.ToString()
            });

            var items   = _itemsRepo.FindAll();
            var itemsid = items.Select(q => new SelectListItem {
                Text = q.ItemName, Value = q.Id.ToString()
            });

            var itemscost = _itemsRepo.FindAll();
            var Icost     = itemscost.Select(q => new SelectListItem {
                Text = q.Cost.ToString(), Value = q.Cost.ToString()
            });

            var POnumber   = _POnumberRepo.FindAll();
            var POnumberid = POnumber.Select(q => new SelectListItem {
                Text = q.PurchaseOrderNumber.ToString(), Value = q.PurchaseOrderNumber.ToString()
            });

            var model = new InvoiceVm
            {
                Vendors        = vendorsId,
                Item           = itemsid,
                PurchaseOrders = POnumberid,
                Itemcost       = Icost
            };

            return(View(model));
        }
Example #2
0
        public IActionResult InvoiceDetail(long invoiceId)
        {
            var invoiceVm = InvoiceVm.MapToViewModel(_invoiceBlProvider.GetSingle(invoiceId));


            return(PartialView("_InvoiceDetail", invoiceVm));
        }
Example #3
0
        private static void AddAPInvToTransTable(string creditAccountId, InvoiceVm invoiceVm)
        {
            string debitAccId = "";
            byte   invFor     = invoiceVm.InvoiceType;

            if (invFor == 1) //carrier
            {
                debitAccId = ((int)AccountingChartEnum.CarrierCostOfSales).ToString();
            }
            else if (invFor == 2) //Contractor
            {
                debitAccId = ((int)AccountingChartEnum.TruckingCostOfSales).ToString();
            }
            else if (invFor == 3) //Custom Clearance
            {
                debitAccId = ((int)AccountingChartEnum.CCCostOfSales).ToString();
            }


            AccTransactionVm accTrans = new AccTransactionVm()
            {
                CreateDate        = DateTime.Now,
                CreateBy          = EasyFreight.DAL.AdminHelper.GetCurrentUserId(),
                TransactionName   = "Invoice Number " + invoiceVm.InvoiceCode,
                TransactionNameAr = "فاتورة رقم " + invoiceVm.InvoiceCode
            };


            AccTransactionDetailVm accTransDetDebit = new AccTransactionDetailVm()
            {
                AccountId    = debitAccId,
                CreditAmount = 0,
                CurrencyId   = invoiceVm.InvCurrencyId,
                DebitAmount  = invoiceVm.InvoiceTotals.FirstOrDefault().TotalAmount
            };

            accTrans.AccTransactionDetails.Add(accTransDetDebit);

            AccTransactionDetailVm accTransDetCredit = new AccTransactionDetailVm()
            {
                AccountId    = creditAccountId,
                CreditAmount = invoiceVm.InvoiceTotals.FirstOrDefault().TotalAmount,
                CurrencyId   = invoiceVm.InvCurrencyId,
                DebitAmount  = 0
            };

            accTrans.AccTransactionDetails.Add(accTransDetCredit);

            int transId = AccountingHelper.AddTransaction(accTrans);

            //Update TransId in invoice table
            AccountingChartHelper.AddTransIdToObj(transId, "InvoiceAP", invoiceVm.InvoiceId, "InvoiceId");
        }
Example #4
0
        // GET: InvoiceController/Edit/5
        public ActionResult Edit(int id)
        {
            var vendors   = _vendorsRepository.FindAll();
            var vendorsId = vendors.Select(q => new SelectListItem {
                Text = q.VendorName, Value = q.ID.ToString()
            });

            var items   = _itemsRepo.FindAll();
            var itemsid = items.Select(q => new SelectListItem {
                Text = q.ItemName, Value = q.Id.ToString()
            });

            var itemscost = _itemsRepo.FindAll();
            var Icost     = itemscost.Select(q => new SelectListItem {
                Text = q.Cost.ToString(), Value = q.Cost.ToString()
            });

            var POnumber   = _POnumberRepo.FindAll();
            var POnumberid = POnumber.Select(q => new SelectListItem {
                Text = q.PurchaseOrderNumber.ToString(), Value = q.PurchaseOrderNumber.ToString()
            });

            var Invoice = _repo.FindbyId(id);
            var model   = _mapper.Map <InvoiceVm>(Invoice);

            model = new InvoiceVm
            {
                Vendors        = vendorsId,
                Item           = itemsid,
                PurchaseOrders = POnumberid,
                Itemcost       = Icost
            };

            if (!_repo.isExist(id))
            {
                return(NotFound());
            }

            return(View(model));
        }
Example #5
0
        public ActionResult Delete(int id, InvoiceVm model)
        {
            try
            {
                var Invoice = _repo.FindbyId(id);


                if (Invoice == null)
                {
                    return(NotFound());
                }
                var isvalid = _repo.Delete(Invoice);
                if (!isvalid)
                {
                    return(View(model));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }
Example #6
0
        public ActionResult Create(InvoiceVm model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var Invoice = _mapper.Map <Invoice>(model);
                var isValid = _repo.Create(Invoice);

                if (!isValid)
                {
                    ModelState.AddModelError("", "No Fields Affected");
                    return(View(model));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "No Fields Affected");
                return(View(model));
            }
        }
Example #7
0
        public ActionResult Edit(InvoiceVm model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var Invoice = _mapper.Map <Invoice>(model);
                var isvalid = _repo.Update(Invoice);

                if (!isvalid)
                {
                    ModelState.AddModelError("", "Could not edit Invoices. Try Again");
                    return(View(model));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Could not edit Invoices. Try Again");
                return(View());
            }
        }
Example #8
0
        /// <summary>
        /// Add Invoice amounts to the accounting transactions table
        /// </summary>
        /// <param name="clientAccId">shipeer/ consignee account Id</param>
        /// <param name="invVm">Invoice Vm obj</param>
        private static void AddInvToTransTable(string clientAccId, InvoiceVm invoiceVm)
        {
            AccTransactionVm accTrans = new AccTransactionVm()
            {
                CreateDate        = DateTime.Now,
                CreateBy          = EasyFreight.DAL.AdminHelper.GetCurrentUserId(),
                TransactionName   = "Invoice Number " + invoiceVm.InvoiceCode,
                TransactionNameAr = "فاتورة رقم " + invoiceVm.InvoiceCode
            };

            //Get Cost list
            //  var operCostObj = AccountingHelper.GetOperationCost(invoiceVm.OperationId, invoiceVm.HouseBillId);

            var operCostList      = invoiceVm.InvoiceDetails;
            var operCostTotalList = invoiceVm.InvoiceTotals;

            //GetHbInvTotal(invoiceVm.InvoiceType, ref operCostList, ref operCostTotalList);

            //Tax Deposit AccountId
            string taxDepositAccId = "";

            if (operCostTotalList.FirstOrDefault().TaxDepositAmount != 0)
            {
                taxDepositAccId = GetTaxDepositAccountId(invoiceVm.OrderFrom, invoiceVm.ShipperId, invoiceVm.ConsigneeId);
            }

            AccTransactionDetailVm accTransDetDebit;
            AccTransactionDetailVm accTransDetCredit;
            AccTransactionDetailVm accTransDetVAT;

            foreach (var item in operCostTotalList)
            {
                accTransDetDebit             = new AccTransactionDetailVm();
                accTransDetDebit.AccountId   = clientAccId;
                accTransDetDebit.DebitAmount = item.TotalAmount;
                accTransDetDebit.CurrencyId  = item.CurrencyId;


                accTransDetCredit              = new AccTransactionDetailVm();
                accTransDetCredit.AccountId    = ((int)AccountingChartEnum.SoldServices).ToString();
                accTransDetCredit.CreditAmount = item.TotalBeforeTax;
                accTransDetCredit.CurrencyId   = item.CurrencyId;

                accTrans.AccTransactionDetails.Add(accTransDetDebit);
                accTrans.AccTransactionDetails.Add(accTransDetCredit);

                if (item.VatTaxAmount != 0)
                {
                    accTransDetVAT              = new AccTransactionDetailVm();
                    accTransDetVAT.AccountId    = ((int)AccountingChartEnum.VAT).ToString();
                    accTransDetVAT.CreditAmount = item.VatTaxAmount;
                    accTransDetVAT.CurrencyId   = item.CurrencyId;
                    accTrans.AccTransactionDetails.Add(accTransDetVAT);
                }

                if (!string.IsNullOrEmpty(taxDepositAccId))
                {
                    AccTransactionDetailVm accTransTaxDepDebit = new AccTransactionDetailVm();
                    accTransTaxDepDebit.AccountId   = taxDepositAccId;
                    accTransTaxDepDebit.DebitAmount = item.TaxDepositAmount;
                    accTransTaxDepDebit.CurrencyId  = item.CurrencyId;
                    accTrans.AccTransactionDetails.Add(accTransTaxDepDebit);
                }
            }

            int transId = AccountingHelper.AddTransaction(accTrans);

            //Update TransId in invoice table
            AccountingChartHelper.AddTransIdToObj(transId, "Invoice", invoiceVm.InvoiceId, "InvoiceId");
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hbId"></param>
        /// <param name="operId"></param>
        /// <param name="invId"></param>
        /// <param name="invType">0 all currency, 1 EGP only, 2 other currency</param>
        /// <returns></returns>
        public static InvoiceVm GetInvoiceInfo(int hbId = 0, int operId = 0, int invId = 0, byte invType = 0)
        {
            InvoiceVm          invoiceVm = new InvoiceVm(invType);
            OperationsEntities db1       = new OperationsEntities();
            var hbInfo = db1.HouseBillViews.Where(x => x.HouseBillId == hbId).FirstOrDefault();

            //Get saved invoice for HB with same invoice type .. if any
            AccountingEntities db = new AccountingEntities();
            var savedInv          = db.Invoices.Where(x => x.HouseBillId == hbId && x.InvoiceType == invType).FirstOrDefault();

            if (savedInv != null)
            {
                invId = savedInv.InvoiceId;
            }

            //If invoice id != 0 ... will fill InvoiceVm from Invoice table
            if (invId != 0)
            {
                Invoice invDb = db.Invoices.Where(x => x.InvoiceId == invId).FirstOrDefault();
                Mapper.CreateMap <Invoice, InvoiceVm>().IgnoreAllNonExisting();
                Mapper.CreateMap <InvoiceTotal, InvoiceTotalVm>().IgnoreAllNonExisting();
                Mapper.Map(invDb, invoiceVm);

                invoiceVm.FromPort        = hbInfo.FromPort;
                invoiceVm.ToPort          = hbInfo.ToPort;
                invoiceVm.PaymentTermName = invDb.PaymentTerm.PaymentTermEn;
                invType = invDb.InvoiceType;
            }
            else
            {
                invoiceVm.InvoiceCode = AdminHelper.GeneratePrefixCode(PrefixForEnum.AccountingInvoice, false);
            }

            Mapper.CreateMap <HouseBillView, InvoiceVm>()
            .ForMember(x => x.CreateBy, y => y.Ignore())
            .ForMember(x => x.CreateDate, y => y.Ignore())
            .IgnoreAllNonExisting();
            Mapper.Map(hbInfo, invoiceVm);

            if (hbInfo.OrderFrom == 1)
            {
                invoiceVm.CustomerName = hbInfo.ShipperNameEn;
                invoiceVm.ConsigneeId  = null;
            }
            else
            {
                invoiceVm.CustomerName = hbInfo.ConsigneeNameEn;
                invoiceVm.ShipperId    = null;
            }

            //Get Cost list
            var operCostObj = AccountingHelper.GetOperationCost(invoiceVm.OperationId, invoiceVm.HouseBillId.Value);

            var operCostList      = operCostObj.OperationCostAccVms;
            var operCostTotalList = operCostObj.OperationCostTotalAccVms;

            GetHbInvTotal(invType, ref operCostList, ref operCostTotalList);

            invoiceVm.OperationCostAccVms      = operCostList;
            invoiceVm.OperationCostTotalAccVms = operCostTotalList;

            return(invoiceVm);
        }
Example #10
0
        internal static string AddEditInvoice(InvoiceVm invoiceVm)
        {
            string isSaved = "true";

            AccountingEntities db = new AccountingEntities();
            int  invoiceId        = invoiceVm.InvoiceId;
            byte invoiceType      = invoiceVm.InvoiceType;
            // int hbId = invoiceVm.HouseBillId;

            Invoice invDb;

            if (invoiceId == 0)
            {
                invDb = new Invoice();
            }
            else
            {
                invDb = db.Invoices.Include("InvoiceDetails").Include("InvoiceTotals")
                        .Where(x => x.InvoiceId == invoiceId).FirstOrDefault();
                //Delete Invoice details and totals .. will insert it again
                var invDbTotals  = invDb.InvoiceTotals;
                var invDbDetails = invDb.InvoiceDetails;
                foreach (var item in invDbDetails)
                {
                    invDb.InvoiceDetails.Remove(item);
                }
                foreach (var item in invDbTotals)
                {
                    invDb.InvoiceTotals.Remove(item);
                }
            }


            Mapper.CreateMap <InvoiceVm, Invoice>()
            .ForMember(x => x.InvoiceTotals, y => y.Ignore())
            .ForMember(x => x.InvoiceDetails, y => y.Ignore())
            .IgnoreAllNonExisting();
            Mapper.Map(invoiceVm, invDb);

            InvoiceDetail invDetail;

            Mapper.CreateMap <InvoiceDetailVm, InvoiceDetail>().IgnoreAllNonExisting();
            foreach (var item in invoiceVm.InvoiceDetails)
            {
                if (item.IsSelected == true)
                {
                    invDetail = new InvoiceDetail();
                    Mapper.Map(item, invDetail);
                    invDb.InvoiceDetails.Add(invDetail);
                }
            }

            InvoiceTotal invTotalDb;

            foreach (var item in invoiceVm.InvoiceTotals)
            {
                invTotalDb = new InvoiceTotal()
                {
                    CurrencyId       = item.CurrencyId,
                    TotalAmount      = item.TotalAmount,
                    CurrencySign     = item.CurrencySign,
                    TaxDepositAmount = item.TaxDepositAmount,
                    TotalBeforeTax   = item.TotalBeforeTax,
                    VatTaxAmount     = item.VatTaxAmount
                };

                invDb.InvoiceTotals.Add(invTotalDb);
            }



            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    //Add shipper or consignee to accounting chart
                    string accountId = GetAccountId(invoiceVm.OrderFrom, invoiceVm.ShipperId, invoiceVm.ConsigneeId);

                    if (invoiceId == 0)
                    {
                        invDb.InvoiceCode = AdminHelper.GeneratePrefixCode(PrefixForEnum.AccountingInvoice, true);
                        db.Invoices.Add(invDb);
                    }

                    db.SaveChanges();

                    invoiceVm.InvoiceId   = invDb.InvoiceId;
                    invoiceVm.InvoiceCode = invDb.InvoiceCode;


                    //Change HB status
                    if (invoiceId == 0)
                    {
                        //Add invoice to accounting transactions table
                        AddInvToTransTable(accountId, invoiceVm);

                        HouseBillHelper.ChangeHBStatus(invDb.HouseBillId, (byte)StatusEnum.InvoiceIssued);
                        OperationHelper.ChangeOperationStatus(invDb.OperationId, (byte)StatusEnum.InvoiceIssued);
                    }

                    transaction.Complete();
                }
                catch (DbEntityValidationException e)
                {
                    isSaved = "false " + e.Message;

                    //AdminHelper.LastIdRemoveOne(PrefixForEnum.AccountingInvoice);
                }
                catch (Exception e)
                {
                    isSaved = "false " + e.Message;
                    //AdminHelper.LastIdRemoveOne(PrefixForEnum.AccountingInvoice);
                }
            }

            return(isSaved);
        }
Example #11
0
        public ActionResult AddEditInvoice(InvoiceVm invoiceVm)
        {
            string isSaved = InvoiceHelper.AddEditInvoice(invoiceVm);

            return(Json(isSaved));
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="operId"></param>
        /// <param name="invId"></param>
        /// <param name="invFor">if = 1  Invoice for Carrier .. if 2 invoice for Contractor .. if 3 custom clearance</param>
        /// <param name="forEdit"></param>
        /// <returns></returns>
        public static InvoiceVm GetInvoiceInfoFullOperation(int operId = 0, int invId = 0, byte invFor = 1, bool forEdit = true)
        {
            InvoiceVm          invoiceVm = new InvoiceVm(invFor);
            AccountingEntities db        = new AccountingEntities();

            if (invId != 0)
            {
                InvoiceAP invDb = db.InvoiceAPs.Include("InvoiceDetailAPs").Include("InvoiceTotalAPs")
                                  .Where(x => x.InvoiceId == invId && x.IsDeleted == null).FirstOrDefault();
                Mapper.CreateMap <InvoiceAP, InvoiceVm>()
                .IgnoreAllNonExisting();

                Mapper.Map(invDb, invoiceVm);

                Mapper.CreateMap <InvoiceDetailAP, InvoiceDetailVm>().IgnoreAllNonExisting();
                Mapper.CreateMap <InvoiceTotalAP, InvoiceTotalVm>().IgnoreAllNonExisting();

                InvoiceDetailVm invDetVm;
                foreach (var item in invDb.InvoiceDetailAPs)
                {
                    invDetVm = new InvoiceDetailVm();
                    Mapper.Map(item, invDetVm);
                    invoiceVm.InvoiceDetails.Add(invDetVm);
                }

                InvoiceTotalVm invTotalVm;
                foreach (var item in invDb.InvoiceTotalAPs)
                {
                    invTotalVm = new InvoiceTotalVm();
                    Mapper.Map(item, invTotalVm);
                    invoiceVm.InvoiceTotals.Add(invTotalVm);
                }


                invoiceVm.PaymentTermName = invDb.PaymentTerm.PaymentTermEn;
                invoiceVm.CurrencySign    = invDb.Currency.CurrencySign;
            }
            else
            {
                invoiceVm.InvoiceCode = AdminHelper.GeneratePrefixCode(PrefixForEnum.APInvoice, false);
            }

            if (operId == 0)
            {
                operId = invoiceVm.OperationId;
            }

            OperationsEntities db1 = new OperationsEntities();
            var hbInfo             = db1.OperationViews.Where(x => x.OperationId == operId).FirstOrDefault();

            Mapper.CreateMap <OperationView, InvoiceVm>()
            .ForMember(x => x.CreateBy, y => y.Ignore())
            .ForMember(x => x.CreateDate, y => y.Ignore())
            .IgnoreAllNonExisting();
            Mapper.Map(hbInfo, invoiceVm);

            if (invFor == 1) //Carrier
            {
                invoiceVm.ContractorId = null;
                invoiceVm.SupplierName = hbInfo.CarrierNameEn;
                invoiceVm.CustomerName = hbInfo.CarrierNameEn;
            }
            else if (invFor == 2)
            {
                var contractorInfo = db1.TruckingOrdersViews
                                     .Where(x => x.OperationId == operId)
                                     .Select(x => new { x.ContractorId, x.ContractorNameEn })
                                     .FirstOrDefault();
                if (contractorInfo != null)
                {
                    invoiceVm.CarrierId    = null;
                    invoiceVm.SupplierName = contractorInfo.ContractorNameEn;
                    invoiceVm.ContractorId = contractorInfo.ContractorId;
                    invoiceVm.CustomerName = contractorInfo.ContractorNameEn;
                }
            }
            else if (invFor == 3)
            {
                invoiceVm.SupplierName = "Custom Clearance";
                invoiceVm.CustomerName = "Custom Clearance";
            }

            //Get Cost list
            var operCostObj = AccountingHelper.GetOperationCost(invoiceVm.OperationId, 0);

            var operCostList      = operCostObj.OperationCostAccVms;
            var operCostTotalList = operCostObj.OperationCostTotalAccVms;

            // GetHbInvTotal(0, ref operCostList, ref operCostTotalList);

            invoiceVm.OperationCostAccVms      = operCostList;
            invoiceVm.OperationCostTotalAccVms = operCostTotalList;

            if (forEdit)
            {
                //Get prev invoice details for this HB
                var prevInvDetails = db.InvoiceDetailAPs
                                     .Where(x => x.InvoiceAP.OperationId == operId && x.InvoiceAP.IsDeleted == null)
                                     .Select(x => new { x.CostFkId, x.FkType })
                                     .ToList();

                InvoiceDetailVm invDetailVm;
                //invFor == 1 ..get operation cost only
                //invFor == 2 ..get trucking cost only
                //invFor == 3 ..get custom clearance cost only
                List <int> usedCost = invoiceVm.InvoiceDetails.Where(x => x.FkType == invFor).Select(x => x.CostFkId).ToList();
                usedCost.AddRange(prevInvDetails.Where(x => x.FkType == invFor).Select(x => x.CostFkId).ToList());
                var newCosts = operCostList.Where(x => !usedCost.Contains(x.CostFkId) && x.FkType == invFor).ToList();

                foreach (var item in newCosts.Where(x => x.NetRate > 0))
                {
                    invDetailVm = new InvoiceDetailVm()
                    {
                        CostFkId       = item.CostFkId,
                        CostName       = item.CostName,
                        ExchangeRate   = 1,
                        FkType         = item.FkType,
                        InvDetailId    = 0,
                        InvoiceAmount  = item.NetRate,
                        InvoiceId      = invoiceVm.InvoiceId,
                        MainAmount     = item.NetRate,
                        MainCurrencyId = item.CurrencyId,
                        MainCurrSign   = item.CurrencySign
                    };

                    invoiceVm.InvoiceDetails.Add(invDetailVm);
                }

                if (invoiceVm.InvoiceTotals.Count == 0)
                {
                    InvoiceTotalVm invTotal = new InvoiceTotalVm()
                    {
                        CurrencyId   = invoiceVm.InvCurrencyId,
                        CurrencySign = invoiceVm.CurrencySign,
                        InvoiceId    = invoiceVm.InvoiceId,
                        TotalAmount  = 0
                    };

                    invoiceVm.InvoiceTotals.Add(invTotal);
                }
            }
            else
            {
                Dictionary <int, string> operCost  = new Dictionary <int, string>();
                Dictionary <int, string> truckCost = new Dictionary <int, string>();
                Dictionary <int, string> ccCost    = new Dictionary <int, string>();
                if (invoiceVm.InvoiceDetails.Any(x => x.FkType == (byte)CostType.OperationCost))
                {
                    operCost = ListCommonHelper.GetOperationCostList();
                }
                else if (invoiceVm.InvoiceDetails.Any(x => x.FkType == (byte)CostType.TruckingCost))
                {
                    truckCost = ListCommonHelper.GetTruckingCostNameList();
                }
                else if (invoiceVm.InvoiceDetails.Any(x => x.FkType == (byte)CostType.CCCost))
                {
                    ccCost = ListCommonHelper.GetCustClearCostList();
                }
                //Get cost name for invoice items
                foreach (var item in invoiceVm.InvoiceDetails)
                {
                    item.CostName = invoiceVm.OperationCostAccVms
                                    .Where(x => x.CostFkId == item.CostFkId && x.FkType == item.FkType)
                                    .FirstOrDefault().CostName;
                }
            }

            return(invoiceVm);
        }
 public async Task BlInser(InvoiceVm Category)
 {
     var addMap = Mapper.Map <InvoiceVm, Invoice>(Category);
     await _invoice.InsertAsync(addMap);
 }
Example #14
0
        internal static string AddEditInvoice(InvoiceVm invoiceVm)
        {
            string isSaved = "true";

            AccountingEntities db = new AccountingEntities();
            int  invoiceId        = invoiceVm.InvoiceId;
            byte invFor           = invoiceVm.InvoiceType;
            //  int hbId = invoiceVm.HouseBillId;

            InvoiceAP invDb;

            if (invoiceId == 0)
            {
                invDb = new InvoiceAP();
            }
            else
            {
                invDb = db.InvoiceAPs.Include("InvoiceDetailAPs").Include("InvoiceTotalAPs")
                        .Where(x => x.InvoiceId == invoiceId).FirstOrDefault();
                //Delete Invoice details and totals .. will insert it again
                var invDbTotals  = invDb.InvoiceTotalAPs;
                var invDbDetails = invDb.InvoiceDetailAPs;
                foreach (var item in invDbDetails)
                {
                    invDb.InvoiceDetailAPs.Remove(item);
                }
                foreach (var item in invDbTotals)
                {
                    invDb.InvoiceTotalAPs.Remove(item);
                }
            }


            Mapper.CreateMap <InvoiceVm, InvoiceAP>()
            .ForMember(x => x.InvoiceTotalAPs, y => y.Ignore())
            .ForMember(x => x.InvoiceDetailAPs, y => y.Ignore())
            .IgnoreAllNonExisting();
            Mapper.Map(invoiceVm, invDb);

            InvoiceDetailAP invDetail;

            Mapper.CreateMap <InvoiceDetailVm, InvoiceDetailAP>().IgnoreAllNonExisting();
            foreach (var item in invoiceVm.InvoiceDetails)
            {
                if (item.IsSelected == true)
                {
                    invDetail = new InvoiceDetailAP();
                    Mapper.Map(item, invDetail);
                    invDb.InvoiceDetailAPs.Add(invDetail);
                }
            }

            InvoiceTotalAP invTotalDb;

            foreach (var item in invoiceVm.InvoiceTotals)
            {
                invTotalDb = new InvoiceTotalAP()
                {
                    CurrencyId   = item.CurrencyId,
                    TotalAmount  = item.TotalAmount,
                    CurrencySign = item.CurrencySign
                };

                invDb.InvoiceTotalAPs.Add(invTotalDb);
            }



            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    //Add shipper or consignee to accounting chart
                    string creditAccountId = "";
                    if (invFor == 1) //carrier
                    {
                        creditAccountId = AccountingChartHelper
                                          .GetAccountIdByPkAndTbName(invoiceVm.CarrierId.Value, "Carrier", "CarrierId");
                        if (string.IsNullOrEmpty(creditAccountId))
                        {
                            creditAccountId = AccountingChartHelper.AddCarrierToChart(invoiceVm.CarrierId.Value);
                        }
                    }
                    else if (invFor == 2) //Contractor
                    {
                        creditAccountId = AccountingChartHelper
                                          .GetAccountIdByPkAndTbName(invoiceVm.ContractorId.Value, "Contractor", "ContractorId");
                        if (string.IsNullOrEmpty(creditAccountId))
                        {
                            creditAccountId = AccountingChartHelper.AddContractorToChart(invoiceVm.ContractorId.Value);
                        }
                    }
                    else if (invFor == 3) //Custom Clearance
                    {
                        creditAccountId = AccountingChartHelper.GetCCCashDepAccountId(invoiceVm.OperationId);

                        if (!string.IsNullOrEmpty(creditAccountId))
                        {
                            invDb.InvStatusId = 4; //paid with cash deposit
                        }
                        else // In this case there was no cash deposit paid .. I added an account to sotre
                             //any credit amount for custom clearance
                        {
                            creditAccountId = ((int)AccountingChartEnum.CustomClearanceSupplier).ToString();
                        }
                    }

                    if (invoiceId == 0)
                    {
                        invDb.InvoiceCode = AdminHelper.GeneratePrefixCode(PrefixForEnum.APInvoice, true);
                        db.InvoiceAPs.Add(invDb);
                    }

                    db.SaveChanges();

                    invoiceVm.InvoiceId   = invDb.InvoiceId;
                    invoiceVm.InvoiceCode = invDb.InvoiceCode;

                    //Change HB status
                    if (invoiceId == 0)
                    {
                        //Add invoice to accounting transactions table
                        if (!string.IsNullOrEmpty(creditAccountId))
                        {
                            AddAPInvToTransTable(creditAccountId, invoiceVm);
                        }

                        //if (invFor == 3) //Custom Clearance
                        if (invFor == 3) //will link the cash out receipts with same currency to this invoice as it is paid
                        {
                            int     operId     = invoiceVm.OperationId;
                            int     savedInvId = invoiceVm.InvoiceId;
                            int     currId     = invoiceVm.InvCurrencyId;
                            decimal invAmount  = invoiceVm.InvoiceTotals.FirstOrDefault().TotalAmount;
                            //Get cashout receiptIds
                            var cashoutReceiptIds = db.CashOutReceipts.Include("CashOutReceiptInvs")
                                                    .Where(x => x.OperationId == operId && x.CurrencyId == currId)
                                                    .ToList();

                            CashOutReceiptInv cashOutReceiptInv;
                            decimal           prevPaidFromReceipt, receiptAmount, amountToPay = 0;

                            foreach (var item in cashoutReceiptIds)
                            {
                                receiptAmount = item.ReceiptAmount;

                                //Get what paid before by this receipt
                                prevPaidFromReceipt = item.CashOutReceiptInvs.Sum(x => x.PaidAmount);
                                amountToPay         = receiptAmount - prevPaidFromReceipt;
                                if (amountToPay <= 0) //This receipt total amount is used by another invoices
                                {
                                    continue;
                                }

                                if (invAmount <= 0) //This Invoice is total paid
                                {
                                    break;
                                }

                                if (amountToPay > invAmount)
                                {
                                    amountToPay = invAmount;
                                }

                                //Add cash out receipt invoice
                                cashOutReceiptInv            = new CashOutReceiptInv();
                                cashOutReceiptInv.ReceiptId  = item.ReceiptId;
                                cashOutReceiptInv.InvoiceId  = savedInvId;
                                cashOutReceiptInv.PaidAmount = amountToPay;

                                db.CashOutReceiptInvs.Add(cashOutReceiptInv);

                                invAmount = invAmount - amountToPay;
                            }

                            db.SaveChanges();
                        }
                        // HouseBillHelper.ChangeHBStatus(invDb.HouseBillId, (byte)StatusEnum.InvoiceIssued);
                        OperationHelper.ChangeOperationStatus(invDb.OperationId, (byte)StatusEnum.InvoiceIssued);
                    }

                    transaction.Complete();
                }
                catch (DbEntityValidationException e)
                {
                    isSaved = "false " + e.Message;

                    //AdminHelper.LastIdRemoveOne(PrefixForEnum.AccountingInvoice);
                }
                catch (Exception e)
                {
                    isSaved = "false " + e.Message;
                    //AdminHelper.LastIdRemoveOne(PrefixForEnum.AccountingInvoice);
                }
            }

            return(isSaved);
        }
 public async Task BlUpdateAsync(InvoiceVm Category)
 {
     var editMap = Mapper.Map <InvoiceVm, Invoice>(Category);
     await _invoice.UpdateAsync(editMap);
 }
Example #16
0
        public static InvoiceVm GetInvoiceInfoNew(int hbId = 0, int invId = 0, bool forEdit = true)
        {
            InvoiceVm invoiceVm = new InvoiceVm(0);


            AccountingEntities db = new AccountingEntities();

            if (invId != 0)
            {
                Invoice invDb = db.Invoices.Where(x => x.InvoiceId == invId).FirstOrDefault();
                Mapper.CreateMap <Invoice, InvoiceVm>().IgnoreAllNonExisting();
                Mapper.CreateMap <InvoiceDetail, InvoiceDetailVm>().IgnoreAllNonExisting();
                Mapper.CreateMap <InvoiceTotal, InvoiceTotalVm>().IgnoreAllNonExisting();
                Mapper.Map(invDb, invoiceVm);

                //invoiceVm.FromPort = hbInfo.FromPort;
                //invoiceVm.ToPort = hbInfo.ToPort;
                invoiceVm.PaymentTermName = invDb.PaymentTerm.PaymentTermEn;
                invoiceVm.CurrencySign    = invDb.Currency.CurrencySign;
                //invType = invDb.InvoiceType;

                //Add Tax part
                //decimal totalBeforeTax = invoiceVm.InvoiceDetails.Sum(x => x.InvoiceAmount);
                // invoiceVm.InvoiceTotals.FirstOrDefault().TotalBeforeTax = totalBeforeTax;
                // invoiceVm.InvoiceTotals.FirstOrDefault().TaxDepositAmount = totalBeforeTax - invoiceVm.InvoiceTotals.FirstOrDefault().TotalAmount;
            }
            else
            {
                invoiceVm.InvoiceCode = AdminHelper.GeneratePrefixCode(PrefixForEnum.AccountingInvoice, false);
            }

            if (hbId == 0)
            {
                hbId = invoiceVm.HouseBillId.Value;
            }

            OperationsEntities db1 = new OperationsEntities();
            var hbInfo             = db1.HouseBillViews.Where(x => x.HouseBillId == hbId).FirstOrDefault();

            Mapper.CreateMap <HouseBillView, InvoiceVm>()
            .ForMember(x => x.CreateBy, y => y.Ignore())
            .ForMember(x => x.CreateDate, y => y.Ignore())
            .IgnoreAllNonExisting();
            Mapper.Map(hbInfo, invoiceVm);

            if (hbInfo.OrderFrom == 1)
            {
                invoiceVm.CustomerName = hbInfo.ShipperNameEn;
                invoiceVm.ConsigneeId  = null;
            }
            else
            {
                invoiceVm.CustomerName = hbInfo.ConsigneeNameEn;
                invoiceVm.ShipperId    = null;
            }

            //Get Cost list
            var operCostObj = AccountingHelper.GetOperationCost(invoiceVm.OperationId, invoiceVm.HouseBillId.Value);

            var operCostList      = operCostObj.OperationCostAccVms;
            var operCostTotalList = operCostObj.OperationCostTotalAccVms;

            GetHbInvTotal(0, ref operCostList, ref operCostTotalList);

            invoiceVm.OperationCostAccVms      = operCostList;
            invoiceVm.OperationCostTotalAccVms = operCostTotalList;



            if (forEdit)
            {
                //Get prev invoice details for this HB
                // adding condation  [x.Invoice.IsDeleted==null] get undeleted invoices
                var prevInvDetails = db.InvoiceDetails
                                     .Where(x => x.Invoice.HouseBillId == hbId && x.Invoice.IsDeleted == null).OrderBy(x => x.ItemOrder)
                                     .Select(x => new { x.CostFkId, x.FkType })
                                     .ToList();
                InvoiceDetailVm invDetailVm;
                //Add other costs that are not inserted in inv details table
                for (int i = 1; i < 4; i++) // loop for the three cost types
                {
                    List <int> usedCost = invoiceVm.InvoiceDetails.Where(x => x.FkType == i).Select(x => x.CostFkId).ToList();
                    usedCost.AddRange(prevInvDetails.Where(x => x.FkType == i).Select(x => x.CostFkId).ToList());
                    var newCosts = operCostList.Where(x => !usedCost.Contains(x.CostFkId) && x.FkType == i).ToList();
                    foreach (var item in newCosts)
                    {
                        invDetailVm = new InvoiceDetailVm()
                        {
                            CostFkId       = item.CostFkId,
                            CostName       = item.CostName,
                            ExchangeRate   = 1,
                            FkType         = item.FkType,
                            InvDetailId    = 0,
                            InvoiceAmount  = item.SellingRate,
                            InvoiceId      = invoiceVm.InvoiceId,
                            MainAmount     = item.SellingRate,
                            MainCurrencyId = item.CurrencyIdSelling,
                            MainCurrSign   = item.CurrencySignSelling
                        };

                        invoiceVm.InvoiceDetails.Add(invDetailVm);
                    }
                }

                if (invoiceVm.InvoiceTotals.Count == 0)
                {
                    InvoiceTotalVm invTotal = new InvoiceTotalVm()
                    {
                        CurrencyId   = invoiceVm.InvCurrencyId,
                        CurrencySign = invoiceVm.CurrencySign,
                        InvoiceId    = invoiceVm.InvoiceId,
                        TotalAmount  = 0
                    };

                    invoiceVm.InvoiceTotals.Add(invTotal);
                }
            }
            else
            {
                Dictionary <int, string> operCost  = new Dictionary <int, string>();
                Dictionary <int, string> truckCost = new Dictionary <int, string>();
                Dictionary <int, string> ccCost    = new Dictionary <int, string>();
                if (invoiceVm.InvoiceDetails.Any(x => x.FkType == (byte)CostType.OperationCost))
                {
                    operCost = ListCommonHelper.GetOperationCostList();
                }
                if (invoiceVm.InvoiceDetails.Any(x => x.FkType == (byte)CostType.TruckingCost))
                {
                    truckCost = ListCommonHelper.GetTruckingCostNameList();
                }
                if (invoiceVm.InvoiceDetails.Any(x => x.FkType == (byte)CostType.CCCost))
                {
                    ccCost = ListCommonHelper.GetCustClearCostList();
                }
                //Get cost name for invoice items
                foreach (var item in invoiceVm.InvoiceDetails)
                {
                    item.CostName = invoiceVm.OperationCostAccVms
                                    .Where(x => x.CostFkId == item.CostFkId && x.FkType == item.FkType)
                                    .FirstOrDefault().CostName;
                }
            }
            invoiceVm.InvoiceDetails = invoiceVm.InvoiceDetails.OrderBy(z => z.ItemOrder).ToList();
            return(invoiceVm);
        }
Example #17
0
        public ActionResult BulkInvoice(string ids)
        {
            int numOfLineInInvoice       = 8;
            List <InvoiceVm> invoiceList = new List <InvoiceVm>();

            var orderid = ids.Split(',').Select(Int32.Parse).ToList();

            var inv = Db.tblt_Order.Where(x => orderid.Contains(x.Orderid));

            foreach (var invitem in inv)
            {
                int id   = invitem.Orderid;
                int dbid = invitem.db_id;

                InvoiceVm invoiceVm = new InvoiceVm();

                var invoiceLineItemSdata = (from a in Db.tblt_Order_line
                                            join b in Db.tbld_SKU on a.sku_id equals b.SKU_id
                                            where a.Orderid == id
                                            orderby a.id ascending
                                            select new InvoiceLineDetilsVm
                {
                    SkuCode = b.SKUcode,
                    SkuId = a.sku_id,
                    SkuName = b.SKUName,
                    BetchId = a.Betch_id,
                    PackSize = a.Pack_size
                }).Distinct().ToList();
                var numberofmemo = (double)invoiceLineItemSdata.Count() / numOfLineInInvoice;
                if (numberofmemo <= 1)
                {
                    List <InvoiceLineDetilsVm> invoiceLineItem = new List <InvoiceLineDetilsVm>();
                    var outlet  = Db.tbld_Outlet.SingleOrDefault(x => x.OutletId == invitem.outlet_id);
                    var dbHouse = Db.tbld_distribution_house.SingleOrDefault(x => x.DB_Id == invitem.db_id);
                    var psrInfo = Db.tbld_distribution_employee.SingleOrDefault(x => x.id == invitem.psr_id);

                    var totalDelivered   = (int)(invitem.total_delivered ?? 0);
                    var salesOrderTypeId = invitem.sales_order_type_id ?? 0;
                    var manualDiscount   = (int)(invitem.manual_discount ?? 0);

                    if (outlet != null)
                    {
                        if (dbHouse != null)
                        {
                            if (psrInfo != null)
                            {
                                invoiceVm = new InvoiceVm
                                {
                                    Orderid   = id,
                                    SoId      = invitem.so_id,
                                    RouteName = Db.tbld_distributor_Route
                                                .Where(x => x.RouteID == invitem.route_id)
                                                .Select(x => x.RouteName).SingleOrDefault(),
                                    OutletName       = outlet.OutletName,
                                    OutletAddress    = outlet.Address,
                                    ChallanNo        = invitem.Challan_no,
                                    PlannedOrderDate = invitem.planned_order_date,
                                    DeliveryDate     = invitem.delivery_date,
                                    DbName           = dbHouse.DBName ?? "",
                                    DbAddress        = dbHouse.OfficeAddress,
                                    DbMobile         = dbHouse.OwnerMoble,
                                    PsrName          = psrInfo.Name,
                                    PsrMobile        = psrInfo.contact_no,
                                    TotalDelivered   = totalDelivered,
                                    SalesOrderTypeId = salesOrderTypeId,
                                    ManualDiscount   = manualDiscount
                                }
                            }
                        }
                    }
                    ;



                    foreach (var lineItem in invoiceLineItemSdata)
                    {
                        int confirmQty = 0;
                        int freeQty    = 0;

                        double unitSalePrice = (from a in Db.tbld_bundle_price_details
                                                join b in Db.tbld_distribution_house on a.bundle_price_id equals b.PriceBuandle_id
                                                where a.sku_id == lineItem.SkuId && a.batch_id == lineItem.BetchId && b.DB_Id == dbid
                                                select a.outlet_lifting_price).SingleOrDefault();


                        var orderQtysum = (from b in Db.tblt_Order_line
                                           where b.Orderid == id && b.sku_id == lineItem.SkuId &&
                                           b.Betch_id == lineItem.BetchId && b.sku_order_type_id == 1
                                           select(int?) b.quantity_delivered).Sum();

                        var freeQtysum = (from b in Db.tblt_Order_line
                                          where b.Orderid == id && b.sku_id == lineItem.SkuId &&
                                          b.Betch_id == lineItem.BetchId && b.sku_order_type_id == 2
                                          select(int?) b.quantity_delivered).Sum();

                        if (orderQtysum != null)
                        {
                            confirmQty = (int)orderQtysum;
                        }

                        if (freeQtysum != null)
                        {
                            freeQty = (int)freeQtysum;
                        }
                        var totalSalePrice = Db.tblt_Order_line
                                             .Where(b => b.Orderid == id && b.sku_id == lineItem.SkuId &&
                                                    b.Betch_id == lineItem.BetchId &&
                                                    b.sku_order_type_id == 1)
                                             .Sum(x => (double?)(x.total_sale_price)) ?? 0;
                        var totalDiscountAmount = Db.tblt_Order_line
                                                  .Where(b => b.Orderid == id && b.sku_id == lineItem.SkuId &&
                                                         b.Betch_id == lineItem.BetchId &&
                                                         b.sku_order_type_id == 1)
                                                  .Sum(x => (double?)(x.total_discount_amount)) ?? 0;
                        var totalBilledAmount = Db.tblt_Order_line
                                                .Where(b => b.Orderid == id && b.sku_id == lineItem.SkuId &&
                                                       b.Betch_id == lineItem.BetchId &&
                                                       b.sku_order_type_id == 1)
                                                .Sum(x => (double?)(x.total_billed_amount)) ?? 0;

                        InvoiceLineDetilsVm invoiceLineDetilsVm = new InvoiceLineDetilsVm
                        {
                            SkuCode             = lineItem.SkuCode,
                            SkuName             = lineItem.SkuName,
                            BetchId             = lineItem.BetchId,
                            PackSize            = lineItem.PackSize,
                            UnitSalePrice       = confirmQty == 0 ? 0 : unitSalePrice,
                            QuantityDeliveredCs = confirmQty / lineItem.PackSize,
                            QuantityDeliveredPs = confirmQty % lineItem.PackSize,
                            QuantityFree        = freeQty,
                            TotalSalePrice      = Math.Round(totalSalePrice),
                            TotalDiscountAmount = Math.Round(totalDiscountAmount),
                            TotalBilledAmount   = Math.Round(totalBilledAmount)
                        };
                        invoiceLineItem.Add(invoiceLineDetilsVm);
                    }


                    invoiceVm.InvoiceLine = invoiceLineItem;
                    invoiceList.Add(invoiceVm);
                }
                else
                {
                    double numberofInvoice = (double)invoiceLineItemSdata.Count() / numOfLineInInvoice;

                    for (int j = 0; j <= numberofInvoice; j++)
                    {
                        List <InvoiceLineDetilsVm> invoiceLineItem = new List <InvoiceLineDetilsVm>();


                        var outlet  = Db.tbld_Outlet.SingleOrDefault(x => x.OutletId == invitem.outlet_id);
                        var dbHouse =
                            Db.tbld_distribution_house.SingleOrDefault(x => x.DB_Id == invitem.db_id);
                        var psrInfo =
                            Db.tbld_distribution_employee.SingleOrDefault(x => x.id == invitem.psr_id);

                        var totalDelivered   = (int)(invitem.total_delivered ?? 0);
                        var salesOrderTypeId = invitem.sales_order_type_id ?? 0;
                        var manualDiscount   = (int)(invitem.manual_discount ?? 0);

                        if (outlet != null)
                        {
                        }
                        if (dbHouse != null)
                        {
                        }
                        if (psrInfo != null)
                        {
                        }
                        invoiceVm = new InvoiceVm
                        {
                            Orderid   = id,
                            SoId      = invitem.so_id,
                            RouteName = Db.tbld_distributor_Route
                                        .Where(x => x.RouteID == invitem.route_id)
                                        .Select(x => x.RouteName).SingleOrDefault(),
                            OutletName       = outlet.OutletName,
                            OutletAddress    = outlet.Address,
                            ChallanNo        = invitem.Challan_no,
                            PlannedOrderDate = invitem.planned_order_date,
                            DeliveryDate     = invitem.delivery_date,
                            DbName           = dbHouse.DBName ?? "",
                            DbAddress        = dbHouse.OfficeAddress,
                            DbMobile         = dbHouse.OwnerMoble,
                            PsrName          = psrInfo.Name,
                            PsrMobile        = psrInfo.contact_no,
                            TotalDelivered   = totalDelivered,
                            SalesOrderTypeId = salesOrderTypeId,
                            ManualDiscount   = manualDiscount
                        };



                        foreach (var lineItem in invoiceLineItemSdata.Take(numOfLineInInvoice))
                        {
                            int confirmQty = 0;
                            int freeQty    = 0;

                            double unitSalePrice = (from a in Db.tbld_bundle_price_details
                                                    join b in Db.tbld_distribution_house on a.bundle_price_id equals b
                                                    .PriceBuandle_id
                                                    where a.sku_id == lineItem.SkuId && a.batch_id == lineItem.BetchId &&
                                                    b.DB_Id == dbid
                                                    select a.outlet_lifting_price).SingleOrDefault();


                            var orderQtysum = (from b in Db.tblt_Order_line
                                               where b.Orderid == id && b.sku_id == lineItem.SkuId &&
                                               b.Betch_id == lineItem.BetchId && b.sku_order_type_id == 1
                                               select(int?) b.quantity_delivered).Sum();

                            var freeQtysum = (from b in Db.tblt_Order_line
                                              where b.Orderid == id && b.sku_id == lineItem.SkuId &&
                                              b.Betch_id == lineItem.BetchId && b.sku_order_type_id == 2
                                              select(int?) b.quantity_delivered).Sum();

                            if (orderQtysum != null)
                            {
                                confirmQty = (int)orderQtysum;
                            }

                            if (freeQtysum != null)
                            {
                                freeQty = (int)freeQtysum;
                            }
                            var totalSalePrice = Db.tblt_Order_line
                                                 .Where(b => b.Orderid == id &&
                                                        b.sku_id == lineItem.SkuId &&
                                                        b.Betch_id == lineItem.BetchId &&
                                                        b.sku_order_type_id == 1)
                                                 .Sum(x => (double?)(x.total_sale_price)) ?? 0;
                            var totalDiscountAmount = Db.tblt_Order_line
                                                      .Where(b => b.Orderid == id &&
                                                             b.sku_id == lineItem.SkuId &&
                                                             b.Betch_id == lineItem.BetchId &&
                                                             b.sku_order_type_id == 1)
                                                      .Sum(x => (double?)(x.total_discount_amount)) ?? 0;
                            var totalBilledAmount = Db.tblt_Order_line
                                                    .Where(b => b.Orderid == id &&
                                                           b.sku_id == lineItem.SkuId &&
                                                           b.Betch_id == lineItem.BetchId &&
                                                           b.sku_order_type_id == 1)
                                                    .Sum(x => (double?)(x.total_billed_amount)) ?? 0;

                            InvoiceLineDetilsVm invoiceLineDetilsVm = new InvoiceLineDetilsVm
                            {
                                SkuCode             = lineItem.SkuCode,
                                SkuName             = lineItem.SkuName,
                                BetchId             = lineItem.BetchId,
                                PackSize            = lineItem.PackSize,
                                UnitSalePrice       = confirmQty == 0 ? 0 : unitSalePrice,
                                QuantityDeliveredCs = confirmQty / lineItem.PackSize,
                                QuantityDeliveredPs = confirmQty % lineItem.PackSize,
                                QuantityFree        = freeQty,
                                TotalSalePrice      = totalSalePrice,
                                TotalDiscountAmount = totalDiscountAmount,
                                TotalBilledAmount   = totalBilledAmount
                            };
                            invoiceLineItem.Add(invoiceLineDetilsVm);
                        }


                        invoiceVm.InvoiceLine = invoiceLineItem;

                        invoiceList.Add(invoiceVm);
                        if (invoiceLineItemSdata.Count() >= numOfLineInInvoice)
                        {
                            invoiceLineItemSdata.RemoveRange(0, numOfLineInInvoice);
                        }
                    }
                }
            }

            return(PartialView("TradePromotionSales/BulkInvoice", invoiceList));
        }
Example #18
0
        public ActionResult ViewInvoice(int id, int hbId, byte invFor, int operId = 0)
        {
            InvoiceVm invObj = APInvoiceHelper.GetInvoiceInfoFullOperation(operId, id, invFor, false);

            return(View("~/Views/Invoice/ViewInvoice.cshtml", invObj));
        }