예제 #1
0
        public async Task <IHttpActionResult> PostApproval(NvVatTuChungTu instance)
        {
            string         unitCode = _service.GetCurrentUnitCode();
            NvVatTuChungTu chungTu  = _service.FindById(instance.Id);

            if (chungTu == null || chungTu.TrangThai == (int)ApprovalState.IsComplete)
            {
                return(NotFound());
            }
            #region For Only ILOVEVN - B&T
            //chungTu.NgayDuyetPhieu = CurrentSetting.GetNgayKhoaSo(unitCode);
            //_InsertPhieuCongNo(chungTu);
            #endregion
            //chungTu = _service.FindById(instance.Id);
            chungTu.TrangThai          = (int)ApprovalState.IsComplete;
            chungTu.NgayDuyetPhieu     = CurrentSetting.GetNgayKhoaSo(unitCode);
            chungTu.ThoiGianDuyetPhieu = int.Parse(DateTime.Now.ToString("HHmmssfff"));
            chungTu.ObjectState        = ObjectState.Modified;
            _service.UnitOfWork.Save();
            switch (_service.Approval(chungTu))
            {
            case StateProcessApproval.NoPeriod:
                try
                {
                    await _service.UnitOfWork.SaveAsync();

                    return(Ok(true));
                }
                catch (Exception e)
                {
                    return(InternalServerError());
                }

            case StateProcessApproval.Success:
                try
                {
                    await _service.UnitOfWork.SaveAsync();

                    return(Ok(true));
                }
                catch (Exception e)
                {
                    return(InternalServerError());
                }

            case StateProcessApproval.Failed:
                break;

            default:
                break;
            }

            return(BadRequest("Không thể duyệt phiếu này"));
        }
예제 #2
0
        public virtual bool ValidateNgayCT(DateTime ngayCt)
        {
            var currentUnitCode = GetCurrentUnitCode();
            var ngayKhoaSo      = CurrentSetting.GetNgayKhoaSo(currentUnitCode);

            if (ngayCt.Date < ngayKhoaSo.Date)
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
        public async Task <IHttpActionResult> PostApproval(NvXuatKhacVm.Dto instance)
        {
            var unitCode = _service.GetCurrentUnitCode();
            var chungTu  = _service.FindById(instance.Id);

            if (chungTu == null || chungTu.TrangThai == (int)ApprovalState.IsComplete)
            {
                return(NotFound());
            }
            _service.UpdatePhieu(instance);
            chungTu.TrangThai      = (int)ApprovalState.IsComplete;
            chungTu.NgayDuyetPhieu = CurrentSetting.GetNgayKhoaSo(unitCode);
            chungTu.ObjectState    = ObjectState.Modified;

            await _service.UnitOfWork.SaveAsync();

            switch (_service.Approval(chungTu.Id))
            {
            case StateProcessApproval.NoPeriod:

                try
                {
                    await _service.UnitOfWork.SaveAsync();

                    return(Ok(true));
                }
                catch (Exception e)
                {
                    return(InternalServerError());
                }

            case StateProcessApproval.Success:
                try
                {
                    await _service.UnitOfWork.SaveAsync();

                    return(Ok(true));
                }
                catch (Exception e)
                {
                    return(InternalServerError());
                }

            case StateProcessApproval.Failed:
                break;

            default:
                break;
            }

            return(BadRequest("Không thể duyệt phiếu này"));
        }
예제 #4
0
        public async Task <IHttpActionResult> GetNewParameter()
        {
            var unitCode    = _service.GetCurrentUnitCode();
            var currentDate = DateTime.Now.Date;
            var datelock    = CurrentSetting.GetNgayKhoaSo(unitCode);
            var result      = new ParameterCongNo()
            {
                ToDate     = datelock,
                FromDate   = datelock.AddDays(-1),
                UnitCode   = unitCode,
                LoaiBaoCao = "0",
            };

            return(Ok(result));
        }
예제 #5
0
        public async Task <IHttpActionResult> GetNewParameter()
        {
            string   unitCode    = _service.GetCurrentUnitCode();
            DateTime currentDate = DateTime.Now.Date;
            DateTime datelock    = CurrentSetting.GetNgayKhoaSo(unitCode);
            ParameterNgayHetHanHangHoa result = new ParameterNgayHetHanHangHoa()
            {
                ToDate   = datelock,
                FromDate = datelock,
                MaxDate  = currentDate,
                UnitCode = unitCode,
                GroupBy  = "MADONVI",
            };

            return(Ok(result));
        }
예제 #6
0
        public async Task <IHttpActionResult> GetNewParameter()
        {
            var unitCode    = _serviceKK.GetCurrentUnitCode();
            var currentDate = DateTime.Now.Date;
            var datelock    = CurrentSetting.GetNgayKhoaSo(unitCode);
            var result      = new ParameterKiemKe()
            {
                ToDate     = datelock,
                FromDate   = datelock,
                MaxDate    = currentDate,
                UnitCode   = unitCode,
                GroupBy    = TypeGroupKiemKe.WAREHOUSE,
                ReportType = TypeReportKiemKe.BAOCAODAYDU
            };

            return(Ok(result));
        }
예제 #7
0
        public async Task <IHttpActionResult> GetNewParameter()
        {
            var unitCode    = _service.GetCurrentUnitCode();
            var currentDate = DateTime.Now.Date;
            var datelock    = CurrentSetting.GetNgayKhoaSo(unitCode);
            var result      = new ParameterCashier()
            {
                ToDate       = datelock,
                FromDate     = datelock,
                MaxDate      = currentDate,
                UnitCode     = unitCode,
                GroupBy      = TypeGroupInventoryCashier.MALOAIVATTU,
                LoaiGiaoDich = TypeGiaoDich.XUATBANLE
            };

            return(Ok(result));
        }
예제 #8
0
        private void _InsertPhieuCongNo(NvVatTuChungTu chungTu)
        {
            //Cos nhieu phieu trong ngay phat sinh no.
            var unitCode = _service.GetCurrentUnitCode();

            var _thanhTienCanTra = _serviceCongNo.GetAmmountCustomerBorrowed(chungTu.MaKhachHang, chungTu.NgayDuyetPhieu.Value).ThanhTienCanTra;

            _serviceCongNo.InsertPhieu(new NvCongNoVm.Dto()
            {
                Id              = Guid.NewGuid().ToString(),
                LoaiChungTu     = LoaiCongNo.CNKH.ToString(),
                NgayCT          = CurrentSetting.GetNgayKhoaSo(unitCode),
                MaKhachHang     = chungTu.MaKhachHang,
                GhiChu          = "[" + chungTu.MaChungTu + "]",
                ThanhTien       = chungTu.ThanhTienSauVat,
                ThanhTienCanTra = _thanhTienCanTra,
            });
            _serviceCongNo.UnitOfWork.Save();
        }