Skip to content

Commit

Permalink
no se que pinga
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Tirador committed Jul 5, 2022
1 parent cd616ae commit 0bb7950
Show file tree
Hide file tree
Showing 67 changed files with 211 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const SalaryPayment = () => {

const [courseSelected, setCourseSelected] = useState();

const [dateSelected, setDateSelected] = useState();

console.log(`selected ${courseSelected}`);

const fixedSalaryPaymentColumns = [
Expand Down Expand Up @@ -123,7 +125,8 @@ const SalaryPayment = () => {
<DatePicker placeholder={"Seleccione la fecha"}
disabledDate={disabledDate}
defaultValue={moment()}
format={dateFormat}
format={"YYYY.MM.DD"}
onChange={setDateSelected}
style={{
float: "right",
marginRight: "5%",
Expand All @@ -136,7 +139,7 @@ const SalaryPayment = () => {
<CRUD_Table title={""}
columns={fixedSalaryPaymentColumns}
operations={[]}
url={"https://localhost:5001/api/WorkerPaymentGetFixSalary" + `/${workerSelected}`}
url={"https://localhost:5001/api/WorkerPaymentGetFixSalary" + `/${workerSelected}` + `/${dateSelected}`}
tableID={fixedSalaryPaymentColumnsTableID}
searchboxID={fixedSalaryPaymentColumnsSearchboxID}
thereIsDropdown={false}
Expand All @@ -149,7 +152,7 @@ const SalaryPayment = () => {
<CRUD_Table title={""}
columns={percentageSalaryPaymentColumns}
operations={[]}
url={"https://localhost:5001/api/WorkerPaymentGetSalaryPerCourse" + `/${workerSelected}` + `$$${courseSelected}`}
url={"https://localhost:5001/api/WorkerPaymentGetSalaryPerCourse" + `/${workerSelected}` + `/${courseSelected}` + `/${dateSelected}`}
tableID={percentageSalaryPaymentColumnsTableID}
searchboxID={percentageSalaryPaymentColumnsSearchboxID}
thereIsDropdown={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ public WorkerPaymentGetFixSalaryController(IDoWorkersPaymentService service, IMa
[HttpGet("{id}/{date}")]
public IActionResult Get(string id,string date)
{
var Date = DateTime.Parse(date);
if(date == "now")
Date = DateTime.Now;
else
var Date = DateTime.Now;
try{

Date = DateTime.Parse(date);
}
catch{};

var worker = _service.Query().SingleOrDefault(c => c.Id == id);
if (worker == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@ public WorkerPaymentGetSalaryPerCourseController(IDoWorkersPaymentService servic
_service = service;
}

[HttpGet("{id}/{date}")]
public IActionResult Get(string id,string date)
[HttpGet("{workerid}/{courseid}/{date}")]
public IActionResult Get(string workerid, string courseid, string date)
{
var Date = DateTime.Parse(date);
if(date == "now")
Date = DateTime.Now;
else
System.Console.WriteLine(date);

var Date = new DateTime(2020,03,01);

try{

Date = DateTime.Parse(date);
}
catch {};

string[] ids = id.Split("$$");
var workerid = ids[0];var courseid = ids[1];

var worker = _service.Query().SingleOrDefault(c => c.Id == workerid);
if (worker == null)
NotFound();

return Ok(_service.GetWorkerPaymentInfo(workerid, Date).InfoByDate[0]
.InfoByCourse
.Single(c => c.CourseId == courseid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface IBasicMeanRepository : IRepository<BasicMean>
public interface IBasicMeanRepository : IActiveRepository<BasicMean>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface IClassroomRepository : IRepository<Classroom>
public interface IClassroomRepository : IActiveRepository<Classroom>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface ICourseGroupRepository : IRepository<CourseGroup>
public interface ICourseGroupRepository : IActiveRepository<CourseGroup>
{
CourseGroup GetById(string id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface ICourseRepository : IRepository<Course>
public interface ICourseRepository : IActiveRepository<Course>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface IExpenseRepository : IRepository<Expense>
public interface IExpenseRepository : IActiveRepository<Expense>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface IPositionRepository : IRepository<Position>
public interface IPositionRepository : IActiveRepository<Position>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface IResourceRepository : IRepository<Resource>
public interface IResourceRepository : IActiveRepository<Resource>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface IStudentRepository : IRepository<Student>
public interface IStudentRepository : IActiveRepository<Student>
{
/// Devuelve el estudiante con ese id
/// En caso de no existir devuelve null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface ITeacherRepository : IRepository<Teacher>
public interface ITeacherRepository : IActiveRepository<Teacher>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface ITuitorRepository : IRepository<Tuitor>
public interface ITuitorRepository : IActiveRepository<Tuitor>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface IWorkerRepository : IRepository<Worker>
public interface IWorkerRepository : IActiveRepository<Worker>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SchoolManagementSystem.Application.Repositories_Interfaces;

public interface ISchoolMemberRepository : IRepository<SchoolMember>
public interface ISchoolMemberRepository : IActiveRepository<SchoolMember>
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

using SchoolManagementSystem.Domain.Interfaces;
using SchoolManagementSystem.Domain.Services;
using SchoolManagementSystem.Domain.Entities;


namespace SchoolManagementSystem.Application.Services_Implementations;



public class ActiveService<TEntity> : BaseService<TEntity>, IActiveService<TEntity> where TEntity : Entity
{
new IActiveRepository<TEntity> BaseRepository;
public ActiveService(IActiveRepository<TEntity> repository) : base(repository)
{
BaseRepository = repository;
}

public IQueryable<TEntity> QueryAll()
{
var inac = BaseRepository.QueryInactives();
var act = BaseRepository.Query();


return inac.Union(act);
}

public IQueryable<TEntity> QueryInactives() => BaseRepository.QueryInactives();

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class BasicMeanService : BaseService<BasicMean>, IBasicMeanService
public class BasicMeanService : ActiveService<BasicMean>, IBasicMeanService
{
public BasicMeanService(IBasicMeanRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class ClassroomService : BaseService<Classroom>, IClassroomService
public class ClassroomService : ActiveService<Classroom>, IClassroomService
{
public ClassroomService(IClassroomRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class CourseGroupService : BaseService<CourseGroup>, ICourseGroupService
public class CourseGroupService : ActiveService<CourseGroup>, ICourseGroupService
{
public CourseGroupService(ICourseGroupRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class CourseService : BaseService<Course>, ICourseService
public class CourseService : ActiveService<Course>, ICourseService
{
public CourseService(ICourseRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class ExpenseService : BaseService<Expense>, IExpenseService
public class ExpenseService : ActiveService<Expense>, IExpenseService
{
public ExpenseService(IExpenseRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class PositionService : BaseService<Position>, IPositionService
public class PositionService : ActiveService<Position>, IPositionService
{
public PositionService(IPositionRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class ResourceService : BaseService<Resource>, IResourceService
public class ResourceService : ActiveService<Resource>, IResourceService
{
public ResourceService(IResourceRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class StudentService : BaseService<Student>, IStudentService
public class StudentService : ActiveService<Student>, IStudentService
{
public StudentService(IStudentRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class TeacherService : BaseService<Teacher>, ITeacherService
public class TeacherService : ActiveService<Teacher>, ITeacherService
{
ISchoolMemberRepository schl_member_repo;
public TeacherService(ISchoolMemberRepository schl_member_repo, ITeacherRepository repository) : base(repository)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class TuitorService : BaseService<Tuitor>, ITuitorService
public class TuitorService : ActiveService<Tuitor>, ITuitorService
{
public TuitorService(ITuitorRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SchoolManagementSystem.Application.Services_Implementations;

public class WorkerService : BaseService<Worker>, IWorkerService
public class WorkerService : ActiveService<Worker>, IWorkerService
{
public WorkerService(IWorkerRepository repository) : base(repository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public IRepository<TeacherCourseRelation> GetTeacherCourseRelationRepo()
}
public void DoPositionPayment(DateTime Date, string WorkerId)
{
var _query = repoWorkerPositionR.Query().Where(c => c.WorkerId == WorkerId);
var _query = repoWorkerPositionR.Query().Where(c => c.WorkerId == WorkerId && c.StartDate < Date
&& c.EndDate >= Date);
foreach (var row in _query)
{
repoPositionPayments.Add(new WorkerPayRecordByPosition()
Expand Down Expand Up @@ -76,7 +77,7 @@ public void DoCoursePayment(DateTime Date, string WorkerId)
repoTeacherPayments.CommitAsync();
}

public WorkerPaymentInfo GetWorkerPaymentInfo(string id)
public WorkerPaymentInfo GetWorkerPaymentInfo(string id, DateTime Date)
{
var worker = this.Query().SingleOrDefault(c => c.Id == id);
var workerPaymentInfo = new WorkerPaymentInfo
Expand All @@ -85,11 +86,13 @@ public WorkerPaymentInfo GetWorkerPaymentInfo(string id)
WorkerName = worker.Name,
InfoByDate = new List<InfoByDate>(){new InfoByDate{
InfoByPosition = new List<InfoByPosition>(),
InfoByCourse = new List<InfoByCourse>()
InfoByCourse = new List<InfoByCourse>(),
Date = Date
}},
};

var _query = from wPR in repoWorkerPositionR.Query().Include(c => c.Position).Where(c => c.WorkerId == id)
var _query = from wPR in repoWorkerPositionR.Query().Include(c => c.Position).Where(c => c.WorkerId == id && c.StartDate < workerPaymentInfo.InfoByDate[0].Date
&& c.EndDate >= workerPaymentInfo.InfoByDate[0].Date)
select new { wPR.PositionId, salary = wPR.FixedSalary, Name = wPR.Position.Name };

foreach (var row in _query)
Expand All @@ -116,11 +119,14 @@ public WorkerPaymentInfo GetWorkerPaymentInfo(string id)
InfoByCourseGroup = new List<InfoByCourseGroup>()
};
var _querytcgr = repoTeacherCGREl.Query().Where(c => c.TeacherId == id
&& c.CourseGroupCourseId == course.CourseId)
&& c.CourseGroupCourseId == course.CourseId
&& c.StartDate <= Date
&& c.EndDate >= Date
)
.Include(c => c.CourseGroup.StudentCourseGroupRelations);
foreach (var group in _querytcgr)
{
var income = group.CourseGroup.StudentCourseGroupRelations.Count() * row.Course.Price;
var income = group.CourseGroup.StudentCourseGroupRelations.Where(c => c.StartDate <= info.Date && c.EndDate >= info.Date).Count() * row.Course.Price;
course.InfoByCourseGroup.Add(new InfoByCourseGroup()
{
CourseGroupId = group.CourseGroup.Id
Expand Down
2 changes: 1 addition & 1 deletion src/SchoolManagementSystem.Domain/Entities/CourseGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CourseGroup : Entity
public Teacher Teacher{ get; set; }
public int Capacity { get; set; }
public DateTime StartDate { get; set; } //= DateTime.Now();
public DateTime EndDate { get; set; }
public DateTime EndDate { get; set; } = DateTime.MaxValue;
public IList<StudentCourseGroupRelation> StudentCourseGroupRelations { get; set; }
// public IList<Teacher> Teachers { get; set; }
public IList<TeacherCourseGroupRelation> TeacherCourseGroupRelations { get; set; }
Expand Down
Loading

0 comments on commit 0bb7950

Please sign in to comment.