本文整理汇总了C#中Samba.Domain.Models.Tickets.Ticket.GetDiscountAndRoundingTotal方法的典型用法代码示例。如果您正苦于以下问题:C# Ticket.GetDiscountAndRoundingTotal方法的具体用法?C# Ticket.GetDiscountAndRoundingTotal怎么用?C# Ticket.GetDiscountAndRoundingTotal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Samba.Domain.Models.Tickets.Ticket
的用法示例。
在下文中一共展示了Ticket.GetDiscountAndRoundingTotal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateTicketItemTotal
public static decimal CalculateTicketItemTotal(Ticket ticket, TicketItem ticketItem)
{
var discount = ticket.GetDiscountAndRoundingTotal();
if (discount != 0)
{
var tsum = ticket.GetSumWithoutTax() + discount;
var rate = tsum > 0 ? (discount * 100) / tsum : 100;
var tiTotal = ticketItem.GetTotal();
var itemDiscount = (tiTotal * rate) / 100;
return tiTotal - itemDiscount;
}
return ticketItem.GetTotal();
}
示例2: RecalculateTicket
public static void RecalculateTicket(Ticket ticket)
{
var total = ticket.TotalAmount;
AppServices.MainDataContext.Recalculate(ticket);
if (total != ticket.TotalAmount)
{
RuleExecutor.NotifyEvent(RuleEventNames.TicketTotalChanged,
new
{
Ticket = ticket,
PreviousTotal = total,
TicketTotal = ticket.GetSum(),
DiscountTotal = ticket.GetDiscountAndRoundingTotal(),
GiftTotal = ticket.GetTotalGiftAmount(),
PaymentTotal = ticket.GetPaymentAmount(),
ticket.CustomerName,
ticket.CustomerId,
ticket.CustomerGroupCode
});
}
}
示例3: GroupLinesByValue
private static IEnumerable<TicketItem> GroupLinesByValue(Ticket ticket, Func<MenuItem, object> selector, string defaultValue, bool calcDiscounts = false)
{
var discounts = calcDiscounts ? ticket.GetDiscountAndRoundingTotal() : 0;
var di = discounts > 0 ? discounts / ticket.GetPlainSum() : 0;
var cache = new Dictionary<string, decimal>();
foreach (var ticketItem in ticket.TicketItems.OrderBy(x => x.Id).ToList())
{
var item = ticketItem;
var value = selector(AppServices.DataAccessService.GetMenuItem(item.MenuItemId)).ToString();
if (string.IsNullOrEmpty(value)) value = defaultValue;
if (!cache.ContainsKey(value))
cache.Add(value, 0);
var total = (item.GetTotal());
cache[value] += Decimal.Round(total - (total * di), 2);
}
return cache.Select(x => new TicketItem
{
MenuItemName = x.Key,
Price = x.Value,
Quantity = 1,
PortionCount = 1,
CurrencyCode = LocalSettings.CurrencySymbol
});
}
示例4: CanAddTicketDiscounts
public void CanAddTicketDiscounts()
{
var mi = new MenuItem("Elma");
mi.AddPortion("Test", 10, "TL");
var mi2 = new MenuItem("Armut");
mi2.AddPortion("Test", 15, "TL");
var ticket = new Ticket();
ticket.AddTicketItem(0, mi, "Test");
ticket.AddTicketItem(0, mi2, "Test");
Assert.IsTrue(ticket.GetSum() == 25);
ticket.AddTicketDiscount(DiscountType.Percent, 10, 0);
Assert.IsTrue(ticket.GetSum() == 22.5m);
ticket.AddTicketDiscount(DiscountType.Percent, 20, 0);
Assert.IsTrue(ticket.GetSum() == 20.0m);
ticket.AddTicketDiscount(DiscountType.Amount, 10, 0);
Assert.IsTrue(ticket.GetSum() == 10);
Assert.IsTrue(ticket.GetDiscountAndRoundingTotal() == 15);
ticket.AddTicketDiscount(DiscountType.Amount, 5, 0);
Assert.IsTrue(ticket.GetSum() == 15);
Assert.IsTrue(ticket.GetDiscountAndRoundingTotal() == 10);
ticket.AddTicketDiscount(DiscountType.Percent, 0, 0);
ticket.AddTicketDiscount(DiscountType.Amount, 0, 0);
Assert.IsTrue(ticket.GetSum() == 25);
Assert.IsTrue(ticket.GetDiscountAndRoundingTotal() == 0);
Assert.IsTrue(ticket.Discounts.Count == 0);
ticket.AddTicketDiscount(DiscountType.Percent, 50, 0);
Assert.IsTrue(ticket.GetSum() == 12.5m);
Assert.IsTrue(ticket.Discounts.Count == 1);
ticket.AddTicketDiscount(DiscountType.Percent, 0, 0);
Assert.IsTrue(ticket.Discounts.Count == 0);
Assert.IsTrue(ticket.GetSum() == 25);
ticket.TicketItems[0].Gifted = true;
Assert.IsTrue(ticket.GetSum() == 15);
ticket.AddTicketDiscount(DiscountType.Percent, 10, 0);
Assert.IsTrue(ticket.GetSum() == 13.5m);
Assert.IsTrue(ticket.GetDiscountAndRoundingTotal() == 1.5m);
ticket.TicketItems[0].Voided = true;
Assert.IsTrue(ticket.GetSum() == 13.5m);
ticket.AddTicketDiscount(DiscountType.Percent, 10, 0);
Assert.AreEqual(13.5m, ticket.GetSum());
Assert.AreEqual(1.5m, ticket.GetDiscountAndRoundingTotal());
ticket.AddTicketDiscount(DiscountType.Amount, 0.5m, 0);
Assert.AreEqual(13m, ticket.GetSum());
ticket.Discounts.Clear();
Assert.AreEqual(15m, ticket.GetSum());
var t = new VatTemplate { Rate = 10 };
var mix = new MenuItem("TestItem2") { VatTemplate = t };
mix.AddPortion("Adet", 10, "TL");
ticket.AddTicketItem(0, mix, "Adet");
Assert.AreEqual(26m, ticket.GetSum());
ticket.AddTicketDiscount(DiscountType.Percent, 10, 0);
Assert.AreEqual(23.4m, ticket.GetSum());
ticket.AddTicketDiscount(DiscountType.Amount, 0.4m, 0);
Assert.AreEqual(23m, ticket.GetSum());
}
示例5: ReplaceDocumentVars
private static string ReplaceDocumentVars(string document, Ticket ticket, int orderNo, int userNo, int departmentNo)
{
string result = document;
if (string.IsNullOrEmpty(document)) return "";
result = FormatData(result, Resources.TF_TicketDate, () => ticket.Date.ToShortDateString());
result = FormatData(result, Resources.TF_TicketTime, () => ticket.Date.ToShortTimeString());
result = FormatData(result, Resources.TF_DayDate, () => DateTime.Now.ToShortDateString());
result = FormatData(result, Resources.TF_DayTime, () => DateTime.Now.ToShortTimeString());
result = FormatData(result, Resources.TF_UniqueTicketId, () => ticket.Id.ToString());
result = FormatData(result, Resources.TF_TicketNumber, () => ticket.TicketNumber);
result = FormatData(result, Resources.TF_LineOrderNumber, orderNo.ToString);
result = FormatData(result, Resources.TF_TicketTag, ticket.GetTagData);
result = FormatDataIf(true, result, "{DEPARTMENT}", () => GetDepartmentName(departmentNo));
var ticketTagPattern = Resources.TF_OptionalTicketTag + "[^}]+}";
while (Regex.IsMatch(result, ticketTagPattern))
{
var value = Regex.Match(result, ticketTagPattern).Groups[0].Value;
var tags = "";
try
{
var tag = value.Trim('{', '}').Split(':')[1];
tags = tag.Split(',').Aggregate(tags, (current, t) => current +
(!string.IsNullOrEmpty(ticket.GetTagValue(t.Trim()))
? (t + ": " + ticket.GetTagValue(t.Trim()) + "\r")
: ""));
result = FormatData(result.Trim('\r'), value, () => tags);
}
catch (Exception)
{
result = FormatData(result, value, () => "");
}
}
const string ticketTag2Pattern = "{TICKETTAG:[^}]+}";
while (Regex.IsMatch(result, ticketTag2Pattern))
{
var value = Regex.Match(result, ticketTag2Pattern).Groups[0].Value;
var tag = value.Trim('{', '}').Split(':')[1];
var tagValue = ticket.GetTagValue(tag);
try
{
result = FormatData(result, value, () => tagValue);
}
catch (Exception)
{
result = FormatData(result, value, () => "");
}
}
var userName = AppServices.MainDataContext.GetUserName(userNo);
var title = ticket.LocationName;
if (string.IsNullOrEmpty(ticket.LocationName))
title = userName;
result = FormatData(result, Resources.TF_TableOrUserName, () => title);
result = FormatData(result, Resources.TF_UserName, () => userName);
result = FormatData(result, Resources.TF_TableName, () => ticket.LocationName);
result = FormatData(result, Resources.TF_TicketNote, () => ticket.Note ?? "");
result = FormatData(result, Resources.TF_AccountName, () => ticket.CustomerName);
result = FormatData(result, "{ACC GROUPCODE}", () => ticket.CustomerGroupCode);
if (ticket.CustomerId > 0 && (result.Contains(Resources.TF_AccountAddress) || result.Contains(Resources.TF_AccountPhone) || result.Contains("{ACC NOTE}")))
{
var customer = Dao.SingleWithCache<Customer>(x => x.Id == ticket.CustomerId);
result = FormatData(result, Resources.TF_AccountAddress, () => customer.Address);
result = FormatData(result, Resources.TF_AccountPhone, () => customer.PhoneNumber);
result = FormatData(result, "{ACC NOTE}", () => customer.Note);
}
if (ticket.CustomerId > 0 && result.Contains("{ACC BALANCE}"))
{
var accBalance = CashService.GetAccountBalance(ticket.CustomerId);
result = FormatDataIf(accBalance != 0, result, "{ACC BALANCE}", () => accBalance.ToString("#,#0.00"));
}
result = RemoveTag(result, Resources.TF_AccountAddress);
result = RemoveTag(result, Resources.TF_AccountPhone);
var payment = ticket.GetPaymentAmount();
var remaining = ticket.GetRemainingAmount();
var discount = ticket.GetDiscountAndRoundingTotal();
var plainTotal = ticket.GetPlainSum();
var giftAmount = ticket.GetTotalGiftAmount();
var vatAmount = GetTaxTotal(ticket.TicketItems, plainTotal, ticket.GetDiscountTotal());
var taxServicesTotal = ticket.GetTaxServicesTotal();
var ticketPaymentAmount = ticket.GetPaymentAmount();
result = FormatDataIf(vatAmount > 0 || discount > 0 || taxServicesTotal > 0, result, "{PLAIN TOTAL}", () => plainTotal.ToString("#,#0.00"));
result = FormatDataIf(discount > 0, result, "{DISCOUNT TOTAL}", () => discount.ToString("#,#0.00"));
result = FormatDataIf(vatAmount > 0, result, "{TAX TOTAL}", () => vatAmount.ToString("#,#0.00"));
result = FormatDataIf(taxServicesTotal > 0, result, "{SERVICE TOTAL}", () => taxServicesTotal.ToString("#,#0.00"));
result = FormatDataIf(vatAmount > 0, result, "{TAX DETAILS}", () => GetTaxDetails(ticket.TicketItems, plainTotal, discount));
result = FormatDataIf(taxServicesTotal > 0, result, "{SERVICE DETAILS}", () => GetServiceDetails(ticket));
result = FormatDataIf(payment > 0, result, Resources.TF_RemainingAmountIfPaid,
//.........这里部分代码省略.........