Merge branch 'working' into develop
Some checks failed
release-dev / release-dev (push) Failing after 13s
Some checks failed
release-dev / release-dev (push) Failing after 13s
This commit is contained in:
commit
528e9a63e4
8 changed files with 1350 additions and 27 deletions
|
|
@ -91,15 +91,15 @@ namespace BMA.EHR.Domain.Models.Leave.Requests
|
||||||
|
|
||||||
public string CoupleDayLevelCountry { get; set; } = string.Empty;
|
public string CoupleDayLevelCountry { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string CoupleDayCountryHistory { get; set; } = string.Empty;
|
public string? CoupleDayCountryHistory { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string CoupleDayTotalHistory { get; set; } = string.Empty;
|
public string? CoupleDayTotalHistory { get; set; }
|
||||||
|
|
||||||
public DateTime CoupleDayStartDateHistory { get; set; } = DateTime.Now;
|
public DateTime? CoupleDayStartDateHistory { get; set; }
|
||||||
|
|
||||||
public DateTime CoupleDayEndDateHistory { get; set; } = DateTime.Now;
|
public DateTime? CoupleDayEndDateHistory { get; set; }
|
||||||
|
|
||||||
public string CoupleDaySumTotalHistory { get; set; } = string.Empty;
|
public string? CoupleDaySumTotalHistory { get; set; }
|
||||||
|
|
||||||
[Required, Comment("สถานะของคำร้อง")]
|
[Required, Comment("สถานะของคำร้อง")]
|
||||||
public string LeaveStatus { get; set; } = string.Empty;
|
public string LeaveStatus { get; set; } = string.Empty;
|
||||||
|
|
|
||||||
1167
BMA.EHR.Infrastructure/Migrations/LeaveDb/20241112025533_change couple history date to nullable.Designer.cs
generated
Normal file
1167
BMA.EHR.Infrastructure/Migrations/LeaveDb/20241112025533_change couple history date to nullable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,139 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class changecouplehistorydatetonullable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "CoupleDayTotalHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "CoupleDaySumTotalHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "CoupleDayStartDateHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "datetime(6)",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "datetime(6)");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "CoupleDayEndDateHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "datetime(6)",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "datetime(6)");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "CoupleDayCountryHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "LeaveRequests",
|
||||||
|
keyColumn: "CoupleDayTotalHistory",
|
||||||
|
keyValue: null,
|
||||||
|
column: "CoupleDayTotalHistory",
|
||||||
|
value: "");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "CoupleDayTotalHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext",
|
||||||
|
oldNullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "LeaveRequests",
|
||||||
|
keyColumn: "CoupleDaySumTotalHistory",
|
||||||
|
keyValue: null,
|
||||||
|
column: "CoupleDaySumTotalHistory",
|
||||||
|
value: "");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "CoupleDaySumTotalHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext",
|
||||||
|
oldNullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "CoupleDayStartDateHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "datetime(6)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "datetime(6)",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "CoupleDayEndDateHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "datetime(6)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "datetime(6)",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "LeaveRequests",
|
||||||
|
keyColumn: "CoupleDayCountryHistory",
|
||||||
|
keyValue: null,
|
||||||
|
column: "CoupleDayCountryHistory",
|
||||||
|
value: "");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "CoupleDayCountryHistory",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext",
|
||||||
|
oldNullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -233,10 +233,9 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<string>("CoupleDayCountryHistory")
|
b.Property<string>("CoupleDayCountryHistory")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<DateTime>("CoupleDayEndDateHistory")
|
b.Property<DateTime?>("CoupleDayEndDateHistory")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
b.Property<string>("CoupleDayLevel")
|
b.Property<string>("CoupleDayLevel")
|
||||||
|
|
@ -255,15 +254,13 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<DateTime>("CoupleDayStartDateHistory")
|
b.Property<DateTime?>("CoupleDayStartDateHistory")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
b.Property<string>("CoupleDaySumTotalHistory")
|
b.Property<string>("CoupleDaySumTotalHistory")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<string>("CoupleDayTotalHistory")
|
b.Property<string>("CoupleDayTotalHistory")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
|
|
||||||
|
|
@ -518,10 +518,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
coupleDayPosition = data.CoupleDayPosition,
|
coupleDayPosition = data.CoupleDayPosition,
|
||||||
coupleDayOrganizationName = "-",
|
coupleDayOrganizationName = "-",
|
||||||
coupleDayLevelCountry = data.CoupleDayLevelCountry,
|
coupleDayLevelCountry = data.CoupleDayLevelCountry,
|
||||||
coupleDayCountryHistory = data.CoupleDayCountryHistory,
|
coupleDayCountryHistory = data.CoupleDayCountryHistory ?? "",
|
||||||
coupleDayTotalHistory = data.CoupleDayTotalHistory,
|
coupleDayTotalHistory = data.CoupleDayTotalHistory ?? "",
|
||||||
coupleDayStartDateHistory = data.CoupleDayStartDateHistory.Date.ToThaiShortDate(),
|
coupleDayStartDateHistory = data.CoupleDayStartDateHistory == null ? "" : data.CoupleDayStartDateHistory.Value.Date.ToThaiShortDate(),
|
||||||
coupleDayEndDateHistory = data.CoupleDayEndDateHistory.Date.ToThaiShortDate(),
|
coupleDayEndDateHistory = data.CoupleDayEndDateHistory == null ? "" : data.CoupleDayEndDateHistory.Value.Date.ToThaiShortDate(),
|
||||||
coupleDaySumTotalHistory = data.CoupleDaySumTotalHistory,
|
coupleDaySumTotalHistory = data.CoupleDaySumTotalHistory,
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -771,6 +771,26 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
var sumApproveLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(userId, req.Type, req.StartLeaveDate.Year);
|
var sumApproveLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(userId, req.Type, req.StartLeaveDate.Year);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var minLeave = (await _context.Set<LeaveRequest>().Where(x => x.Type.Id == req.Type &&
|
||||||
|
x.LeaveStatus != "DELETE" && x.LeaveStatus != "REJECT")
|
||||||
|
.OrderBy(x => x.LeaveStartDate)
|
||||||
|
.FirstOrDefaultAsync());
|
||||||
|
|
||||||
|
var maxLeave = (await _context.Set<LeaveRequest>().Where(x => x.Type.Id == req.Type &&
|
||||||
|
x.LeaveStatus != "DELETE" && x.LeaveStatus != "REJECT")
|
||||||
|
.OrderByDescending(x => x.LeaveEndDate)
|
||||||
|
.FirstOrDefaultAsync());
|
||||||
|
|
||||||
|
var isBetween = false;
|
||||||
|
if (minLeave != null && maxLeave != null)
|
||||||
|
{
|
||||||
|
isBetween = (req.StartLeaveDate.Date >= minLeave.LeaveStartDate.Date && req.StartLeaveDate.Date <= maxLeave.LeaveEndDate.Date) ||
|
||||||
|
(req.EndLeaveDate.Date >= minLeave.LeaveStartDate.Date && req.EndLeaveDate.Date <= maxLeave.LeaveEndDate.Date);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var isLeave = false;
|
var isLeave = false;
|
||||||
|
|
||||||
switch (leaveType.Code.ToUpper().Trim())
|
switch (leaveType.Code.ToUpper().Trim())
|
||||||
|
|
@ -784,10 +804,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
isLeave = totalDay <= 90;
|
isLeave = totalDay <= 90;
|
||||||
break;
|
break;
|
||||||
case "LV-004":
|
case "LV-004":
|
||||||
isLeave = (totalDay - sumWorkDay - sumWeekend) <= 15;
|
isLeave = (totalDay - (sumWorkDay + sumWeekend) + sumApproveLeave) <= 15;
|
||||||
break;
|
break;
|
||||||
case "LV-005":
|
case "LV-005":
|
||||||
isLeave = (totalDay - sumWorkDay - sumWeekend - sumApproveLeave) <= 10;
|
isLeave = (totalDay - (sumWorkDay + sumWeekend) + sumApproveLeave) <= 10;
|
||||||
break;
|
break;
|
||||||
case "LV-006":
|
case "LV-006":
|
||||||
isLeave = totalDay <= 120;
|
isLeave = totalDay <= 120;
|
||||||
|
|
@ -864,7 +884,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
var result = new GetLeaveCheckResultDto
|
var result = new GetLeaveCheckResultDto
|
||||||
{
|
{
|
||||||
IsLeave = isLeave,
|
IsLeave = !isBetween ? isLeave : false,
|
||||||
SumDateWork = sumWorkDay,
|
SumDateWork = sumWorkDay,
|
||||||
TotalDate = totalDay,
|
TotalDate = totalDay,
|
||||||
SumDateHoliday = sumWeekend
|
SumDateHoliday = sumWeekend
|
||||||
|
|
|
||||||
|
|
@ -105,15 +105,15 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||||
|
|
||||||
public string CoupleDayLevelCountry { get; set; } = string.Empty;
|
public string CoupleDayLevelCountry { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string CoupleDayCountryHistory { get; set; } = string.Empty;
|
public string? CoupleDayCountryHistory { get; set; }
|
||||||
|
|
||||||
public string CoupleDayTotalHistory { get; set; } = string.Empty;
|
public string? CoupleDayTotalHistory { get; set; }
|
||||||
|
|
||||||
public DateTime CoupleDayStartDateHistory { get; set; } = DateTime.Now;
|
public DateTime? CoupleDayStartDateHistory { get; set; }
|
||||||
|
|
||||||
public DateTime CoupleDayEndDateHistory { get; set; } = DateTime.Now;
|
public DateTime? CoupleDayEndDateHistory { get; set; }
|
||||||
|
|
||||||
public string CoupleDaySumTotalHistory { get; set; } = string.Empty;
|
public string? CoupleDaySumTotalHistory { get; set; }
|
||||||
|
|
||||||
public string? Dear { get; set; } = string.Empty;
|
public string? Dear { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,15 +112,15 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||||
|
|
||||||
public string CoupleDayLevelCountry { get; set; } = string.Empty;
|
public string CoupleDayLevelCountry { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string CoupleDayCountryHistory { get; set; } = string.Empty;
|
public string? CoupleDayCountryHistory { get; set; }
|
||||||
|
|
||||||
public string CoupleDayTotalHistory { get; set; } = string.Empty;
|
public string? CoupleDayTotalHistory { get; set; }
|
||||||
|
|
||||||
public DateTime CoupleDayStartDateHistory { get; set; } = DateTime.Now;
|
public DateTime? CoupleDayStartDateHistory { get; set; }
|
||||||
|
|
||||||
public DateTime CoupleDayEndDateHistory { get; set; } = DateTime.Now;
|
public DateTime? CoupleDayEndDateHistory { get; set; }
|
||||||
|
|
||||||
public string CoupleDaySumTotalHistory { get; set; } = string.Empty;
|
public string? CoupleDaySumTotalHistory { get; set; }
|
||||||
|
|
||||||
public string Dear { get; set; } = string.Empty;
|
public string Dear { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue