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

This commit is contained in:
kamonwan taengsuk
2023-11-06 17:19:58 +07:00
parent 4c9484d57e
commit ba2a5b966e
12 changed files with 176 additions and 4 deletions

View File

@@ -1197,6 +1197,64 @@ namespace rmutr_report.Controllers
"compensation_ro_three" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("เงินสมทบกองทุนประกันสังคม_เงินสมทบกองทุนเงินทดแทน")]
[HttpPost, Route("reports/contributions/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetContributionsReport([FromRoute] string type,
[FromBody] contributions contributions)
{
var compensation = contributions.data.ToList();
if (contributions.topic_type == 1)
{
contributions.topic_name = "เงินสมทบกองทุนประกันสังคม";
foreach (var detail in contributions.data)
{
detail.amount = (detail.salary * 5)/100;
detail.per_year = (detail.amount * 12);
}
}
if (contributions.topic_type == 2)
{
contributions.topic_name = "เงินสมทบกองทุนเงินทดแทน";
foreach (var detail in contributions.data)
{
detail.amount = (detail.salary * (decimal?)0.2)/100;
detail.per_year = (detail.amount * 12);
}
}
contributions.total_amount = compensation.Sum(f => f.per_year);
var _contributions = new List<contributions>() { contributions };
Report report = new Report();
report.Load(_setting.report_path + "contributions.frx");
report.RegisterData(_contributions, "contributions");
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",
"contributions" + ".xlsx");
}
return Ok();
}
}