Добавить OrderPaymentReceipt.cs
Квитанция об оплате без процентов скидок-надбавок. Только название и сумма
This commit is contained in:
241
OrderPaymentReceipt.cs
Normal file
241
OrderPaymentReceipt.cs
Normal file
@@ -0,0 +1,241 @@
|
||||
@using System
|
||||
@using System.Collections.Generic
|
||||
@using System.Linq
|
||||
@using Resto.Front.PrintTemplates.Cheques.Razor
|
||||
@using Resto.Front.PrintTemplates.Cheques.Razor.TemplateModels
|
||||
|
||||
@inherits TemplateBase<IReceiptCheque>
|
||||
|
||||
@{
|
||||
var chequeTask = Model.ChequeTask;
|
||||
var order = Model.Order;
|
||||
|
||||
var sum = chequeTask.Sales.Sum(sale => sale.GetCost() - sale.DiscountSum + sale.IncreaseSum).RoundMoney();
|
||||
}
|
||||
|
||||
<doc>
|
||||
@if (!Model.ChequeInfo.IsForReport)
|
||||
{
|
||||
<left>
|
||||
<split>
|
||||
<whitespace-preserve>@Model.CommonInfo.CafeSetup.BillHeader</whitespace-preserve>
|
||||
</split>
|
||||
</left>
|
||||
}
|
||||
<whitespace-preserve>@Raw(string.Join(Environment.NewLine, Model.Extensions.BeforeCheque))</whitespace-preserve>
|
||||
@if (!Model.ChequeInfo.IsForReport)
|
||||
{
|
||||
<pair left="@string.Format(Resources.CashRegisterFormat, Model.ChequeInfo.Session.CashRegisterNumber)" right="@Model.CommonInfo.Group.Name" />
|
||||
<pair left="@Resources.HeadCashRegisterShift" right="@Model.ChequeInfo.Session.Number" />
|
||||
<pair left="@Resources.CurrentDate" right="@FormatLongDateTime(Model.ChequeInfo.OperationTime)" />
|
||||
}
|
||||
<center>
|
||||
@(chequeTask.IsStorno ? Resources.StornoCheque : chequeTask.IsBuy ? Resources.OrderBuyReceipt : Resources.OrderPaymentReceipt)
|
||||
</center>
|
||||
|
||||
<pair
|
||||
left="@string.Format(Resources.BillHeaderCashierPattern, chequeTask.CashierName)"
|
||||
right="@string.Format(Resources.BillHeaderOrderNumberPattern, order.Number)" />
|
||||
<left>
|
||||
@string.Format(Resources.BillHeaderWaiterPattern, order.Waiter.GetNameOrEmpty())
|
||||
</left>
|
||||
|
||||
<pair left="@string.Format(Resources.BillHeaderTablePattern, order.Table.Number)" />
|
||||
<left>
|
||||
Guest: @(order.Delivery != null ? order.Delivery.PersonCount : order.Guests.Count())
|
||||
</left>
|
||||
|
||||
@foreach (var clientInfo in
|
||||
from discountItem in order.DiscountItems
|
||||
where discountItem.CardInfo != null
|
||||
select discountItem.CardInfo into cardInfo
|
||||
select string.IsNullOrWhiteSpace(cardInfo.MaskedCard) ? cardInfo.Owner : string.Format("{0} ({1})", cardInfo.Owner, cardInfo.MaskedCard) into clientInfo
|
||||
where !string.IsNullOrWhiteSpace(clientInfo)
|
||||
select clientInfo)
|
||||
{
|
||||
<left>
|
||||
@string.Format(Resources.ClientFormat, clientInfo)
|
||||
</left>
|
||||
}
|
||||
@Sales(chequeTask)
|
||||
@if (chequeTask.ResultSum != sum)
|
||||
{
|
||||
<pair left="@Resources.BillFooterTotalPlain" right="@FormatMoney(sum)" />
|
||||
}
|
||||
@if (chequeTask.PrintNds)
|
||||
{
|
||||
@Vats(chequeTask)
|
||||
}
|
||||
<pair left="@Resources.BillFooterTotal" right="@FormatMoney(chequeTask.ResultSum)" />
|
||||
@Payments(chequeTask)
|
||||
@if (!Model.ChequeInfo.IsForReport)
|
||||
{
|
||||
<center>
|
||||
@string.Format(Resources.AllSumsInFormat, Model.CommonInfo.CafeSetup.CurrencyName)
|
||||
</center>
|
||||
<np />
|
||||
<center>
|
||||
<split>
|
||||
<whitespace-preserve>@Model.CommonInfo.CafeSetup.BillFooter</whitespace-preserve>
|
||||
</split>
|
||||
</center>
|
||||
}
|
||||
@if (!chequeTask.IsStorno)
|
||||
{
|
||||
<np />
|
||||
<line />
|
||||
<center>
|
||||
@Resources.Signature
|
||||
</center>
|
||||
}
|
||||
<whitespace-preserve>@Raw(string.Join(Environment.NewLine, Model.Extensions.AfterCheque))</whitespace-preserve>
|
||||
</doc>
|
||||
|
||||
@helper Sales(IChequeTask chequeTask)
|
||||
{
|
||||
<line />
|
||||
if (chequeTask.Sales.IsEmpty())
|
||||
{
|
||||
@Resources.ZeroChequeBody
|
||||
<line />
|
||||
}
|
||||
else if (Model.IsFullCheque)
|
||||
{
|
||||
<table>
|
||||
<columns>
|
||||
<column formatter="split" />
|
||||
<column align="right" autowidth="" />
|
||||
<column align="right" autowidth="" />
|
||||
</columns>
|
||||
<cells>
|
||||
@if (!Model.ChequeInfo.IsForReport)
|
||||
{
|
||||
<ct>@Resources.NameTitle</ct>
|
||||
<ct>@Resources.AmountWithPriceTitle</ct>
|
||||
<ct>@Resources.ProductSum</ct>
|
||||
<linecell />
|
||||
}
|
||||
@foreach (var sale in chequeTask.Sales)
|
||||
{
|
||||
<c>@sale.Name</c>
|
||||
<ct>@string.Format("{0}x{1}", FormatAmount(sale.Amount), FormatMoneyMin(sale.Price))</ct>
|
||||
<ct>@FormatMoney(sale.GetCost())</ct>
|
||||
}
|
||||
</cells>
|
||||
</table>
|
||||
<line />
|
||||
|
||||
var discountItems = chequeTask.Sales
|
||||
.Where(s => s.DiscountSum != 0m)
|
||||
.GroupBy(s => s.DiscountPercent)
|
||||
.Select(g => new {
|
||||
Name = Resources.Discount,
|
||||
Percent = g.Key,
|
||||
Sum = g.Sum(s => s.DiscountSum)
|
||||
});
|
||||
|
||||
var increaseItems = chequeTask.Sales
|
||||
.Where(s => s.IncreaseSum != 0m)
|
||||
.GroupBy(s => s.IncreasePercent)
|
||||
.Select(g => new {
|
||||
Name = Resources.Increase,
|
||||
Percent = g.Key,
|
||||
Sum = g.Sum(s => s.IncreaseSum)
|
||||
});
|
||||
|
||||
if (discountItems.Any() || increaseItems.Any())
|
||||
{
|
||||
|
||||
foreach (var item in discountItems.Concat(increaseItems))
|
||||
{
|
||||
<pair left="@string.Format(item.Name)"
|
||||
right="@FormatMoney(item.Sum)" />
|
||||
}
|
||||
|
||||
<line />
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@helper Vats(IChequeTask chequeTask)
|
||||
{
|
||||
var vats = chequeTask.Sales
|
||||
.GroupBy(sale => sale.NdsPercent)
|
||||
.Where(group => group.Key > 0m)
|
||||
.Select(group => Tuple.Create(group.Key, group.Sum(sale => (sale.ResultSum - sale.ResultSum / (1m + @group.Key / 100m)).RoundMoney())))
|
||||
.ToList();
|
||||
|
||||
var vatSum = vats.Sum(tuple => tuple.Item2);
|
||||
|
||||
if (vatSum != 0)
|
||||
{
|
||||
<pair left="@Resources.ResultSumWithoutNds" right="@FormatMoney(chequeTask.ResultSum - vatSum)" />
|
||||
foreach (var percentAndSum in vats)
|
||||
{
|
||||
<pair left="@string.Format(Resources.VatFormat, FormatPercent(percentAndSum.Item1))" right="@FormatMoney(percentAndSum.Item2)" />
|
||||
}
|
||||
if (vats.Count > 1)
|
||||
{
|
||||
<pair left="@Resources.VatSum" right="@FormatMoney(vatSum)" />
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@helper Payments(IChequeTask chequeTask)
|
||||
{
|
||||
<line />
|
||||
foreach (var prepayItem in chequeTask.Prepayments)
|
||||
{
|
||||
<pair left="@string.Format(Resources.PrepayTemplate, prepayItem.PaymentTypeName)" right="@FormatMoney(prepayItem.Sum)" />
|
||||
}
|
||||
|
||||
if (chequeTask.CashPayment != 0m || (chequeTask.CardPayments.IsEmpty() && chequeTask.AdditionalPayments.IsEmpty()))
|
||||
{
|
||||
@Payment(Resources.Cash, chequeTask.CashPayment)
|
||||
}
|
||||
foreach (var cardPaymentItem in chequeTask.CardPayments)
|
||||
{
|
||||
@Payment(string.Format(Resources.CardPattern, cardPaymentItem.PaymentTypeName), cardPaymentItem.Sum, cardPaymentItem.Comment)
|
||||
}
|
||||
foreach (var additionalPaymentItem in chequeTask.AdditionalPayments)
|
||||
{
|
||||
@Payment(additionalPaymentItem.PaymentTypeName, additionalPaymentItem.Sum, additionalPaymentItem.Comment)
|
||||
}
|
||||
|
||||
var orderPaymentsSumWithoutPrepay = chequeTask.CashPayment + chequeTask.CardPayments.Sum(p => p.Sum) + chequeTask.AdditionalPayments.Sum(p => p.Sum);
|
||||
var orderPaymentsSumWithPrepay = orderPaymentsSumWithoutPrepay + SetSign(chequeTask.Prepayments.Sum(p => p.Sum));
|
||||
var changeSum = Math.Max(orderPaymentsSumWithPrepay - chequeTask.ResultSum, 0m);
|
||||
|
||||
var hasMultiplePayments = ((chequeTask.CashPayment != 0m ? 1 : 0) +
|
||||
chequeTask.CardPayments.Count() +
|
||||
chequeTask.AdditionalPayments.Count() +
|
||||
chequeTask.Prepayments.Count()) > 1;
|
||||
|
||||
if (hasMultiplePayments)
|
||||
{
|
||||
<pair left="@Resources.Total" right="@FormatMoney(SetSign(orderPaymentsSumWithoutPrepay))" />
|
||||
}
|
||||
if (changeSum > 0m)
|
||||
{
|
||||
<pair left="@Resources.Change" right="@FormatMoney(changeSum)" />
|
||||
}
|
||||
}
|
||||
|
||||
@helper Payment(string name, decimal sum, string comment = null)
|
||||
{
|
||||
<pair left="@name" right="@FormatMoney(SetSign(sum))" />
|
||||
if (!string.IsNullOrWhiteSpace(comment))
|
||||
{
|
||||
<left>
|
||||
@comment
|
||||
</left>
|
||||
}
|
||||
}
|
||||
|
||||
@functions
|
||||
{
|
||||
private decimal SetSign(decimal sum)
|
||||
{
|
||||
return Model.ChequeTask.IsStorno ? -sum : sum;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user