update
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kamonwan taengsuk
2023-11-06 12:38:12 +07:00
parent 6fcb0a856a
commit 4c9484d57e
16 changed files with 533 additions and 21 deletions

View File

@@ -1037,6 +1037,166 @@ namespace rmutr_report.Controllers
break;
}
return Ok();
}
[SwaggerOperation("ค่าตอบแทนอื่นๆ")]
[HttpPost, Route("reports/other_compensation/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetCompensationReport([FromRoute] string type,
[FromBody] parcel_inspection_committee committee)
{
int no = 1;
foreach (var data in committee.data)
{
data.list = "รายการ " + no;
no++;
foreach (var detail in data.data_detail)
{
if (detail != null)
{
detail.total_amount = ( detail.quantity_person *
detail.amount);
}
}
data.total_amount = data.data_detail.Sum(f => f.total_amount);
var s = committee.data.Sum(d => d.total_amount);
committee.total_all_amount = s;
}
var expenses = new List<parcel_inspection_committee>() { committee };
Report report = new Report();
report.Load(_setting.report_path + "other_compensation.frx");
report.RegisterData(expenses, "parcel_inspection_committee");
report.Prepare();
MemoryStream stream = new MemoryStream();
switch (type)
{
case "pdf":
PDFExport pdf = new PDFExport();
report.Export(pdf, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(
stream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"other_compensation" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("ค่าตอบแทน_ค่าเช่าบ้าน")]
[HttpPost, Route("reports/house_rent_ro_three/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetHouseRentReport([FromRoute] string type,
[FromBody] house_rent_ro_three houseRent)
{
if (houseRent.topic_type == 1)
{
houseRent.topic_name = "ค่าเช่าบ้านชาวต่างประเทศ";
}
if (houseRent.topic_type == 2)
{
houseRent.topic_name = "ค่าเช่าบ้านครูอาสาสมัคร(ชาวจีน)";
}
if (houseRent.topic_type == 3)
{
houseRent.topic_name = "ค่าเช่าบ้านที่ปรึกษาชาวต่างประเทศ";
}
var house = new List<house_rent_ro_three>() { houseRent };
Report report = new Report();
report.Load(_setting.report_path + "house_rent_ro_three.frx");
report.RegisterData(house, "house_rent_ro_three");
report.Prepare();
MemoryStream stream = new MemoryStream();
switch (type)
{
case "pdf":
PDFExport pdf = new PDFExport();
report.Export(pdf, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(
stream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"house_rent_ro_three" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("ค่าตอบแทนพิเศษรายเดือน_ค่าตอบแทนเงินประจำตำแหน่ง")]
[HttpPost, Route("reports/compensation_ro_three/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetCompensationMoneyReport([FromRoute] string type,
[FromBody] compensation_ro_three compensationRoThree)
{
var compensation = compensationRoThree.data.ToList();
if (compensationRoThree.topic_type == 1)
{
compensationRoThree.topic_name = "ค่าตอบแทนพิเศษรายเดือน อาจารย์ชาวต่างประเทศ";
}
if (compensationRoThree.topic_type == 2)
{
compensationRoThree.topic_name = "ค่าตอบแทนเงินประจำตำแหน่ง";
}
foreach (var detail in compensationRoThree.data)
{
detail.budget_amount = (detail.salary_rate * 12);
}
compensationRoThree.total_amount = compensation.Sum(f => f.budget_amount);
var compensationRoThrees = new List<compensation_ro_three>() { compensationRoThree };
Report report = new Report();
report.Load(_setting.report_path + "compensation_ro_three.frx");
report.RegisterData(compensationRoThrees, "compensation_ro_three");
report.Prepare();
MemoryStream stream = new MemoryStream();
switch (type)
{
case "pdf":
PDFExport pdf = new PDFExport();
report.Export(pdf, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(
stream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"compensation_ro_three" + ".xlsx");
}
return Ok();
}
}