Пример #1
0
        public static VLCExpenseDTO ConvertToVLCExpenseDTO(VLCExpenseDetail vLCExpenseDetail)
        {
            VLCExpenseDTO vLCExpenseDTO = new VLCExpenseDTO();

            if (vLCExpenseDetail != null)
            {
                vLCExpenseDTO.VLCExpenseId = vLCExpenseDetail.VLCExpenseId;
                vLCExpenseDTO.CreatedBy    = vLCExpenseDetail.CreatedBy;
                vLCExpenseDTO.CreatedDate  = vLCExpenseDetail.CreatedDate;
                vLCExpenseDTO.VLCId        = vLCExpenseDetail.VLCId;
                vLCExpenseDTO.VLCName      = vLCExpenseDetail.VLC.VLCName;

                VLCExpenseEnum vLCExpenseReason;
                Enum.TryParse <VLCExpenseEnum>(vLCExpenseDetail.ExpenseReason.ToString(), out vLCExpenseReason);
                vLCExpenseDTO.ExpenseReason = vLCExpenseReason;

                vLCExpenseDTO.VLCExpenseId    = vLCExpenseDetail.VLCExpenseId;
                vLCExpenseDTO.ModifiedDate    = vLCExpenseDetail.ModifiedDate;
                vLCExpenseDTO.ModifiedBy      = vLCExpenseDetail.ModifiedBy;
                vLCExpenseDTO.ExpenseComments = vLCExpenseDetail.ExpenseComments;
                vLCExpenseDTO.PaymentCrAmount = vLCExpenseDetail.PaymentCrAmount.GetValueOrDefault();
                vLCExpenseDTO.ExpenseDate     = vLCExpenseDetail.ExpenseDate;
                vLCExpenseDTO.PaymentDrAmount = vLCExpenseDetail.PaymentDrAmount.GetValueOrDefault();
            }

            return(vLCExpenseDTO);
        }
Пример #2
0
        public ResponseDTO UpdateMachineAndHouseRentExpenseForALLVLC(DateTime expenseMonth)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            var         vlcList     = unitOfWork.VLCRepository.GetAll();

            foreach (var vlc in vlcList)
            {
                if (vlc.HouseRent.GetValueOrDefault() > 0 || vlc.MachineRent.GetValueOrDefault() > 0)
                {
                    VLCExpenseDTO vLCExpenseDTO = new VLCExpenseDTO();
                    vLCExpenseDTO.VLCId       = vlc.VLCId;
                    vLCExpenseDTO.ExpenseDate = expenseMonth;
                    if (vlc.HouseRent.GetValueOrDefault() > 0 && vlc.MachineRent.GetValueOrDefault() > 0)
                    {
                        vLCExpenseDTO.ExpenseReason   = VLCExpenseEnum.HouseAndMachineRent;
                        vLCExpenseDTO.PaymentDrAmount = vlc.HouseRent.GetValueOrDefault() + vlc.MachineRent.GetValueOrDefault();
                    }
                    else if (vlc.HouseRent.GetValueOrDefault() > 0)
                    {
                        vLCExpenseDTO.ExpenseReason   = VLCExpenseEnum.HouseRent;
                        vLCExpenseDTO.PaymentDrAmount = vlc.HouseRent.GetValueOrDefault();
                    }
                    else
                    {
                        vLCExpenseDTO.ExpenseReason   = VLCExpenseEnum.MachineRent;
                        vLCExpenseDTO.PaymentDrAmount = vlc.HouseRent.GetValueOrDefault();
                    }
                }
            }
            responseDTO.Message = "Machine Rent and House Rent Updated for all VLCs";
            responseDTO.Status  = true;
            responseDTO.Data    = new object();
            return(responseDTO);
        }
Пример #3
0
        public ResponseDTO UpdateVLCExpenseDetail(VLCExpenseDTO vLCExpenseDTO)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            var         vLCExpense  = unitOfWork.VLCExpenseDetailRepository.GetExpenseByExpenseId(vLCExpenseDTO.VLCExpenseId);

            if (vLCExpense == null)
            {
                throw new PlatformModuleException("VLC Expense Details not found with VLC Expense Id");
            }

            // return AddVLCPaymentDetail(vLCPaymentDTO);

            VLCExpenseConvertor.ConvertToVLCExpenseDetailEntity(ref vLCExpense, vLCExpenseDTO, true);

            vLCExpense.PaymentCrAmount = vLCExpenseDTO.PaymentCrAmount;
            vLCExpense.PaymentDrAmount = vLCExpenseDTO.PaymentDrAmount;
            vLCExpense.ModifiedBy      = "Admin";
            vLCExpense.ModifiedDate    = DateTimeHelper.GetISTDateTime();

            unitOfWork.VLCExpenseDetailRepository.Update(vLCExpense);
            unitOfWork.SaveChanges();
            vLCExpenseDTO       = VLCExpenseConvertor.ConvertToVLCExpenseDTO(vLCExpense);
            responseDTO.Status  = true;
            responseDTO.Message = "VLC Expense Detail Updated Successfully";
            responseDTO.Data    = vLCExpenseDTO;
            return(responseDTO);
        }
Пример #4
0
        public VLCPaymentDetail AddVLCExpenseInPaymentDetail(VLCExpenseDTO vLCPaymentDTO, int expenseId, decimal paidAmount)
        {
            VLCPaymentDetail vLCPaymentDetail = new VLCPaymentDetail();

            vLCPaymentDetail.VLCPaymentId = unitOfWork.DashboardRepository.NextNumberGenerator("VLCPaymentDetail");
            var vLC = unitOfWork.DistributionCenterRepository.GetById(vLCPaymentDTO.VLCId);

            vLCPaymentDetail.VLCId = vLCPaymentDTO.VLCId;
            if (string.IsNullOrWhiteSpace(vLCPaymentDTO.ExpenseComments) == false)
            {
                vLCPaymentDetail.PaymentComments = vLCPaymentDTO.ExpenseComments;
            }

            vLCPaymentDetail.VLCExpenseId = expenseId;
            vLCPaymentDetail.IsDeleted    = false;
            vLCPaymentDetail.CreatedBy    = vLCPaymentDetail.ModifiedBy = "Admin";
            vLCPaymentDetail.CreatedDate  = vLCPaymentDetail.ModifiedDate = DateTimeHelper.GetISTDateTime();
            if (vLCPaymentDTO.ExpenseDate != DateTime.MinValue)
            {
                vLCPaymentDetail.PaymentDate = DateTimeHelper.GetISTDateTime().Date;
            }
            else
            {
                vLCPaymentDetail.PaymentDate = vLCPaymentDTO.ExpenseDate.HasValue ? vLCPaymentDTO.ExpenseDate.Value : DateTime.Now.Date;
            }
            vLCPaymentDetail.PaymentCrAmount = paidAmount;
            unitOfWork.VLCPaymentDetailRepository.Add(vLCPaymentDetail);
            return(vLCPaymentDetail);
        }
Пример #5
0
        public ResponseDTO DeleteVLCExpenseDetail(int id)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            UnitOfWork  unitOfWork  = new UnitOfWork();
            //get vLCAddress
            var vLCExpenseDetail = unitOfWork.VLCExpenseDetailRepository.GetExpenseByExpenseId(id);

            vLCExpenseDetail.IsDeleted = true;
            unitOfWork.VLCExpenseDetailRepository.Update(vLCExpenseDetail);
            unitOfWork.SaveChanges();
            VLCExpenseDTO vLCPaymentDTO = VLCExpenseConvertor.ConvertToVLCExpenseDTO(vLCExpenseDetail);

            responseDTO.Status  = true;
            responseDTO.Message = "VLC Payment Detail Deleted Successfully";
            responseDTO.Data    = vLCPaymentDTO;
            return(responseDTO);
        }
Пример #6
0
        public ResponseDTO GetVLCExpensesById(int value)
        {
            ResponseDTO      response         = new ResponseDTO();
            VLCExpenseDetail vLCExpenseDetail = unitOfWork.VLCExpenseDetailRepository.GetExpenseByExpenseId(value);
            VLCExpenseDTO    vLCExpense       = new VLCExpenseDTO();

            vLCExpense = VLCExpenseConvertor.ConvertToVLCExpenseDTO(vLCExpenseDetail);
            if (vLCExpense != null)
            {
                response.Data    = vLCExpense;
                response.Status  = true;
                response.Message = "VLC Expense by ID";
            }
            else
            {
                response.Status  = false;
                response.Message = "VLC Expense not found !";
            }
            return(response);
        }
Пример #7
0
        //TODO: Vimal please check why you are checking vlc id in DC repository
        //Date: 09-Sep-19
        public ResponseDTO AddVLCExpenseDetail(VLCExpenseDTO vLCExpenseDTO)
        {
            ResponseDTO responseDTO = new ResponseDTO();

            //CC: By Anil see comment above
            //var vLC = unitOfWork.DistributionCenterRepository.GetById(vLCExpenseDTO.VLCId);
            var vLC = unitOfWork.VLCRepository.GetById(vLCExpenseDTO.VLCId);

            if (vLC != null)
            {
                VLCExpenseDetail vLCExpenseDetail = AddExpense(vLCExpenseDTO);
                vLCExpenseDTO = VLCExpenseConvertor.ConvertToVLCExpenseDTO(vLCExpenseDetail);

                responseDTO.Status  = true;
                responseDTO.Message = "VLC Expense Detail Added Successfully";
                responseDTO.Data    = vLCExpenseDTO;
                return(responseDTO);
            }
            else
            {
                throw new PlatformModuleException("VLC Not Found");
            }
        }
Пример #8
0
        private VLCExpenseDetail AddExpense(VLCExpenseDTO vLCExpenseDTO)
        {
            VLCExpenseDetail vLCExpenseDetail = new VLCExpenseDetail();

            vLCExpenseDetail.VLCExpenseId    = unitOfWork.DashboardRepository.NextNumberGenerator("VLCExpenseDetail");
            vLCExpenseDetail.VLCId           = vLCExpenseDTO.VLCId;
            vLCExpenseDetail.ExpenseReason   = (int)vLCExpenseDTO.ExpenseReason;
            vLCExpenseDetail.IsDeleted       = false;
            vLCExpenseDetail.CreatedBy       = vLCExpenseDetail.ModifiedBy = "Admin";
            vLCExpenseDetail.CreatedDate     = vLCExpenseDetail.ModifiedDate = DateTimeHelper.GetISTDateTime();
            vLCExpenseDetail.PaymentCrAmount = vLCExpenseDTO.PaymentCrAmount;
            vLCExpenseDetail.PaymentDrAmount = vLCExpenseDTO.PaymentDrAmount;
            vLCExpenseDetail.ExpenseComments = vLCExpenseDTO.ExpenseComments;

            if (vLCExpenseDetail.ExpenseDate != DateTime.MinValue)
            {
                vLCExpenseDetail.ExpenseDate = DateTimeHelper.GetISTDateTime().Date;
            }
            else
            {
                vLCExpenseDetail.ExpenseDate = vLCExpenseDTO.ExpenseDate.Value;
            }
            unitOfWork.VLCExpenseDetailRepository.Add(vLCExpenseDetail);
            if (vLCExpenseDTO.PaymentCrAmount > 0)
            {
                UpdateVLCWalletForExpense(vLCExpenseDTO.VLCId, vLCExpenseDTO.PaymentCrAmount, true);
                AddVLCExpenseInPaymentDetail(vLCExpenseDTO, vLCExpenseDetail.VLCExpenseId, vLCExpenseDTO.PaymentCrAmount);
            }
            else
            {
                UpdateVLCWalletForExpense(vLCExpenseDTO.VLCId, vLCExpenseDTO.PaymentDrAmount, false);
                AddVLCExpenseInPaymentDetail(vLCExpenseDTO, vLCExpenseDetail.VLCExpenseId, vLCExpenseDTO.PaymentCrAmount);
            }
            unitOfWork.SaveChanges();
            return(vLCExpenseDetail);
        }
Пример #9
0
 public static void ConvertToVLCExpenseDetailEntity(ref VLCExpenseDetail vLCExpenseDetail, VLCExpenseDTO vLCExpenseDTO, bool isUpdate)
 {
     vLCExpenseDetail.VLCId = vLCExpenseDTO.VLCId;
     if (string.IsNullOrWhiteSpace(vLCExpenseDTO.ExpenseComments) == false)
     {
         vLCExpenseDetail.ExpenseComments = vLCExpenseDTO.ExpenseComments;
         vLCExpenseDetail.ExpenseDate     = vLCExpenseDTO.ExpenseDate.HasValue ? vLCExpenseDTO.ExpenseDate.Value : DateTime.Now.Date;
         vLCExpenseDetail.ExpenseReason   = (int)vLCExpenseDTO.ExpenseReason;
         vLCExpenseDTO.PaymentCrAmount    = vLCExpenseDTO.PaymentCrAmount;
         vLCExpenseDTO.PaymentDrAmount    = vLCExpenseDTO.PaymentDrAmount;
         vLCExpenseDTO.CreatedBy          = "User";
         vLCExpenseDTO.CreatedDate        = DateTime.Now.Date;
     }
 }