nettoyer le contrôle html de la facture

vnext
Paul Schneider 7 years ago
parent 44c0faaa29
commit c82a88f6a9
4 changed files with 18 additions and 11 deletions

@ -64,11 +64,9 @@ namespace Yavsc.ApiControllers
return new ChallengeResult(); return new ChallengeResult();
} }
var filename = $"facture-{billingCode}-{id}.pdf"; var fi = BillingHelpers.GetBillInfo(billingCode,id);
FileInfo fi = new FileInfo(Path.Combine(Startup.UserBillsDirName, filename));
if (!fi.Exists) return Ok(new { Error = "Not generated" }); if (!fi.Exists) return Ok(new { Error = "Not generated" });
return File(fi.OpenRead(), "application/x-pdf", filename); ; return File(fi.OpenRead(), "application/x-pdf", fi.Name);
} }
[HttpGet("facture-{billingCode}-{id}.tex"), Authorize] [HttpGet("facture-{billingCode}-{id}.tex"), Authorize]

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using Yavsc.Billing; using Yavsc.Billing;
using Yavsc.Models.Billing; using Yavsc.Models.Billing;
@ -18,5 +19,11 @@ namespace Yavsc.Helpers
$"\n\nTotal: {total}"; $"\n\nTotal: {total}";
return bill; return bill;
} }
public static FileInfo GetBillInfo(string billingcode, long id)
{
var filename = $"facture-{billingcode}-{id}.pdf";
return new FileInfo(Path.Combine(Startup.UserBillsDirName, filename));
}
} }
} }

@ -1,13 +1,12 @@
@model IBillable @model IBillable
<div class="bill"> <div class="bill">
@{ var fi = BillingHelpers.GetBillInfo(ViewBag.BillingCode,Model.Id); }
<a class="btn btn-default" href="~/api/bill/facture-@(ViewBag.BillingCode)-@(Model.Id).tex" >Export au format LaTeX</a> @if (fi.Exists) {
<a class="btn btn-link" href="~/api/bill/facture-@(ViewBag.BillingCode)-@(Model.Id).pdf" >La facture au format Pdf</a>
} else {
<form action="~/api/bill/genpdf/@ViewBag.BillingCode/@Model.Id" method="POST"> <form action="~/api/bill/genpdf/@ViewBag.BillingCode/@Model.Id" method="POST">
<input class="btn btn-default" type="submit" value="Générer le Pdf"/> <input class="btn btn-default" type="submit" value="Générer la facture au format Pdf"/>
</form> </form>
}
<a class="btn btn-link" href="~/api/bill/facture-@(ViewBag.BillingCode)-@(Model.Id).pdf" >Télécharger le document généré</a>
</div> </div>

@ -1199,6 +1199,9 @@
<Content Include="Views\Manage\ChangeUserName.cshtml" /> <Content Include="Views\Manage\ChangeUserName.cshtml" />
<Content Include="Controllers\Haircut\HairCutCommandController.cs" /> <Content Include="Controllers\Haircut\HairCutCommandController.cs" />
<Content Include="Views\Manage\Index.cshtml" /> <Content Include="Views\Manage\Index.cshtml" />
<Content Include="Helpers\BillingHelpers.cs" />
<Content Include="ApiControllers\BillingController.cs" />
<Content Include="Models\Payment\PaypalPayment.cs" />
</ItemGroup> </ItemGroup>
<Import Project="../Yavsc.Abstract/Yavsc.Abstract.csproj" /> <Import Project="../Yavsc.Abstract/Yavsc.Abstract.csproj" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

Loading…