public IHttpActionResult PostComplete(NvKiemKeVm.Dto instance) { string unitCode = _service.GetCurrentUnitCode(); MdPeriod curentDate = CurrentSetting.GetKhoaSo(unitCode); int period = curentDate.Period; int year = curentDate.Year; string tablleName = curentDate.GetTableName(); instance.NgayDuyetPhieu = curentDate.ToDate; try { string msg = _serviceKK.Approval(instance, tablleName, year.ToString(), period); if (msg.Length > 0) { return(BadRequest(msg)); } _serviceKK.UpdateApproval(instance); _serviceKK.UnitOfWork.Save(); return(Ok(msg)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IHttpActionResult> GetLastPeriod() { var result = new MdPeriod(); var unitCode = _servicePeriod.GetCurrentUnitCode(); result = CurrentSetting.GetKhoaSo(unitCode); //if(result!=null) //{ } return(Ok(result)); }
public MdPeriod GetPeriodDate() { var unitCode = _servicePeriod.GetCurrentUnitCode(); var period = new MdPeriod(); period = CurrentSetting.GetKhoaSo(unitCode); if (period != null) { return(period); } else { return(null); } }
public async Task <IHttpActionResult> GetExternalCode(ParameterKiemKe para) { string unitCode = _service.GetCurrentUnitCode(); MdPeriod curentDate = CurrentSetting.GetKhoaSo(unitCode); if (para.WareHouseCodes == null) { para.WareHouseCodes = unitCode + "-K2"; } string tableName = curentDate.GetTableName(); List <NvKiemKeVm.ExternalCodeInInventory> result = new List <NvKiemKeVm.ExternalCodeInInventory>(); result = ProcedureCollection.GetExternalCodeInventory(unitCode, tableName, para); if (result != null) { return(Ok(result)); } else { return(NotFound()); } }
public async Task <IHttpActionResult> PostComplete(NvKiemKeVm.Dto instance) { string unitCode = _service.GetCurrentUnitCode(); MdPeriod curentDate = CurrentSetting.GetKhoaSo(unitCode); int period = curentDate.Period; int year = curentDate.Year; string tablleName = curentDate.GetTableName(); NvKiemKe phieuKiemKe = _serviceKK.FindById(instance.Id); instance.NgayDuyetPhieu = curentDate.ToDate; //thực hiện tạo phiếu kiểm kê nhập, kiểm kê xuất try { _serviceKK.Approval(instance, tablleName, year.ToString(), period); _serviceKK.UpdateApproval(instance); _serviceKK.UnitOfWork.Save(); return(Ok(true)); } catch (Exception) { return(InternalServerError()); } }
public async Task <IHttpActionResult> GetDetails(string id) { var _ParentUnitCode = _service.GetParentUnitCode(); var result = new TransferObj <NvXuatKhacVm.Dto>(); var temp = new NvXuatKhacVm.Dto(); var phieu = _service.FindById(id); if (phieu != null) { temp = Mapper.Map <NvVatTuChungTu, NvXuatKhacVm.Dto>(phieu); var chiTietPhieu = _service.UnitOfWork.Repository <NvVatTuChungTuChiTiet>().DbSet.Where(x => x.MaChungTuPk == phieu.MaChungTuPk).ToList(); temp.DataDetails = Mapper.Map <List <NvVatTuChungTuChiTiet>, List <NvXuatKhacVm.DtoDetail> >(chiTietPhieu); temp.DataDetails.ForEach( x => { x.CalcResult(); x.GiaVon = x.GiaVon; } ); if (phieu.TrangThai != 10) { decimal sum = 0; List <NvXuatKhacVm.DtoDetail> listDetails = new List <NvXuatKhacVm.DtoDetail>(); var unitCode = _service.GetCurrentUnitCode(); var ky = CurrentSetting.GetKhoaSo(unitCode); var tableName = ProcedureCollection.GetTableName(ky.Year, ky.Period); var MaKho = temp.MaKhoXuat; decimal giaVon = 0; //string kyKeToan = _servicePeriod.GetKyKeToan((DateTime)phieu.NgayCT); foreach (var value in temp.DataDetails) { var sp = _service.UnitOfWork.Repository <MdMerchandisePrice>().DbSet.Where(x => x.MaVatTu.Equals(value.MaHang) && x.MaDonVi.StartsWith(_ParentUnitCode)).FirstOrDefault(); var item = _service.UnitOfWork.Repository <MdMerchandise>().DbSet.Where(x => x.MaVatTu.Equals(value.MaHang) && x.UnitCode.StartsWith(_ParentUnitCode)).FirstOrDefault(); if (sp != null) { value.TyLeVATVao = sp.TyLeVatVao; } if (item != null) { value.TenHang = item.TenHang; } List <MdMerchandiseVm.DataXNT> data = ProcedureCollection.GetDataInventoryByCondition(unitCode, MaKho, value.MaHang, tableName, _ParentUnitCode); if (data.Count > 0) { decimal.TryParse(value.GiaVon.ToString(), out giaVon); value.DonGia = giaVon; value.TyLeVATRa = data[0].TyLeVATRa; value.TyLeVATVao = data[0].TyLeVATVao; value.ThanhTien = value.DonGia * value.SoLuong; sum += (decimal)value.ThanhTien; } listDetails.Add(value); } temp.DataDetails = listDetails; var tyLe = _service.UnitOfWork.Repository <MdTax>().DbSet.Where(x => x.MaLoaiThue == temp.VAT).Select(x => x.TaxRate).FirstOrDefault(); if (tyLe != null) { temp.TienVat = sum * (tyLe / 100); } else { temp.TienVat = 0; } temp.ThanhTienTruocVat = sum; temp.ThanhTienSauVat = temp.ThanhTienTruocVat + temp.TienVat; } result.Data = temp; result.Status = true; return(Ok(result)); } return(NotFound()); }