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

This commit is contained in:
kamonwan taengsuk
2023-10-21 21:09:37 +07:00
parent e206bf0efe
commit 5441324de9
21 changed files with 201 additions and 6 deletions

View File

@@ -1172,6 +1172,68 @@ namespace rmutr_report.Controllers
"ค่าอาหารทำการนอกเวลา" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("ค่าเบี้ยเลี้ยง ที่พัก พาหนะ")]
[HttpPost, Route("reports/expense/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetExpenseReport([FromRoute] string type,
[FromBody] expense _expense)
{
var meals = _expense.data.ToList();
if (_expense.topic_type==1)
{
_expense.topic = "ค่าเบี้ยเลี้ยง";
_expense.text_1 = "จำนวนเงิน/วัน";
_expense.text_2 = "จำนวน (วัน)";
}
if (_expense.topic_type==2)
{
_expense.topic = "ค่าเช่าที่พัก";
_expense.text_1 = "จำนวนเงิน/คน/คืน";
_expense.text_2 = "จำนวนวัน";
}
if (_expense.topic_type==3)
{
_expense.topic = "ค่าพาหนะ";
_expense.text_1 = "จำนวนเงิน";
_expense.text_2 = "จำนวนครั้ง";
}
foreach (var detail in _expense.data)
{
detail.total_amount = (detail.quantity_1*detail.quantity_2*detail.quantity_3);
}
_expense.quantity_1 = _expense.data.Sum(d => d.quantity_1);
_expense.quantity_2 = _expense.data.Sum(d => d.quantity_2);
_expense.quantity_3 = _expense.data.Sum(d => d.quantity_3);
_expense.total_amount = meals.Sum(f => f.total_amount);
var expenses = new List<expense>() { _expense };
Report report = new Report();
report.Load(_setting.report_path + "expense.frx");
report.RegisterData(expenses, "expense");
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",
"ค่าใช้สอย" + ".xlsx");
}
return Ok();
}
}