Ejemplo n.º 1
0
        public void PrepareContractPaymentAdvanceModel(ContractPaymentAdvanceModel model, ContractPaymentAdvance item)
        {
            string treeTam = "";
            var    units   = _unitService.GetAllUnits();

            model.AvailableUnit = units.Select(c => new SelectListItem
            {
                Text     = treeTam.PadLeft((int)c.TreeLevel - 1, '-') + c.Name,
                Value    = c.Id.ToString(),
                Selected = c.Id == model.UnitId
            }).ToList();
            model.AvailableUnit.Insert(0,
                                       new SelectListItem
            {
                Value = "0",
                Text  = "--Chọn đơn vị--"
            });
            var currencys = _currencyService.GetAllCurrencies();

            model.listCurrency = currencys.Select(c => new SelectListItem
            {
                Text     = c.Name,
                Value    = c.Id.ToString(),
                Selected = c.Id == model.CurrencyId
            }).ToList();
            //model.listCurrency.Insert(0, new SelectListItem
            //{
            //    Value = "0",
            //    Text = "--Chọn đơn vị tiền---"
            //});
        }
Ejemplo n.º 2
0
        public virtual IActionResult _AdvanceContracts(int UnitId)
        {
            var model     = new ContractPaymentAdvanceModel();
            var Contracts = _contractService.getAllContractbyUnitId(UnitId);

            model.listContractModel = Contracts.Select(c => c.ToModel <ContractModel>()).ToList();
            return(PartialView(model));
        }
Ejemplo n.º 3
0
        public virtual IActionResult Create(ContractPaymentAdvanceModel model)
        {
            var noti = "admin.common.Added";
            var item = new ContractPaymentAdvance();

            //var ListAcceptance = model.ListContractAcceptance.Where(c => c.TotalAmount.ToNumber() > 0).ToList();

            if (ModelState.IsValid && model.ListContractAcceptance.Count > 0)
            {
                if (model.Id > 0)
                {
                    var acceptances = _contractService.getAllContractAcceptanceByAdvanceId(model.Id);
                    foreach (ContractAcceptance acceptance in acceptances)
                    {
                        _contractService.DeleteContractAcceptance(acceptance);
                        _contractService.DeleteContractAcceptanceTaskMappingbyAcceptanceId(acceptance.Id);
                    }
                    item = _paymentAdvanceService.GetPaymentAdvanceById(model.Id);
                    _paymentAdvanceFactory.PrepareContractPaymentAdvance(model, item);
                    _paymentAdvanceService.UpdatePaymentAdvance(item);
                    noti = "admin.common.Updated";
                }
                else
                {
                    _paymentAdvanceFactory.PrepareContractPaymentAdvance(model, item);
                    _paymentAdvanceService.InsertPaymentAdvance(item);
                }
                foreach (ContractAcceptanceModel accep in model.ListContractAcceptance)
                {
                    //add contractAcceptance
                    var accepitem = new ContractAcceptance();
                    accep.ApprovalDate     = model.PayDate;
                    accep.PaymentAdvanceId = item.Id;
                    accep.TypeId           = (int)ContractAcceptancesType.TamUng;
                    _contractModelFactory.PrepareContractAcceptance(accep, accepitem);
                    _contractService.InsertContractAcceptance(accepitem);
                    //add ContractAcceptamce_Task_Mapping
                    var AcceptanceTask = new ContractAcceptanceTaskMapping
                    {
                        TaskId = (int)accep.TaskId,
                        ContractAcceptanceId = accepitem.Id
                    };

                    _contractService.InsertContractAcceptanceTaskMapping(AcceptanceTask);
                }
                return(JsonSuccessMessage(_localizationService.GetResource(noti)));
            }
            var list = ModelState.Values.Where(c => c.Errors.Count > 0).ToList();

            return(JsonErrorMessage("Error", list));
        }
Ejemplo n.º 4
0
        public virtual IActionResult Create(Guid AdvanceGuid)
        {
            var model = new ContractPaymentAdvanceModel();
            var item  = _paymentAdvanceService.GetContractAdvanceByGuid(AdvanceGuid);

            if (item != null)
            {
                model = item.ToModel <ContractPaymentAdvanceModel>();
                model.TotalReceive = item.TotalReceive.ToVNStringNumber();
            }
            _paymentAdvanceFactory.PrepareContractPaymentAdvanceModel(model, null);
            if (item != null)
            {
                var listAcceptan = _contractService.getAllContractAcceptanceByAdvanceId(AdvanceId: item.Id);
                var listContract = listAcceptan.Select(c => c.ContractId).Distinct();
                model.ListContractId = String.Join(",", listContract.ToList());
            }
            return(View(model));
        }
Ejemplo n.º 5
0
 public void PrepareContractPaymentAdvance(ContractPaymentAdvanceModel model, ContractPaymentAdvance item)
 {
     item.StatusId = (int)PaymentAdvanceStatus.Use;
     if (model.Id == 0)
     {
         item.CreatorId   = _workContext.CurrentCustomer.Id;
         item.CreatedDate = DateTime.Now;
         item.AdvanceGuid = Guid.NewGuid();
     }
     item.Name         = model.Name;
     item.Code         = model.Code;
     item.TotalAmount  = model.TotalAmount.ToNumber();
     item.TotalReceive = model.TotalReceive.ToNumber();
     item.Description  = model.Description;
     if (model.UnitId > 0)
     {
         item.UnitId = model.UnitId;
     }
     item.PayDate = model.PayDate;
     if (model.CurrencyId > 0)
     {
         item.CurrencyId = model.CurrencyId;
     }
 }