refacto query status
This commit is contained in:
parent
ee6cb34c23
commit
7b3a236bcc
11 changed files with 20 additions and 53 deletions
|
|
@ -17,8 +17,8 @@ namespace Yavsc.Services
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renvoye la facture associée à une clé de facturation,
|
/// Renvoye la facture associée à une clé de facturation,
|
||||||
/// à partir du couple suivant :
|
/// à partir du couple suivant :
|
||||||
///
|
///
|
||||||
/// * un code de facturation
|
/// * un code de facturation
|
||||||
/// (identifiant associé à un type de demande du client)
|
/// (identifiant associé à un type de demande du client)
|
||||||
/// * un entier long identifiant la demande du client
|
/// * un entier long identifiant la demande du client
|
||||||
/// (à une demande, on associe au maximum une seule facture)
|
/// (à une demande, on associe au maximum une seule facture)
|
||||||
|
|
@ -26,10 +26,10 @@ namespace Yavsc.Services
|
||||||
/// <param name="billingCode">Identifiant du type de facturation</param>
|
/// <param name="billingCode">Identifiant du type de facturation</param>
|
||||||
/// <param name="queryId">Identifiant de la demande du client</param>
|
/// <param name="queryId">Identifiant de la demande du client</param>
|
||||||
/// <returns>La facture</returns>
|
/// <returns>La facture</returns>
|
||||||
Task<IDecidableQuery> GetBillAsync(string billingCode, long queryId);
|
Task<IQuery> GetBillAsync(string billingCode, long queryId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perfomer settings for the specified performer in the activity
|
/// Perfomer settings for the specified performer in the activity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="activityCode">activityCode</param>
|
/// <param name="activityCode">activityCode</param>
|
||||||
/// <param name="userId">performer uid</param>
|
/// <param name="userId">performer uid</param>
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ namespace Yavsc.Abstract.Workflow
|
||||||
{
|
{
|
||||||
public interface IDecidableQuery: ITrackedEntity, IQuery
|
public interface IDecidableQuery: ITrackedEntity, IQuery
|
||||||
{
|
{
|
||||||
bool Reviewed { get; set; }
|
|
||||||
bool Accepted { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ namespace Yavsc.ApiControllers
|
||||||
if (queryId == 0) return BadRequest("queryId");
|
if (queryId == 0) return BadRequest("queryId");
|
||||||
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
|
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
|
||||||
if (billing == null) return BadRequest();
|
if (billing == null) return BadRequest();
|
||||||
billing.Reviewed = true;
|
|
||||||
billing.Accepted = false;
|
billing.Status = QueryStatus.Rejected;
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -47,8 +47,7 @@ namespace Yavsc.ApiControllers
|
||||||
if (queryId == 0) return BadRequest("queryId");
|
if (queryId == 0) return BadRequest("queryId");
|
||||||
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
|
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
|
||||||
if (billing == null) return BadRequest();
|
if (billing == null) return BadRequest();
|
||||||
billing.Accepted = true;
|
billing.Status = QueryStatus.Accepted;
|
||||||
billing.Reviewed = true;
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,11 @@ namespace Yavsc
|
||||||
{
|
{
|
||||||
WorkflowHelpers.ConfigureBillingService();
|
WorkflowHelpers.ConfigureBillingService();
|
||||||
|
|
||||||
var firstRegistrar = new Func<ApplicationDbContext, long, IDecidableQuery>((db, id) =>
|
var firstRegistrar = new Func<ApplicationDbContext, long, IQuery>((db, id) =>
|
||||||
db.HairCutQueries.Include(q => q.Prestation).Include(q => q.Regularisation).Single(q => q.Id == id));
|
db.HairCutQueries.Include(q => q.Prestation).Include(q => q.Regularisation).Single(q => q.Id == id));
|
||||||
|
|
||||||
const string testCode = "Brush";
|
const string testCode = "Brush";
|
||||||
|
|
||||||
Assert.Throws<InvalidOperationException>(() =>
|
Assert.Throws<InvalidOperationException>(() =>
|
||||||
WorkflowHelpers.RegisterBilling<HairCutQuery>(testCode, firstRegistrar));
|
WorkflowHelpers.RegisterBilling<HairCutQuery>(testCode, firstRegistrar));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,6 @@
|
||||||
<dd>
|
<dd>
|
||||||
@Html.DisplayFor(model => model.Previsional)
|
@Html.DisplayFor(model => model.Previsional)
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
|
||||||
@Html.DisplayNameFor(model => model.Reviewed)
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
@Html.DisplayFor(model => model.Reviewed)
|
|
||||||
</dd>
|
|
||||||
<dt>
|
<dt>
|
||||||
@Html.DisplayNameFor(model => model.DateModified)
|
@Html.DisplayNameFor(model => model.DateModified)
|
||||||
</dt>
|
</dt>
|
||||||
|
|
|
||||||
|
|
@ -58,12 +58,6 @@
|
||||||
<dd>
|
<dd>
|
||||||
@Html.DisplayFor(model => model.Previsional)
|
@Html.DisplayFor(model => model.Previsional)
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
|
||||||
@Html.DisplayNameFor(model => model.Reviewed)
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
@Html.DisplayFor(model => model.Reviewed)
|
|
||||||
</dd>
|
|
||||||
<dt>
|
<dt>
|
||||||
@Html.DisplayNameFor(model => model.DateModified)
|
@Html.DisplayNameFor(model => model.DateModified)
|
||||||
</dt>
|
</dt>
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,6 @@
|
||||||
<span asp-validation-for="Previsional" class="text-danger" ></span>
|
<span asp-validation-for="Previsional" class="text-danger" ></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-md-offset-2 col-md-10">
|
|
||||||
<div class="checkbox">
|
|
||||||
<input asp-for="Reviewed" />
|
|
||||||
<label asp-for="Reviewed"></label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Status" class="col-md-2 control-label"></label>
|
<label asp-for="Status" class="col-md-2 control-label"></label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Previsional)
|
@Html.DisplayNameFor(model => model.Previsional)
|
||||||
</th>
|
</th>
|
||||||
<th>
|
|
||||||
@Html.DisplayNameFor(model => model.Reviewed)
|
|
||||||
</th>
|
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.DateModified)
|
@Html.DisplayNameFor(model => model.DateModified)
|
||||||
</th>
|
</th>
|
||||||
|
|
@ -79,9 +76,6 @@
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Previsional)
|
@Html.DisplayFor(modelItem => item.Previsional)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Reviewed)
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.DateModified)
|
@Html.DisplayFor(modelItem => item.DateModified)
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Yavsc.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterBilling<T>(string code, Func<ApplicationDbContext, long,
|
public static void RegisterBilling<T>(string code, Func<ApplicationDbContext, long,
|
||||||
IDecidableQuery> getter) where T : IBillable
|
IQuery> getter) where T : IBillable
|
||||||
{
|
{
|
||||||
lock (_billingLock)
|
lock (_billingLock)
|
||||||
{
|
{
|
||||||
|
|
@ -91,7 +91,7 @@ namespace Yavsc.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterBilling<HairCutQuery>(BillingCodes.Brush, new Func<ApplicationDbContext, long, IDecidableQuery>
|
RegisterBilling<HairCutQuery>(BillingCodes.Brush, new Func<ApplicationDbContext, long, IQuery>
|
||||||
((db, id) =>
|
((db, id) =>
|
||||||
{
|
{
|
||||||
var query = db.HairCutQueries.Include(q => q.Prestation).Include(q => q.Regularisation).Single(q => q.Id == id);
|
var query = db.HairCutQueries.Include(q => q.Prestation).Include(q => q.Regularisation).Single(q => q.Id == id);
|
||||||
|
|
@ -99,10 +99,10 @@ namespace Yavsc.Helpers
|
||||||
return query;
|
return query;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
RegisterBilling<HairMultiCutQuery>(BillingCodes.MBrush, new Func<ApplicationDbContext, long, IDecidableQuery>
|
RegisterBilling<HairMultiCutQuery>(BillingCodes.MBrush, new Func<ApplicationDbContext, long, IQuery>
|
||||||
((db, id) => db.HairMultiCutQueries.Include(q => q.Regularisation).Single(q => q.Id == id)));
|
((db, id) => db.HairMultiCutQueries.Include(q => q.Regularisation).Single(q => q.Id == id)));
|
||||||
|
|
||||||
RegisterBilling<RdvQuery>(BillingCodes.Rdv, new Func<ApplicationDbContext, long, IDecidableQuery>
|
RegisterBilling<RdvQuery>(BillingCodes.Rdv, new Func<ApplicationDbContext, long, IQuery>
|
||||||
((db, id) => db.RdvQueries.Include(q => q.Regularisation).Single(q => q.Id == id)));
|
((db, id) => db.RdvQueries.Include(q => q.Regularisation).Single(q => q.Id == id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Yavsc.Models.Billing
|
||||||
using Yavsc.Abstract.Workflow;
|
using Yavsc.Abstract.Workflow;
|
||||||
using Yavsc.Services;
|
using Yavsc.Services;
|
||||||
|
|
||||||
public abstract class NominativeServiceCommand : IDecidableQuery, IIdentified<long>, IBillable
|
public abstract class NominativeServiceCommand : IQuery, IIdentified<long>, IBillable
|
||||||
{
|
{
|
||||||
public string GetInvoiceId() { return GetType().Name + "/" + Id; }
|
public string GetInvoiceId() { return GetType().Name + "/" + Id; }
|
||||||
|
|
||||||
|
|
@ -78,9 +78,6 @@ namespace Yavsc.Models.Billing
|
||||||
[ForeignKey("ActivityCode"),JsonIgnore,Display(Name="Domaine d'activité")]
|
[ForeignKey("ActivityCode"),JsonIgnore,Display(Name="Domaine d'activité")]
|
||||||
public virtual Activity Context { get; set ; }
|
public virtual Activity Context { get; set ; }
|
||||||
|
|
||||||
public bool Reviewed { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public abstract System.Collections.Generic.List<IBillItem> GetBillItems();
|
public abstract System.Collections.Generic.List<IBillItem> GetBillItems();
|
||||||
|
|
||||||
public bool GetIsAcquitted()
|
public bool GetIsAcquitted()
|
||||||
|
|
@ -102,6 +99,5 @@ namespace Yavsc.Models.Billing
|
||||||
|
|
||||||
[Display(Name = "Acquittement de la facture")]
|
[Display(Name = "Acquittement de la facture")]
|
||||||
public virtual PayPalPayment Regularisation { get; set; }
|
public virtual PayPalPayment Regularisation { get; set; }
|
||||||
public bool Accepted { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ namespace Yavsc.Services
|
||||||
public class BillingService : IBillingService
|
public class BillingService : IBillingService
|
||||||
{
|
{
|
||||||
public ApplicationDbContext DbContext { get; private set; }
|
public ApplicationDbContext DbContext { get; private set; }
|
||||||
public static Dictionary<string, Func<ApplicationDbContext, long, IDecidableQuery>> Billing =
|
public static Dictionary<string, Func<ApplicationDbContext, long, IQuery>> Billing =
|
||||||
new Dictionary<string, Func<ApplicationDbContext, long, IDecidableQuery>>();
|
new Dictionary<string, Func<ApplicationDbContext, long, IQuery>>();
|
||||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
||||||
|
|
||||||
public static Dictionary<string, string> GlobalBillingMap =
|
public static Dictionary<string, string> GlobalBillingMap =
|
||||||
|
|
@ -25,12 +25,12 @@ namespace Yavsc.Services
|
||||||
DbContext = dbContext;
|
DbContext = dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IDecidableQuery> GetBillAsync(string billingCode, long queryId)
|
public Task<IQuery> GetBillAsync(string billingCode, long queryId)
|
||||||
{
|
{
|
||||||
return Task.FromResult(GetBillable(DbContext, billingCode, queryId));
|
return Task.FromResult(GetBillable(DbContext, billingCode, queryId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDecidableQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId) => Billing[billingCode](context, queryId);
|
public static IQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId) => Billing[billingCode](context, queryId);
|
||||||
public async Task<IUserSettings> GetPerformersSettingsAsync(string activityCode, string userId)
|
public async Task<IUserSettings> GetPerformersSettingsAsync(string activityCode, string userId)
|
||||||
{
|
{
|
||||||
var activity = await DbContext.Activities.SingleAsync(a => a.Code == activityCode);
|
var activity = await DbContext.Activities.SingleAsync(a => a.Code == activityCode);
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Yavsc.Services
|
||||||
|
|
||||||
var dbSetGetter =
|
var dbSetGetter =
|
||||||
UserSettings.SingleOrDefault(s => s.Name == activity.SettingsClassName);
|
UserSettings.SingleOrDefault(s => s.Name == activity.SettingsClassName);
|
||||||
|
|
||||||
if (dbSetGetter==null) return null;
|
if (dbSetGetter==null) return null;
|
||||||
var dbSet = dbSetGetter.GetValue(DbContext);
|
var dbSet = dbSetGetter.GetValue(DbContext);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue