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>
|
||||
/// Renvoye la facture associée à une clé de facturation,
|
||||
/// à partir du couple suivant :
|
||||
///
|
||||
/// * un code de facturation
|
||||
///
|
||||
/// * un code de facturation
|
||||
/// (identifiant associé à un type de demande du client)
|
||||
/// * un entier long identifiant la demande du client
|
||||
/// (à 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="queryId">Identifiant de la demande du client</param>
|
||||
/// <returns>La facture</returns>
|
||||
Task<IDecidableQuery> GetBillAsync(string billingCode, long queryId);
|
||||
|
||||
Task<IQuery> GetBillAsync(string billingCode, long queryId);
|
||||
|
||||
/// <summary>
|
||||
/// Perfomer settings for the specified performer in the activity
|
||||
/// Perfomer settings for the specified performer in the activity
|
||||
/// </summary>
|
||||
/// <param name="activityCode">activityCode</param>
|
||||
/// <param name="userId">performer uid</param>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ namespace Yavsc.Abstract.Workflow
|
|||
{
|
||||
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");
|
||||
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
|
||||
if (billing == null) return BadRequest();
|
||||
billing.Reviewed = true;
|
||||
billing.Accepted = false;
|
||||
|
||||
billing.Status = QueryStatus.Rejected;
|
||||
dbContext.SaveChanges();
|
||||
return Ok();
|
||||
}
|
||||
|
|
@ -47,8 +47,7 @@ namespace Yavsc.ApiControllers
|
|||
if (queryId == 0) return BadRequest("queryId");
|
||||
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
|
||||
if (billing == null) return BadRequest();
|
||||
billing.Accepted = true;
|
||||
billing.Reviewed = true;
|
||||
billing.Status = QueryStatus.Accepted;
|
||||
dbContext.SaveChanges();
|
||||
return Ok();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ namespace Yavsc
|
|||
{
|
||||
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));
|
||||
|
||||
const string testCode = "Brush";
|
||||
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() =>
|
||||
WorkflowHelpers.RegisterBilling<HairCutQuery>(testCode, firstRegistrar));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,12 +53,6 @@
|
|||
<dd>
|
||||
@Html.DisplayFor(model => model.Previsional)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Reviewed)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Reviewed)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.DateModified)
|
||||
</dt>
|
||||
|
|
|
|||
|
|
@ -58,12 +58,6 @@
|
|||
<dd>
|
||||
@Html.DisplayFor(model => model.Previsional)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Reviewed)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Reviewed)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.DateModified)
|
||||
</dt>
|
||||
|
|
|
|||
|
|
@ -42,14 +42,6 @@
|
|||
<span asp-validation-for="Previsional" class="text-danger" ></span>
|
||||
</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">
|
||||
<label asp-for="Status" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@
|
|||
<th>
|
||||
@Html.DisplayNameFor(model => model.Previsional)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Reviewed)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.DateModified)
|
||||
</th>
|
||||
|
|
@ -79,9 +76,6 @@
|
|||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Previsional)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Reviewed)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateModified)
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Yavsc.Helpers
|
|||
}
|
||||
|
||||
public static void RegisterBilling<T>(string code, Func<ApplicationDbContext, long,
|
||||
IDecidableQuery> getter) where T : IBillable
|
||||
IQuery> getter) where T : IBillable
|
||||
{
|
||||
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) =>
|
||||
{
|
||||
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;
|
||||
}));
|
||||
|
||||
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)));
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Yavsc.Models.Billing
|
|||
using Yavsc.Abstract.Workflow;
|
||||
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; }
|
||||
|
||||
|
|
@ -78,9 +78,6 @@ namespace Yavsc.Models.Billing
|
|||
[ForeignKey("ActivityCode"),JsonIgnore,Display(Name="Domaine d'activité")]
|
||||
public virtual Activity Context { get; set ; }
|
||||
|
||||
public bool Reviewed { get; set; }
|
||||
|
||||
|
||||
public abstract System.Collections.Generic.List<IBillItem> GetBillItems();
|
||||
|
||||
public bool GetIsAcquitted()
|
||||
|
|
@ -102,6 +99,5 @@ namespace Yavsc.Models.Billing
|
|||
|
||||
[Display(Name = "Acquittement de la facture")]
|
||||
public virtual PayPalPayment Regularisation { get; set; }
|
||||
public bool Accepted { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Yavsc.Services
|
|||
public class BillingService : IBillingService
|
||||
{
|
||||
public ApplicationDbContext DbContext { get; private set; }
|
||||
public static Dictionary<string, Func<ApplicationDbContext, long, IDecidableQuery>> Billing =
|
||||
new Dictionary<string, Func<ApplicationDbContext, long, IDecidableQuery>>();
|
||||
public static Dictionary<string, Func<ApplicationDbContext, long, IQuery>> Billing =
|
||||
new Dictionary<string, Func<ApplicationDbContext, long, IQuery>>();
|
||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
||||
|
||||
public static Dictionary<string, string> GlobalBillingMap =
|
||||
|
|
@ -25,12 +25,12 @@ namespace Yavsc.Services
|
|||
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));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
var activity = await DbContext.Activities.SingleAsync(a => a.Code == activityCode);
|
||||
|
|
@ -39,7 +39,7 @@ namespace Yavsc.Services
|
|||
|
||||
var dbSetGetter =
|
||||
UserSettings.SingleOrDefault(s => s.Name == activity.SettingsClassName);
|
||||
|
||||
|
||||
if (dbSetGetter==null) return null;
|
||||
var dbSet = dbSetGetter.GetValue(DbContext);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue