Export Distribution report

This commit is contained in:
2016-09-22 08:49:24 -04:00
parent 206a3f2def
commit 02555eba7e
11 changed files with 216 additions and 21 deletions
@@ -27,6 +27,29 @@ namespace InventoryTraker.Web.Controllers
}
public ActionResult Distribution(DateTime startDate, DateTime endDate)
{
var report = GetDistributionReport(startDate, endDate);
return BetterJson(report.ToArray());
}
public ActionResult DistributionExcel(DateTime startDate, DateTime endDate)
{
var report = GetDistributionReport(startDate, endDate);
var writer = new DistributionReportWriter();
var excel = writer.Write(report);
var filename = $"InventoryDistributionReport{startDate:yyyyMMdd}-{endDate:yyyyMMdd}.xlsx";
return
new FileContentResult(excel, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
{
FileDownloadName = filename
};
}
private DistributionReport[] GetDistributionReport(DateTime startDate, DateTime endDate)
{
var query =
from t in _context.Transactions
@@ -54,7 +77,7 @@ namespace InventoryTraker.Web.Controllers
(item.Transactions).ToArray()
};
return BetterJson(report.ToArray());
return report.ToArray();
}
[HttpGet]
@@ -196,16 +219,16 @@ namespace InventoryTraker.Web.Controllers
};
return inventoryTypeReportItems;
}
}
internal class MovementReportInventoryItem
{
public Inventory Inventory { get; set; }
public int BeginningQuantity { get; set; }
public int AddedQuantity { get; set; }
public int TotalAvailableQuantity { get; set; }
public int DistributedQuantity { get; set; }
public int AdjustmentQuantity { get; set; }
public int EndingQuantity { get; set; }
private class MovementReportInventoryItem
{
public Inventory Inventory { get; set; }
public int BeginningQuantity { get; set; }
public int AddedQuantity { get; set; }
public int TotalAvailableQuantity { get; set; }
public int DistributedQuantity { get; set; }
public int AdjustmentQuantity { get; set; }
public int EndingQuantity { get; set; }
}
}
}