billing
This commit is contained in:
parent
7b9078c6da
commit
42c08797e3
44 changed files with 2798 additions and 350 deletions
|
|
@ -40,7 +40,7 @@ namespace Yavsc.Helpers
|
|||
string evdate = query.EventDate?.ToString("dddd dd/MM/yyyy à HH:mm")??"[pas de date spécifiée]";
|
||||
string address = query.Location?.Address??"[pas de lieu spécifié]";
|
||||
var p = query.Prestation;
|
||||
decimal total = query.Prestation.Addition(bpr);
|
||||
decimal total = query.Addition(bpr);
|
||||
string strprestation = $@"Coupe: {p.Cut}, Total: {total}";
|
||||
|
||||
var yaev = new HairCutQueryEvent
|
||||
|
|
|
|||
|
|
@ -1,130 +0,0 @@
|
|||
using Yavsc.Models.Haircut;
|
||||
|
||||
namespace Yavsc.Helpers
|
||||
{
|
||||
public static class HaircutHelpers
|
||||
{
|
||||
public static decimal Addition (this HairPrestation p, BrusherProfile profile)
|
||||
{
|
||||
decimal sub=0;
|
||||
// Le shampoing
|
||||
sub += p.Shampoo ? profile.ShampooPrice:0;
|
||||
|
||||
// la coupe
|
||||
sub += p.Cut ? p.Gender == HairCutGenders.Women ?
|
||||
p.Length == HairLength.Long ? profile.WomenLongCutPrice :
|
||||
p.Length == HairLength.HalfLong ? profile.WomenHalfCutPrice :
|
||||
profile.WomenShortCutPrice : p.Gender == HairCutGenders.Man ?
|
||||
profile.ManCutPrice : profile.KidCutPrice : 0;
|
||||
|
||||
// Les techniques
|
||||
switch (p.Tech) {
|
||||
case HairTechnos.Color:
|
||||
bool multicolor = p.Taints.Count>1;
|
||||
switch (p.Length) {
|
||||
case HairLength.Long:
|
||||
sub += sub += multicolor? profile.LongMultiColorPrice : profile.LongColorPrice;
|
||||
break;
|
||||
case HairLength.HalfLong: sub += multicolor? profile.HalfMultiColorPrice : profile.HalfColorPrice;
|
||||
break;
|
||||
default:
|
||||
sub += multicolor? profile.ShortMultiColorPrice : profile.ShortColorPrice;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HairTechnos.Balayage:
|
||||
switch (p.Length) {
|
||||
case HairLength.Long:
|
||||
sub += profile.LongBalayagePrice;
|
||||
break;
|
||||
case HairLength.HalfLong: sub += profile.HalfBalayagePrice;
|
||||
break;
|
||||
default:
|
||||
sub += profile.ShortBalayagePrice;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HairTechnos.Defris:
|
||||
switch (p.Length) {
|
||||
case HairLength.Long:
|
||||
sub += profile.LongDefrisPrice;
|
||||
break;
|
||||
case HairLength.HalfLong: sub += profile.HalfDefrisPrice;
|
||||
break;
|
||||
default:
|
||||
sub += profile.ShortDefrisPrice;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HairTechnos.Mech:
|
||||
switch (p.Length) {
|
||||
case HairLength.Long:
|
||||
sub += profile.LongMechPrice;
|
||||
break;
|
||||
case HairLength.HalfLong: sub += profile.HalfMechPrice;
|
||||
break;
|
||||
default:
|
||||
sub += profile.ShortMechPrice;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HairTechnos.Permanent:
|
||||
switch (p.Length) {
|
||||
case HairLength.Long:
|
||||
sub += profile.LongPermanentPrice;
|
||||
break;
|
||||
case HairLength.HalfLong: sub += profile.HalfPermanentPrice;
|
||||
break;
|
||||
default:
|
||||
sub += profile.ShortPermanentPrice;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Les coiffages
|
||||
switch (p.Dressing) {
|
||||
case HairDressings.Brushing:
|
||||
switch (p.Gender) {
|
||||
case HairCutGenders.Women:
|
||||
switch (p.Length) {
|
||||
case HairLength.Long:
|
||||
sub += profile.LongBrushingPrice;
|
||||
break;
|
||||
case HairLength.HalfLong: sub += profile.HalfBrushingPrice;
|
||||
break;
|
||||
default:
|
||||
sub += profile.ShortBrushingPrice;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HairCutGenders.Man:
|
||||
sub += profile.ManBrushPrice;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HairDressings.Coiffage:
|
||||
// est offert
|
||||
break;
|
||||
case HairDressings.Folding:
|
||||
switch (p.Length) {
|
||||
case HairLength.Long:
|
||||
sub += profile.LongFoldingPrice;
|
||||
break;
|
||||
case HairLength.HalfLong: sub += profile.HalfFoldingPrice;
|
||||
break;
|
||||
default:
|
||||
sub += profile.ShortFoldingPrice;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// les soins
|
||||
sub += p.Cares ? profile.CarePrice:0;
|
||||
return sub;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PayPal.Api;
|
||||
using Yavsc.Models.Billing;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
namespace Yavsc.Helpers
|
||||
{
|
||||
|
|
@ -18,20 +19,40 @@ namespace Yavsc.Helpers
|
|||
return apiContext;
|
||||
}
|
||||
|
||||
public static Payment CreatePaiement(this APIContext apiContext, NominativeServiceCommand query, string intent = "sale")
|
||||
public static Payment CreatePaiment(this APIContext apiContext, NominativeServiceCommand query, string intent = "sale", ILogger logger=null)
|
||||
{
|
||||
var queryType = query.GetType().Name;
|
||||
var transaction = new Transaction
|
||||
{
|
||||
description = query.Description+"\nVotre commande du "+query.DateCreated.ToLongDateString(),
|
||||
description ="Votre commande du "+query.DateCreated.ToLongDateString()+
|
||||
"\n"+query.Description,
|
||||
invoice_number = $"{query.ActivityCode}/{queryType}/{query.Id}"
|
||||
};
|
||||
transaction.item_list.shipping_address.line1 = query.Client.PostalAddress.Address;
|
||||
logger?.LogInformation("transaction: "+transaction.invoice_number);
|
||||
// transaction.item_list.shipping_address.city
|
||||
// country_code default_address id
|
||||
// line1 line2 preferred_address recipient_name state status type
|
||||
transaction.item_list = new ItemList();
|
||||
if (query.Client.PostalAddress!=null) {
|
||||
transaction.item_list.shipping_address = new ShippingAddress();
|
||||
transaction.item_list.shipping_address.line1 = query.Client.PostalAddress.Address;
|
||||
}
|
||||
transaction.item_list.shipping_phone_number = query.Client.PhoneNumber;
|
||||
transaction.item_list.items = new List<Item> { };
|
||||
var item = new Item();
|
||||
logger?.LogInformation("client address: "+transaction.item_list.shipping_address.line1);
|
||||
transaction.item_list.items = query.GetBillItems().Select(i => new Item {
|
||||
name = i.Name,
|
||||
description = i.Description,
|
||||
price = i.UnitaryCost.ToString("F2"),
|
||||
currency = "EUR",
|
||||
quantity = i.Count.ToString(),
|
||||
sku = query.ActivityCode
|
||||
/* postback_data=
|
||||
sku=
|
||||
supplementary_data= */
|
||||
}).ToList();
|
||||
|
||||
return new Payment
|
||||
|
||||
return Payment.Create(apiContext, new Payment
|
||||
{
|
||||
intent = intent, // "sale", "order", "authorize"
|
||||
payer = new Payer
|
||||
|
|
@ -39,10 +60,10 @@ namespace Yavsc.Helpers
|
|||
payment_method = "paypal"
|
||||
},
|
||||
transactions = new List<Transaction> { transaction }
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public static Payment CreatePaiement(this APIContext apiContext, Estimate estimation)
|
||||
public static Payment CreatePaiment(this APIContext apiContext, Estimate estimation)
|
||||
{
|
||||
var payment = Payment.Create(apiContext,
|
||||
new Payment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue