This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user