InvokeAsync(
- string code,
- IBillable billable,
- OutputFormat format,
- bool asBill,
- SiteSettings settings
- )
- {
- var di = new DirectoryInfo(settings.Bills);
- var dia = new DirectoryInfo(settings.Avatars);
- ViewBag.BillsDir = di.FullName;
- ViewBag.AvatarsDir = dia.FullName;
- ViewBag.AsBill = asBill; // vrai pour une facture, sinon, c'est un devis
- ViewBag.Acquitted = billable.GetIsAcquitted();
-
- ViewBag.BillingCode = code;
- var client = await dbContext.Users
- .Include(u=>u.PostalAddress)
- .SingleAsync(u=>u.Id == billable.ClientId);
- ViewBag.Client = client;
- var performer = await dbContext.Users
- .Include(u=>u.BankInfo)
- .Include(u=>u.PostalAddress)
- .SingleAsync(u=>u.Id == billable.PerformerId);
- ViewBag.Performer = performer;
- string clientAddress = client.PostalAddress?.Address ?? null;
- ViewBag.ClientAddress = clientAddress.SplitAddressToTeX();
-
-
- var profile = await dbContext.Performers
- .Include(p=>p.OrganizationAddress)
- .SingleAsync(p=>p.PerformerId == billable.PerformerId);
- ViewBag.PerformerProfile = profile;
- ViewBag.ActivityLabel = (await dbContext.Activities.SingleAsync(a => a.Code == billable.ActivityCode)).Name;
-
- var proAddr = profile.OrganizationAddress.Address;
- ViewBag.PerformerOrganizationAddress = proAddr.SplitAddressToTeX() ;
- ViewBag.FooterPerformerOrganizationAddress = proAddr.SplitAddressToTeX(", ");
-
- ViewBag.PerformerAddress = performer.PostalAddress?.Address.SplitAddressToTeX() ;
- switch (format) {
- case OutputFormat.LaTeX :
- return this.View("Bill_tex", billable);
- case OutputFormat.Pdf :
- string tex = null;
- var oldWriter = ViewComponentContext.ViewContext.Writer;
- using (var writer = new StringWriter())
- {
- this.ViewComponentContext.ViewContext.Writer = writer;
- var resultTex = View("Bill_tex", billable);
- await resultTex.ExecuteAsync(this.ViewComponentContext);
- tex = writer.ToString();
- }
- ViewComponentContext.ViewContext.Writer = oldWriter;
-
- var pdfGenerationViewModel = new PdfGenerationViewModel
- {
- Temp = siteSettings.TempDir,
- TeXSource = tex,
- DestDir = siteSettings.Bills,
- BaseFileName = billable.GetFileBaseName(billing)
- };
- if (settings.GenerateEstimatePdf(pdfGenerationViewModel)) {
- return this.View(new { Generated = pdfGenerationViewModel.BaseFileName+".pdf" });
- } else {
- return View(new { Error = pdfGenerationViewModel.GenerationErrorMessage } );
- }
- }
- ViewBag.BillFileInfo = billable.GetBillInfo(billing, siteSettings);
- ViewBag.Settings = settings;
- return View("Default",billable);
-
- }
-
- }
-}
diff --git a/src/Yavsc.Org/Views/Shared/Components/Bill/Bill_pdf.cshtml b/src/Yavsc.Org/Views/Shared/Components/Bill/Bill_pdf.cshtml
deleted file mode 100644
index f49fad802..000000000
--- a/src/Yavsc.Org/Views/Shared/Components/Bill/Bill_pdf.cshtml
+++ /dev/null
@@ -1,21 +0,0 @@
-@using System.Reflection
-@using System.IO
-@using Microsoft.Extensions.WebEncoders
-@using System.Diagnostics
-@using System.Text
-@using Yavsc.Helpers
-@model Yavsc.ViewModels.Gen.PdfGenerationViewModel
-
-@{
- ViewBag.Settings.GenerateEstimatePdf(Model);
-}
-@if (Model.Generated) {
-
- @(Model.BaseFileName).pdf was generated
-
-} else {
-
- @Model.GenerationErrorMessage
-
Something went wrong ...
-
-}
diff --git a/src/Yavsc.Org/Views/Shared/Components/Bill/Default.cshtml b/src/Yavsc.Org/Views/Shared/Components/Bill/Default.cshtml
deleted file mode 100644
index f2d0e0163..000000000
--- a/src/Yavsc.Org/Views/Shared/Components/Bill/Default.cshtml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-@model IBillable
-
diff --git a/src/Yavsc.Org/Views/Shared/Components/Estimate/Default.cshtml b/src/Yavsc.Org/Views/Shared/Components/Estimate/Default.cshtml
deleted file mode 100644
index b9a1ab26d..000000000
--- a/src/Yavsc.Org/Views/Shared/Components/Estimate/Default.cshtml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-@model Estimate
-
diff --git a/src/Yavsc.Org/Views/Shared/Components/Estimate/Estimate_pdf.cshtml b/src/Yavsc.Org/Views/Shared/Components/Estimate/Estimate_pdf.cshtml
deleted file mode 100644
index bef19b35a..000000000
--- a/src/Yavsc.Org/Views/Shared/Components/Estimate/Estimate_pdf.cshtml
+++ /dev/null
@@ -1,21 +0,0 @@
-@using System.Reflection
-@using System.IO
-@using Microsoft.Extensions.WebEncoders
-@using System.Diagnostics
-@using System.Text
-@using Yavsc.Helpers
-@model Yavsc.ViewModels.Gen.PdfGenerationViewModel
-
-@{
- SiteSettings.Value.GenerateEstimatePdf(Model);
-}
-@if (Model.Generated) {
-
- @(Model.BaseFileName).pdf was generated
-
-} else {
-
- @Model.GenerationErrorMessage
-
Something went wrong ...
-
-}
diff --git a/src/Yavsc.Org/Yavsc.Org.csproj b/src/Yavsc.Org/Yavsc.Org.csproj
index 928faf7c8..99e0cf29c 100644
--- a/src/Yavsc.Org/Yavsc.Org.csproj
+++ b/src/Yavsc.Org/Yavsc.Org.csproj
@@ -9,8 +9,8 @@
https://github.com/pazof/yavsc
1.1.0.0
1.1.0.0
- 1.1.0-feat-sign-estimate.1+306.Branch.feat-sign-estimate.Sha.e9a33695b38154859729b61d1280e596f1597acf
- 1.1.0-feat-sign-estimate.1
+ 1.1.0-estimate.1+343.Branch.feature-estimate.Sha.ba40698cc9562f0f4ad2dcad4dd20e638c05b07d
+ 1.1.0-estimate.1
@@ -47,4 +47,4 @@
-
+
\ No newline at end of file
diff --git a/src/Yavsc.Server/Helpers/FileSystemHelpers.cs b/src/Yavsc.Server/Helpers/FileSystemHelpers.cs
index bc7b9c81d..77e691ea5 100644
--- a/src/Yavsc.Server/Helpers/FileSystemHelpers.cs
+++ b/src/Yavsc.Server/Helpers/FileSystemHelpers.cs
@@ -34,7 +34,7 @@ namespace Yavsc.Server.Helpers
{
var item = new FileReceivedInfo(
settings.Bills,
- AbstractFileSystemHelpers.SignFileNameFormat("pro", billingCode, estimateId));
+ AbstractFileSystemHelpers.SignFileNameFormat(signType, billingCode, estimateId));
var fi = new FileInfo(item.FullName);
if (fi.Exists) item.Overridden = true;
diff --git a/src/Yavsc.Server/Models/Billing/Estimate.cs b/src/Yavsc.Server/Models/Billing/Estimate.cs
index 74680e7b7..8a26faab9 100644
--- a/src/Yavsc.Server/Models/Billing/Estimate.cs
+++ b/src/Yavsc.Server/Models/Billing/Estimate.cs
@@ -8,6 +8,7 @@ namespace Yavsc.Models.Billing
{
using Models.Workflow;
using Newtonsoft.Json;
+ using System.Linq;
public partial class Estimate : IEstimate
{
@@ -78,14 +79,39 @@ namespace Yavsc.Models.Billing
public DateTime ClientValidationDate { get; set; }
///
- /// All signatures captured against this estimate, in
- /// capture order. Multiple versions per (Type, SignerId)
- /// are allowed; the controller reads the most recent
- /// when asked. See .
+ /// All signatures captured against this estimate, keyed by
+ /// . The persister upserts by
+ /// (EstimateId, Type), so there is at most one row per type.
+ /// This collection is the persisted shape and stays
+ /// [JsonIgnore]: the wire payload exposes signatures
+ /// only through the dedicated and
+ /// projections, since an
+ /// estimate has exactly these two signature slots and never
+ /// more. See .
///
[InverseProperty(nameof(Signature.Estimate))]
+ [JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
public virtual ICollection Signatures { get; set; }
= new List();
+ ///
+ /// The provider's signature on this estimate, or null when the
+ /// provider has not signed. Projected from
+ /// ; not mapped (the table is
+ /// ).
+ ///
+ [NotMapped]
+ public Signature? SignaturePro
+ => Signatures?.FirstOrDefault(s => s.Type == SignatureType.Pro);
+
+ ///
+ /// The client's signature on this estimate, or null when the
+ /// client has not signed. Projected from
+ /// ; not mapped.
+ ///
+ [NotMapped]
+ public Signature? SignatureClient
+ => Signatures?.FirstOrDefault(s => s.Type == SignatureType.Client);
+
}
}
diff --git a/src/Yavsc.Server/Models/Billing/Signature.cs b/src/Yavsc.Server/Models/Billing/Signature.cs
index 1aac0cd0e..7e568dbd1 100644
--- a/src/Yavsc.Server/Models/Billing/Signature.cs
+++ b/src/Yavsc.Server/Models/Billing/Signature.cs
@@ -31,7 +31,7 @@ public class Signature
public long EstimateId { get; set; }
- [ForeignKey(nameof(EstimateId)), JsonIgnore]
+ [ForeignKey(nameof(EstimateId)), JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
public virtual Estimate Estimate { get; set; }
///
@@ -48,7 +48,7 @@ public class Signature
[Required]
public string SignerId { get; set; }
- [ForeignKey(nameof(SignerId)), JsonIgnore]
+ [ForeignKey(nameof(SignerId)), JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
public virtual ApplicationUser Signer { get; set; }
public SignatureType Type { get; set; }
diff --git a/src/Yavsc.Server/Yavsc.Server.csproj b/src/Yavsc.Server/Yavsc.Server.csproj
index bb2022fc6..b291847c0 100644
--- a/src/Yavsc.Server/Yavsc.Server.csproj
+++ b/src/Yavsc.Server/Yavsc.Server.csproj
@@ -9,8 +9,8 @@
true
1.1.0.0
1.1.0.0
- 1.1.0-feat-sign-estimate.1+306.Branch.feat-sign-estimate.Sha.e9a33695b38154859729b61d1280e596f1597acf
- 1.1.0-feat-sign-estimate.1
+ 1.1.0-estimate.1+343.Branch.feature-estimate.Sha.ba40698cc9562f0f4ad2dcad4dd20e638c05b07d
+ 1.1.0-estimate.1
diff --git a/src/Yavsc.Tests.Shared/Yavsc.Tests.Shared.csproj b/src/Yavsc.Tests.Shared/Yavsc.Tests.Shared.csproj
index dd93a8b34..830377ca2 100644
--- a/src/Yavsc.Tests.Shared/Yavsc.Tests.Shared.csproj
+++ b/src/Yavsc.Tests.Shared/Yavsc.Tests.Shared.csproj
@@ -14,8 +14,8 @@
-->
1.1.0.0
1.1.0.0
- 1.1.0-feat-sign-estimate.1+306.Branch.feat-sign-estimate.Sha.e9a33695b38154859729b61d1280e596f1597acf
- 1.1.0-feat-sign-estimate.1
+ 1.1.0-estimate.1+343.Branch.feature-estimate.Sha.ba40698cc9562f0f4ad2dcad4dd20e638c05b07d
+ 1.1.0-estimate.1
diff --git a/src/cli/cli.csproj b/src/cli/cli.csproj
index 382dff670..39ef7660f 100644
--- a/src/cli/cli.csproj
+++ b/src/cli/cli.csproj
@@ -7,8 +7,8 @@
true
1.1.0.0
1.1.0.0
- 1.1.0-feat-sign-estimate.1+306.Branch.feat-sign-estimate.Sha.e9a33695b38154859729b61d1280e596f1597acf
- 1.1.0-feat-sign-estimate.1
+ 1.1.0-estimate.1+343.Branch.feature-estimate.Sha.ba40698cc9562f0f4ad2dcad4dd20e638c05b07d
+ 1.1.0-estimate.1