diff --git a/Controllers/RoThree.Controller.cs b/Controllers/RoThree.Controller.cs index 12eaf79..10240a0 100644 --- a/Controllers/RoThree.Controller.cs +++ b/Controllers/RoThree.Controller.cs @@ -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 }; + 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(); } } diff --git a/Models/RoReport/contributions.cs b/Models/RoReport/contributions.cs new file mode 100644 index 0000000..ad9a04b --- /dev/null +++ b/Models/RoReport/contributions.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models.RoThree +{ + public class contributions + { + public int? topic_type { get; set; } //1 2 + public string topic_name { get; set; } + public decimal? total_amount { get; set; } + + public List data { get; set; } + } + + public class contributions_detail + { + public string position { get; set; } + public string qualification { get; set; } + public decimal? salary { get; set; } + public decimal? amount { get; set; } + public decimal? per_year { get; set; } + } +} \ No newline at end of file diff --git a/bin/Debug/netcoreapp3.1/rmutr_report.dll b/bin/Debug/netcoreapp3.1/rmutr_report.dll index a66f7c0..0869629 100644 Binary files a/bin/Debug/netcoreapp3.1/rmutr_report.dll and b/bin/Debug/netcoreapp3.1/rmutr_report.dll differ diff --git a/bin/Debug/netcoreapp3.1/rmutr_report.pdb b/bin/Debug/netcoreapp3.1/rmutr_report.pdb index 36b0890..73fff02 100644 Binary files a/bin/Debug/netcoreapp3.1/rmutr_report.pdb and b/bin/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache index badd940..45746e9 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -38a9d07017ef8cf4da24333a91be9dc5a1c91c4d +04ffabe9d09db3eaf66c7e59e1b69ef6220d980e diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.dll b/obj/Debug/netcoreapp3.1/rmutr_report.dll index a66f7c0..0869629 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.dll and b/obj/Debug/netcoreapp3.1/rmutr_report.dll differ diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.pdb b/obj/Debug/netcoreapp3.1/rmutr_report.pdb index 36b0890..73fff02 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.pdb and b/obj/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/obj/Debug/netcoreapp3.1/staticwebassets/msbuild.rmutr_report.Microsoft.AspNetCore.StaticWebAssets.props b/obj/Debug/netcoreapp3.1/staticwebassets/msbuild.rmutr_report.Microsoft.AspNetCore.StaticWebAssets.props index 0f74358..6be04d7 100644 --- a/obj/Debug/netcoreapp3.1/staticwebassets/msbuild.rmutr_report.Microsoft.AspNetCore.StaticWebAssets.props +++ b/obj/Debug/netcoreapp3.1/staticwebassets/msbuild.rmutr_report.Microsoft.AspNetCore.StaticWebAssets.props @@ -320,6 +320,22 @@ PreserveNewest $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\reports\compensation_ro_three.frx)) + + Package + rmutr_report + $(MSBuildThisFileDirectory)..\staticwebassets\ + _content/rmutr_report + reports\contributions.frx + + + + + + + + PreserveNewest + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\reports\contributions.frx)) + Package rmutr_report diff --git a/obj/Debug/netcoreapp3.1/staticwebassets/rmutr_report.StaticWebAssets.Pack.cache b/obj/Debug/netcoreapp3.1/staticwebassets/rmutr_report.StaticWebAssets.Pack.cache index 5407f81..c6747be 100644 --- a/obj/Debug/netcoreapp3.1/staticwebassets/rmutr_report.StaticWebAssets.Pack.cache +++ b/obj/Debug/netcoreapp3.1/staticwebassets/rmutr_report.StaticWebAssets.Pack.cache @@ -1 +1 @@ -27b0df10d71791bb35e369c161be6ce323153ef6 +645f8f19f3f7269784e8db7e853e5c6df8c222f9 diff --git a/obj/rider.project.model.nuget.info b/obj/rider.project.model.nuget.info index 9f761de..1ba63a6 100644 --- a/obj/rider.project.model.nuget.info +++ b/obj/rider.project.model.nuget.info @@ -1 +1 @@ -16983221242759201 \ No newline at end of file +16992484278328616 \ No newline at end of file diff --git a/obj/rider.project.restore.info b/obj/rider.project.restore.info index 1ba63a6..6aff16d 100644 --- a/obj/rider.project.restore.info +++ b/obj/rider.project.restore.info @@ -1 +1 @@ -16992484278328616 \ No newline at end of file +16992659798608142 \ No newline at end of file diff --git a/wwwroot/reports/contributions.frx b/wwwroot/reports/contributions.frx new file mode 100644 index 0000000..df7f8e2 --- /dev/null +++ b/wwwroot/reports/contributions.frx @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +