บันทึกเงินเดือนของผู้บรรจุ
This commit is contained in:
parent
69bd9c0a68
commit
bb9a0bc73e
6 changed files with 16338 additions and 6 deletions
|
|
@ -1722,6 +1722,8 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var receiver = await _dbContext.Set<CommandReceiver>()
|
var receiver = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.Include(x => x.Command)
|
||||||
|
.ThenInclude(x => x.CommandType)
|
||||||
.FirstOrDefaultAsync(x => x.Id == personalId);
|
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||||
|
|
||||||
if (receiver == null)
|
if (receiver == null)
|
||||||
|
|
@ -2116,6 +2118,30 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
|
|
||||||
#region " Placement "
|
#region " Placement "
|
||||||
|
|
||||||
|
public async Task<PlacementSalaryResponse> GetCommandReceiverSalary(Guid recordId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cmdReceiver = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == recordId);
|
||||||
|
|
||||||
|
if (cmdReceiver == null)
|
||||||
|
throw new Exception($"Invalid command receiver: {recordId}");
|
||||||
|
|
||||||
|
return new PlacementSalaryResponse
|
||||||
|
{
|
||||||
|
SalaryAmount = cmdReceiver.Amount ?? 0,
|
||||||
|
PositionSalaryAmount = cmdReceiver.PositionSalaryAmount ?? 0,
|
||||||
|
MonthSalaryAmount = cmdReceiver.MouthSalaryAmount ?? 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<PlacementSalaryResponse> GetPlacementSalaryAsync(Guid placementProfileId)
|
public async Task<PlacementSalaryResponse> GetPlacementSalaryAsync(Guid placementProfileId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -2140,6 +2166,28 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateCommandReceiverSalaryAsync(Guid personalId, UpdatePlacementSalaryRequest req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var current = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||||
|
|
||||||
|
if (current == null)
|
||||||
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
|
current.Amount = req.SalaryAmount;
|
||||||
|
current.PositionSalaryAmount = req.PositionSalaryAmount;
|
||||||
|
current.MouthSalaryAmount = req.MonthSalaryAmount;
|
||||||
|
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task UpdatePlacementSalaryAsync(Guid personalId, UpdatePlacementSalaryRequest req)
|
public async Task UpdatePlacementSalaryAsync(Guid personalId, UpdatePlacementSalaryRequest req)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using BMA.EHR.Application.Repositories;
|
using BMA.EHR.Application.Repositories;
|
||||||
using BMA.EHR.Application.Repositories.Commands;
|
using BMA.EHR.Application.Repositories.Commands;
|
||||||
using BMA.EHR.Application.Requests.Commands;
|
using BMA.EHR.Application.Requests.Commands;
|
||||||
|
using BMA.EHR.Application.Responses;
|
||||||
using BMA.EHR.Command.Service.Requests;
|
using BMA.EHR.Command.Service.Requests;
|
||||||
using BMA.EHR.Command.Service.Responses;
|
using BMA.EHR.Command.Service.Responses;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
|
|
@ -12,6 +13,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
namespace BMA.EHR.Command.Service.Controllers
|
namespace BMA.EHR.Command.Service.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -2525,6 +2527,15 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
|
foreach (var r in receivers)
|
||||||
|
{
|
||||||
|
var salary = await _repository.GetCommandReceiverSalary(r.PersonalId);
|
||||||
|
r.SalaryAmount = salary.SalaryAmount;
|
||||||
|
r.PositionSalaryAmount = salary.PositionSalaryAmount;
|
||||||
|
r.MonthSalaryAmount = salary.MonthSalaryAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2587,9 +2598,18 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default:
|
||||||
|
{
|
||||||
|
foreach (var r in receivers)
|
||||||
|
{
|
||||||
|
var salary = await _repository.GetCommandReceiverSalary(r.PersonalId);
|
||||||
|
r.SalaryAmount = salary.SalaryAmount;
|
||||||
|
r.PositionSalaryAmount = salary.PositionSalaryAmount;
|
||||||
|
r.MonthSalaryAmount = salary.MonthSalaryAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Success(receivers);
|
return Success(receivers);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
@ -3042,8 +3062,25 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var record = await _repository.GetCommandReceiverAsync(personalId);
|
var record = await _repository.GetCommandReceiverAsync(personalId);
|
||||||
|
if (record == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
var data = await _repository.GetPlacementSalaryAsync(record!.RefPlacementProfileId!.Value);
|
var data = new PlacementSalaryResponse();
|
||||||
|
|
||||||
|
switch (record.Command.CommandType.CommandCode.ToUpper())
|
||||||
|
{
|
||||||
|
case "C-PM-01":
|
||||||
|
case "C-PM-02":
|
||||||
|
case "C-PM-03":
|
||||||
|
case "C-PM-04":
|
||||||
|
data = await _repository.GetPlacementSalaryAsync(record!.RefPlacementProfileId!.Value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
data = await _repository.GetCommandReceiverSalary(personalId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return Success(data);
|
return Success(data);
|
||||||
}
|
}
|
||||||
|
|
@ -3074,9 +3111,18 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
if (receiver == null)
|
if (receiver == null)
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
await _repository.UpdatePlacementSalaryAsync(personalId, req);
|
switch (receiver.Command.CommandType.CommandCode.ToUpper())
|
||||||
|
{
|
||||||
return Success();
|
case "C-PM-01":
|
||||||
|
case "C-PM-02":
|
||||||
|
case "C-PM-03":
|
||||||
|
case "C-PM-04":
|
||||||
|
await _repository.UpdatePlacementSalaryAsync(personalId, req);
|
||||||
|
return Success();
|
||||||
|
default:
|
||||||
|
await _repository.UpdateCommandReceiverSalaryAsync(personalId, req);
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -32,5 +32,14 @@ namespace BMA.EHR.Domain.Models.Commands.Core
|
||||||
|
|
||||||
[Comment("รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ")]
|
[Comment("รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ")]
|
||||||
public Guid? RefPlacementProfileId { get; set; }
|
public Guid? RefPlacementProfileId { get; set; }
|
||||||
|
|
||||||
|
[Comment("เงินเดือน")]
|
||||||
|
public double? Amount { get; set; }
|
||||||
|
|
||||||
|
[Comment("เงินประจำตำแหน่ง")]
|
||||||
|
public double? PositionSalaryAmount { get; set; }
|
||||||
|
|
||||||
|
[Comment("เงินค่าตอบแทนรายเดือน")]
|
||||||
|
public double? MouthSalaryAmount { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16166
BMA.EHR.Infrastructure/Migrations/20230902063606_Add field salary for commandReceiver.Designer.cs
generated
Normal file
16166
BMA.EHR.Infrastructure/Migrations/20230902063606_Add field salary for commandReceiver.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,51 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddfieldsalaryforcommandReceiver : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<double>(
|
||||||
|
name: "Amount",
|
||||||
|
table: "CommandReceivers",
|
||||||
|
type: "double",
|
||||||
|
nullable: true,
|
||||||
|
comment: "เงินเดือน");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<double>(
|
||||||
|
name: "MouthSalaryAmount",
|
||||||
|
table: "CommandReceivers",
|
||||||
|
type: "double",
|
||||||
|
nullable: true,
|
||||||
|
comment: "เงินค่าตอบแทนรายเดือน");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<double>(
|
||||||
|
name: "PositionSalaryAmount",
|
||||||
|
table: "CommandReceivers",
|
||||||
|
type: "double",
|
||||||
|
nullable: true,
|
||||||
|
comment: "เงินประจำตำแหน่ง");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Amount",
|
||||||
|
table: "CommandReceivers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "MouthSalaryAmount",
|
||||||
|
table: "CommandReceivers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionSalaryAmount",
|
||||||
|
table: "CommandReceivers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -463,6 +463,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasComment("PrimaryKey")
|
.HasComment("PrimaryKey")
|
||||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||||
|
|
||||||
|
b.Property<double?>("Amount")
|
||||||
|
.HasColumnType("double")
|
||||||
|
.HasComment("เงินเดือน");
|
||||||
|
|
||||||
b.Property<string>("CitizenId")
|
b.Property<string>("CitizenId")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(13)
|
.HasMaxLength(13)
|
||||||
|
|
@ -528,6 +532,14 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasColumnOrder(102)
|
.HasColumnOrder(102)
|
||||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||||
|
|
||||||
|
b.Property<double?>("MouthSalaryAmount")
|
||||||
|
.HasColumnType("double")
|
||||||
|
.HasComment("เงินค่าตอบแทนรายเดือน");
|
||||||
|
|
||||||
|
b.Property<double?>("PositionSalaryAmount")
|
||||||
|
.HasColumnType("double")
|
||||||
|
.HasComment("เงินประจำตำแหน่ง");
|
||||||
|
|
||||||
b.Property<string>("Prefix")
|
b.Property<string>("Prefix")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue