Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.24 KB | None | 0 0
  1. @using System
  2. @using System.Collections.Generic
  3. @using System.Linq
  4. @using Resto.Front.PrintTemplates.Cheques.Razor
  5. @using Resto.Front.PrintTemplates.Cheques.Razor.TemplateModels
  6.  
  7. @inherits TemplateBase<IBillCheque>
  8.  
  9. @{
  10. var order = Model.Order;
  11. }
  12.  
  13. <doc>
  14. @* Header (begin) *@
  15. <whitespace-preserve>@Raw(string.Join(Environment.NewLine, Model.Extensions.BeforeHeader))</whitespace-preserve>
  16.  
  17. <center>
  18. <line symbols="*" />
  19. <split><whitespace-preserve>- = @Model.CommonInfo.Group.Name = -</whitespace-preserve></split><np />
  20. <line symbols="*" />
  21. </center>
  22.  
  23. @if (@Model.CommonInfo.Group.Name == "ДАЧА") {
  24. <center>
  25. Реквизиты ДАЧА
  26. </center>
  27. } else {
  28. <center>
  29. Реквизиты Спартак
  30. </center><np />
  31. <line symbols="*" />
  32. }
  33.  
  34.  
  35. @if (Model.AdditionalServiceChequeInfo == null)
  36. {
  37. <center>
  38. @Resources.BillHeaderTitle
  39. </center>
  40. }
  41. <pair fit="right"
  42. left="@string.Format(Resources.BillHeaderWaiterPattern, order.Waiter.GetNameOrEmpty())"
  43. right="@string.Format(Resources.BillHeaderTablePattern, order.Table.Number)" />
  44.  
  45. <pair fit="right"
  46. left="@string.Format(Resources.BillHeaderOrderOpenPattern, FormatLongDateTime(order.OpenTime))"
  47. right="@string.Format(Resources.BillHeaderOrderNumberPattern, order.Number)" />
  48.  
  49. <pair fit="right"
  50. left='@string.Format("Пречек: {0}", FormatLongDateTime(Model.CommonInfo.CurrentTime))'
  51. right="@string.Format(Resources.BillHeaderSectionPattern, order.Table.Section.Name)" />
  52.  
  53. @if (Model.AdditionalServiceChequeInfo != null)
  54. {
  55. <left>
  56. @string.Format(Resources.AdditionalServiceHeaderOrderItemsAddedPattern, FormatLongDateTime(Model.CommonInfo.CurrentTime))
  57. </left>
  58. }
  59.  
  60. @foreach (var clientInfo in
  61. from discountItem in order.DiscountItems
  62. where discountItem.CardInfo != null
  63. select discountItem.CardInfo into cardInfo
  64. select string.IsNullOrWhiteSpace(cardInfo.MaskedCard) ? cardInfo.Owner : string.Format("{0} ({1})", cardInfo.Owner, cardInfo.MaskedCard) into clientInfo
  65. where !string.IsNullOrWhiteSpace(clientInfo)
  66. select clientInfo)
  67. {
  68. <left>
  69. @string.Format(Resources.ClientFormat, clientInfo)
  70. </left>
  71. }
  72. <whitespace-preserve>@Raw(string.Join(Environment.NewLine, Model.Extensions.AfterHeader))</whitespace-preserve>
  73. @if (Model.AdditionalServiceChequeInfo != null)
  74. {
  75. if (order.ClientBinding != null && !string.IsNullOrWhiteSpace(order.ClientBinding.CardNumber))
  76. {
  77. <left>
  78. @string.Format(Resources.CardPattern, order.ClientBinding.CardNumber)
  79. </left>
  80. }
  81. <np />
  82. <center>
  83. @Resources.AdditionalServiceHeaderTitle
  84. </center>
  85. }
  86. @* Header (end) *@
  87.  
  88. @* Body (begin) *@
  89. <table>
  90. <columns>
  91. <column formatter="split"/>
  92. <column align="right" autowidth="" />
  93. <column width="0" />
  94. <column align="right" autowidth="" />
  95. </columns>
  96. <cells>
  97. @Guests()
  98.  
  99. <linecell />
  100.  
  101. @Summaries()
  102.  
  103. </cells>
  104. </table>
  105. @* Body (end) *@
  106.  
  107. @* Footer (begin) *@
  108. <np />
  109. <whitespace-preserve>@Raw(string.Join(Environment.NewLine, Model.Extensions.BeforeFooter))</whitespace-preserve>
  110. <center>
  111. <split>
  112. <whitespace-preserve>@Model.CommonInfo.CafeSetup.BillFooter</whitespace-preserve>
  113. </split>
  114. </center>
  115. <np />
  116. <np />
  117. <whitespace-preserve>@Raw(string.Join(Environment.NewLine, Model.Extensions.AfterFooter))</whitespace-preserve>
  118. <np />
  119. @* Footer (end) *@
  120. </doc>
  121.  
  122. @helper Guests()
  123. {
  124. var order = Model.Order;
  125. Func<IOrderItem, bool> orderItemsFilter;
  126. if (Model.AdditionalServiceChequeInfo != null)
  127. {
  128. orderItemsFilter = orderItem => Model.AdditionalServiceChequeInfo.AddedOrderItems.Contains(orderItem);
  129. }
  130. else
  131. {
  132. orderItemsFilter = orderItem => orderItem.DeletionInfo == null;
  133. }
  134.  
  135. var guestsWithItems = Model.Order.Table.Section.DisplayGuests
  136. ? order.Guests
  137. .Select(guest => new { Guest = guest, Items = guest.Items.Where(item => orderItemsFilter(item) && OrderItemsToPrintFilter(item, order.DiscountItems)) })
  138. .Where(guestWithItems => guestWithItems.Items.Any())
  139. .ToList()
  140. : Enumerable.Repeat(new { Guest = order.Guests.FirstOrDefault(), Items = order.Guests.SelectMany(g => g.Items.Where(item => orderItemsFilter(item) && OrderItemsToPrintFilter(item, order.DiscountItems))) }, 1)
  141. .Where(guestWithItems => guestWithItems.Items.Any())
  142. .ToList();
  143.  
  144. if (!guestsWithItems.Any())
  145. {
  146. return;
  147. }
  148.  
  149. <linecell />
  150. <ct>
  151. @Resources.NameColumnHeader
  152. </ct>
  153. <ct>
  154. @Resources.ProductAmount
  155. </ct>
  156. <ct />
  157. <ct>
  158. @Resources.ResultSum
  159. </ct>
  160. <linecell />
  161.  
  162. if (guestsWithItems.Count == 1)
  163. {
  164. @SingleGuest(guestsWithItems.Single().Items)
  165. }
  166. else
  167. {
  168. @OneOfMultipleGuests(guestsWithItems.First().Guest, guestsWithItems.First().Items)
  169.  
  170. foreach (var guestWithItems in guestsWithItems.Skip(1))
  171. {
  172. <linecell symbols=" " />
  173. @OneOfMultipleGuests(guestWithItems.Guest, guestWithItems.Items)
  174. }
  175. }
  176. }
  177.  
  178. @helper SingleGuest(IEnumerable<IOrderItem> items)
  179. {
  180. foreach (var orderItemGroup in items.GroupBy(_ => _, CreateComparer<IOrderItem>(AreOrderItemsEqual)))
  181. {
  182. <ct>
  183. @orderItemGroup.Key.Product.Name
  184. </ct>
  185. <ct>
  186. <center>@string.Format("{0:#,0.0##}", orderItemGroup.Sum(orderItem => orderItem.Amount))</center>
  187. </ct>
  188. <ct />
  189. <ct>
  190. @FormatMoney(orderItemGroup.Sum(orderItem => orderItem.GetCost()))
  191. </ct>
  192.  
  193. @CategorizedDiscountsForOrderEntryGroup(orderItemGroup)
  194.  
  195. if (Model.Order.Table.Section.PrintProductItemCommentInCheque && orderItemGroup.Key is IProductItem)
  196. {
  197. var productItem = (IProductItem)orderItemGroup.Key;
  198. if (productItem.Comment != null && !productItem.Comment.Deleted)
  199. {
  200. <c>
  201. <table cellspacing="0">
  202. <columns>
  203. <column width="2" />
  204. <column />
  205. </columns>
  206. <cells>
  207. <c />
  208. <c>
  209. <split>
  210. - @productItem.Comment.Text
  211. </split>
  212. </c>
  213. </cells>
  214. </table>
  215. </c>
  216. <c colspan="3" />
  217. }
  218. }
  219.  
  220. foreach (var orderEntry in orderItemGroup.Key.GetNotDeletedChildren().Where(orderEntry => OrderItemChildrenFilter(orderEntry, orderItemGroup.Key)))
  221. {
  222. <ct>
  223. <whitespace-preserve>@(" - " + orderEntry.Product.Name)</whitespace-preserve>
  224. </ct>
  225.  
  226. if (orderEntry.Amount != 1m)
  227. {
  228. <ct>
  229. <center>@string.Format("{0:#,0.0##}", orderEntry.Amount)</center>
  230. </ct>
  231. }
  232. else
  233. {
  234. <ct />
  235. }
  236.  
  237. <ct />
  238.  
  239. if (orderEntry.Price != 0m)
  240. {
  241. <ct>
  242. @FormatMoney(orderEntry.GetCost())
  243. </ct>
  244. }
  245. else
  246. {
  247. <ct />
  248. }
  249.  
  250. @CategorizedDiscountsForOrderEntryGroup(EnumerableEx.Return(orderEntry))
  251. }
  252. }
  253. }
  254.  
  255. @helper CategorizedDiscountsForOrderEntryGroup(IEnumerable<IOrderEntry> entries)
  256. {
  257. var orderEntry = entries.First();
  258. if (orderEntry.Price != 0m)
  259. {
  260. var categorizedDiscounts =
  261. from discountItem in Model.Order.DiscountItems
  262. where discountItem.IsCategorized &&
  263. discountItem.PrintDetailedInPrecheque
  264. let discountSum = entries.Sum(entry => discountItem.GetDiscountSumFor(entry))
  265. where discountSum != 0m
  266. select new
  267. {
  268. IsDiscount = discountSum > 0m,
  269. Sum = Math.Abs(discountSum),
  270. Percent = Math.Abs(CalculatePercent(entries.Sum(entry => entry.GetCost()), discountSum)),
  271. Name = discountItem.Type.PrintableName,
  272. DiscountBySum = discountItem.Type.DiscountBySum
  273. } into discount
  274. orderby discount.IsDiscount descending
  275. select discount;
  276.  
  277. foreach (var categorizedDiscount in categorizedDiscounts)
  278. {
  279. <c colspan="3">
  280. <whitespace-preserve>@GetFormattedDiscountDescriptionForOrderItem(categorizedDiscount.IsDiscount, categorizedDiscount.Name, categorizedDiscount.DiscountBySum, categorizedDiscount.Percent)</whitespace-preserve>
  281. </c>
  282. <ct>
  283. @GetFormattedDiscountSum(categorizedDiscount.IsDiscount, categorizedDiscount.Sum)
  284. </ct>
  285. }
  286. }
  287. }
  288.  
  289. @helper OneOfMultipleGuests(IGuest guest, IEnumerable<IOrderItem> items)
  290. {
  291. <c colspan="0">
  292. @guest.Name
  293. </c>
  294. @SingleGuest(items)
  295.  
  296. <c colspan="3" />
  297. <c>
  298. <line />
  299. </c>
  300.  
  301. var includedEntries = items.SelectMany(item => item.ExpandIncludedEntries()).ToList();
  302.  
  303. var total = includedEntries.Sum(orderEntry => orderEntry.GetCost());
  304. var totalWithoutCategorizedDiscounts = total -
  305. (from orderEntry in includedEntries
  306. from discountItem in Model.Order.DiscountItems
  307. where discountItem.IsCategorized
  308. select discountItem.GetDiscountSumFor(orderEntry)).Sum();
  309. var totalWithoutDiscounts = totalWithoutCategorizedDiscounts -
  310. (from orderEntry in includedEntries
  311. from discountItem in Model.Order.DiscountItems
  312. where !discountItem.IsCategorized
  313. select discountItem.GetDiscountSumFor(orderEntry)).Sum();
  314.  
  315. if (totalWithoutCategorizedDiscounts != totalWithoutDiscounts)
  316. {
  317. <c colspan="3">
  318. @Resources.BillFooterTotalPlain
  319. </c>
  320. <ct>
  321. @FormatMoney(totalWithoutCategorizedDiscounts)
  322. </ct>
  323.  
  324. var nonCategorizedDiscounts =
  325. from discountItem in Model.Order.DiscountItems
  326. where !discountItem.IsCategorized
  327. let discountSum = includedEntries.Sum(orderEntry => discountItem.GetDiscountSumFor(orderEntry))
  328. select new
  329. {
  330. IsDiscount = discountSum > 0m,
  331. Sum = Math.Abs(discountSum),
  332. Percent = Math.Abs(CalculatePercent(includedEntries.Sum(entry => entry.GetCost()), discountSum)),
  333. Name = discountItem.Type.PrintableName,
  334. DiscountBySum = discountItem.Type.DiscountBySum
  335. } into discount
  336. orderby discount.IsDiscount descending
  337. select discount;
  338.  
  339. foreach (var nonCategorizedDiscount in nonCategorizedDiscounts)
  340. {
  341. <c colspan="3">
  342. @(nonCategorizedDiscount.DiscountBySum
  343. ? GetFormattedDiscountDescriptionShort(nonCategorizedDiscount.IsDiscount, nonCategorizedDiscount.Name)
  344. : GetFormattedDiscountDescriptionDetailed(nonCategorizedDiscount.IsDiscount, nonCategorizedDiscount.Name, nonCategorizedDiscount.Percent))
  345. </c>
  346. <ct>
  347. @GetFormattedDiscountSum(nonCategorizedDiscount.IsDiscount, nonCategorizedDiscount.Sum)
  348. </ct>
  349. }
  350. }
  351.  
  352. <c colspan="3">
  353. @string.Format(Model.AdditionalServiceChequeInfo == null ? Resources.BillFooterTotalGuestPattern : Resources.AdditionalServiceFooterTotalGuestPattern, guest.Name)
  354. </c>
  355. <ct>
  356. @FormatMoney(totalWithoutDiscounts)
  357. </ct>
  358. }
  359.  
  360. @helper Summaries()
  361. {
  362. var order = Model.Order;
  363.  
  364. var fullSum =
  365. order.GetFullSum() -
  366. order.DiscountItems.Where(di => !di.Type.PrintProductItemInPrecheque).Sum(di => di.GetDiscountSum());
  367.  
  368. var categorizedDiscountItems = new List<IDiscountItem>();
  369. var nonCategorizedDiscountItems = new List<IDiscountItem>();
  370. foreach (var discountItem in order.DiscountItems.Where(di => di.Type.PrintProductItemInPrecheque && di.DiscountSums.Count > 0))
  371. {
  372. if (discountItem.IsCategorized)
  373. {
  374. categorizedDiscountItems.Add(discountItem);
  375. }
  376. else
  377. {
  378. nonCategorizedDiscountItems.Add(discountItem);
  379. }
  380. }
  381.  
  382. var subTotal = fullSum - categorizedDiscountItems.Sum(di => di.GetDiscountSum());
  383.  
  384. var totalWithoutDiscounts = subTotal - nonCategorizedDiscountItems.Sum(di => di.GetDiscountSum());
  385.  
  386. var prepay = order.PrePayments.Sum(prepayItem => prepayItem.Sum);
  387.  
  388. var total = Math.Max(totalWithoutDiscounts + order.GetVatSumExcludedFromPrice() - prepay, 0m);
  389.  
  390. if (Model.DiscountMarketingCampaigns != null)
  391. {
  392. total -= Model.DiscountMarketingCampaigns.TotalDiscount;
  393. totalWithoutDiscounts -= Model.DiscountMarketingCampaigns.TotalDiscount;
  394. }
  395.  
  396. var vatSumsByVat =
  397. (Model.AdditionalServiceChequeInfo == null
  398. ? order.GetIncludedEntries()
  399. : Model.AdditionalServiceChequeInfo.AddedOrderItems.SelectMany(item => item.ExpandIncludedEntries()))
  400. .Where(orderEntry => !orderEntry.VatIncludedInPrice)
  401. .GroupBy(orderEntry => orderEntry.Vat)
  402. .Where(group => group.Key != 0m)
  403. .Select(group => new { Vat = group.Key, Sum = group.Sum(orderEntry => orderEntry.GetVatSumExcludedFromPriceForOrderEntry(order.DiscountItems)) })
  404. .ToList();
  405.  
  406. var vatSum = vatSumsByVat.Sum(vatWithSum => vatWithSum.Sum);
  407.  
  408.  
  409. <c colspan="4">
  410. <f2>
  411. @(Model.AdditionalServiceChequeInfo == null ? Resources.BillFooterTotal : Resources.AdditionalServiceFooterTotalUpper)
  412. </f2>
  413. </c>
  414. <c colspan="4">
  415. <f2>
  416. <right>@FormatMoney(total)</right>
  417. </f2>
  418. </c>
  419.  
  420.  
  421.  
  422. if ((prepay != 0m || fullSum != total) && Model.AdditionalServiceChequeInfo == null)
  423. {
  424. <c colspan="3">
  425. @Resources.BillFooterFullSum
  426. </c>
  427. <ct>
  428. @FormatMoney(fullSum)
  429. </ct>
  430. }
  431.  
  432.  
  433. @PrintOrderDiscounts(categorizedDiscountItems, fullSum)
  434.  
  435. if (categorizedDiscountItems.Any())
  436. {
  437. <c colspan="3">
  438. @Resources.BillFooterTotalPlain
  439. </c>
  440. <ct>
  441. @FormatMoney(subTotal)
  442. </ct>
  443. }
  444.  
  445. @PrintOrderDiscounts(nonCategorizedDiscountItems, fullSum)
  446.  
  447. if (Model.DiscountMarketingCampaigns != null)
  448. {
  449. foreach (var discountMarketingCampaign in Model.DiscountMarketingCampaigns.Campaigns)
  450. {
  451. <c colspan="3">
  452. @discountMarketingCampaign.Name
  453. </c>
  454. <ct>
  455. @("-" + FormatMoney(discountMarketingCampaign.TotalDiscount))
  456. </ct>
  457. }
  458. }
  459.  
  460. if (prepay != 0m && (categorizedDiscountItems.Any() || nonCategorizedDiscountItems.Any()))
  461. {
  462. <c colspan="3">
  463. @Resources.BillFooterTotalWithoutDiscounts
  464. </c>
  465. <ct>
  466. @FormatMoney(totalWithoutDiscounts)
  467. </ct>
  468. }
  469.  
  470. if (vatSum != 0m)
  471. {
  472. foreach (var vatWithSum in vatSumsByVat)
  473. {
  474. <c colspan="3">
  475. @string.Format(Resources.VatFormat, vatWithSum.Vat)
  476. </c>
  477. <ct>
  478. @string.Format(FormatMoney(vatWithSum.Sum))
  479. </ct>
  480. }
  481. if (vatSumsByVat.Count > 1)
  482. {
  483. <c colspan="3">
  484. @Resources.VatSum
  485. </c>
  486. <ct>
  487. @FormatMoney(vatSum)
  488. </ct>
  489. }
  490. }
  491.  
  492. if (Model.AdditionalServiceChequeInfo != null)
  493. {
  494. <c colspan="3">
  495. @Resources.AdditionalServiceAddedFooterTotalUpper
  496. </c>
  497. <ct>
  498. @FormatMoney(Model.AdditionalServiceChequeInfo.AddedOrderItems
  499. .SelectMany(item => item.ExpandIncludedEntries())
  500. .Sum(orderEntry => orderEntry.GetCost()) + vatSum)
  501. </ct>
  502. }
  503.  
  504. if (prepay != 0m)
  505. {
  506. <c colspan="3">
  507. @Resources.Prepay
  508. </c>
  509. <ct>
  510. @FormatMoney(prepay)
  511. </ct>
  512. }
  513.  
  514.  
  515.  
  516. if (Model.AdditionalServiceChequeInfo != null &&
  517. order.ClientBinding != null &&
  518. order.ClientBinding.PaymentLimit.HasValue)
  519. {
  520. <c colspan="3">
  521. @Resources.AdditionalServiceLimit
  522. </c>
  523. <ct>
  524. @FormatMoney(order.ClientBinding.PaymentLimit.Value - total)
  525. </ct>
  526. }
  527.  
  528. if (Model.DiscountMarketingCampaigns != null)
  529. {
  530. foreach (var discountMarketingCampaign in Model.DiscountMarketingCampaigns.Campaigns.Where(campaign => !string.IsNullOrWhiteSpace(campaign.BillComment)))
  531. {
  532. <c colspan="4">
  533. @discountMarketingCampaign.BillComment
  534. </c>
  535. }
  536. }
  537. }
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545. @helper PrintOrderDiscounts(IEnumerable<IDiscountItem> discountItems, decimal fullSum)
  546. {
  547. foreach (var discountItem in discountItems.OrderByDescending(discountItem => discountItem.IsDiscount()))
  548. {
  549. <c colspan="3">
  550. @((!discountItem.IsCategorized || discountItem.PrintDetailedInPrecheque) && !discountItem.Type.DiscountBySum
  551. ? GetFormattedDiscountDescriptionDetailed(discountItem.IsDiscount(), discountItem.Type.PrintableName, Math.Abs(CalculatePercent(fullSum, discountItem.GetDiscountSum())))
  552. : GetFormattedDiscountDescriptionShort(discountItem.IsDiscount(), discountItem.Type.PrintableName))
  553. </c>
  554. <ct>
  555. @GetFormattedDiscountSum(discountItem.IsDiscount(), Math.Abs(discountItem.GetDiscountSum()))
  556. </ct>
  557. }
  558. }
  559.  
  560. @functions
  561. {
  562. private static bool OrderItemsToPrintFilter(IOrderItem orderItem, IEnumerable<IDiscountItem> discountItems)
  563. {
  564. return !(orderItem is IProductItem) || discountItems
  565. .Where(discountItem => discountItem.DiscountSums.ContainsKey(orderItem))
  566. .All(discountItem => discountItem.Type.PrintProductItemInPrecheque);
  567. }
  568.  
  569. private bool AreOrderItemsEqual(IOrderItem x, IOrderItem y)
  570. {
  571. if (ReferenceEquals(x, y))
  572. return true;
  573.  
  574. if (x == null)
  575. return y == null;
  576. if (y == null)
  577. return false;
  578.  
  579. var xProductItem = x as IProductItem;
  580. var yProductItem = y as IProductItem;
  581.  
  582. if (xProductItem == null || yProductItem == null || !ProductItemCanBeMerged(xProductItem) || !ProductItemCanBeMerged(yProductItem))
  583. return false;
  584.  
  585. if (xProductItem.Product.Name != yProductItem.Product.Name)
  586. return false;
  587.  
  588. if (xProductItem.Price != yProductItem.Price)
  589. return false;
  590.  
  591. if (xProductItem.Price == 0m)
  592. return true;
  593.  
  594.  
  595. var categorizedDiscounts = Model.Order.DiscountItems
  596. .Where(discountItem => discountItem.IsCategorized &&
  597. discountItem.PrintDetailedInPrecheque &&
  598. discountItem.DiscountSums.Count > 0)
  599. .ToList();
  600.  
  601. var xCategorizedDiscountItems = categorizedDiscounts
  602. .Where(discountItem => discountItem.DiscountSums.ContainsKey(x));
  603.  
  604. var yCategorizedDiscountItems = categorizedDiscounts
  605. .Where(discountItem => discountItem.DiscountSums.ContainsKey(y));
  606.  
  607. return new HashSet<IDiscountItem>(xCategorizedDiscountItems).SetEquals(yCategorizedDiscountItems);
  608. }
  609.  
  610. private bool ProductItemCanBeMerged(IProductItem productItem)
  611. {
  612. return
  613. productItem.Amount - Math.Truncate(productItem.Amount) == 0m &&
  614. productItem.GetNotDeletedChildren().Where(orderEntry => OrderItemChildrenFilter(orderEntry, productItem)).IsEmpty() &&
  615. (productItem.Comment == null || productItem.Comment.Deleted || !Model.Order.Table.Section.PrintProductItemCommentInCheque);
  616. }
  617.  
  618. private static bool OrderItemChildrenFilter(IOrderEntry orderEntry, IOrderItem parent)
  619. {
  620. if (orderEntry.Price > 0m)
  621. return true;
  622.  
  623. if (!orderEntry.Product.PrechequePrintable)
  624. return false;
  625.  
  626. var modifierEntry = orderEntry as IModifierEntry;
  627. if (modifierEntry == null)
  628. return true;
  629.  
  630. if (modifierEntry.ChildModifier == null || !modifierEntry.ChildModifier.HideIfDefaultAmount)
  631. return true;
  632.  
  633. var amountPerItem = modifierEntry.ChildModifier.AmountIndependentOfParentAmount
  634. ? modifierEntry.Amount
  635. : modifierEntry.Amount / parent.Amount;
  636.  
  637. return amountPerItem != modifierEntry.ChildModifier.DefaultAmount;
  638. }
  639.  
  640. private static string GetFormattedDiscountDescriptionForOrderItem(bool isDiscount, string discountName, bool discountBySum, decimal absolutePercent)
  641. {
  642. return discountBySum
  643. ? string.Format(" {0}", discountName)
  644. : string.Format(isDiscount ? " {0} (-{1})" : " {0} (+{1})", discountName, FormatPercent(absolutePercent));
  645. }
  646.  
  647. private static string GetFormattedDiscountDescriptionShort(bool isDiscount, string discountName)
  648. {
  649. return string.Format(isDiscount ? Resources.BillFooterDiscountNamePatternShort : Resources.BillFooterIncreaseNamePatternShort,
  650. discountName);
  651. }
  652.  
  653. private static string GetFormattedDiscountDescriptionDetailed(bool isDiscount, string discountName, decimal absolutePercent)
  654. {
  655. return string.Format(isDiscount ? Resources.BillFooterDiscountNamePatternDetailed : Resources.BillFooterIncreaseNamePatternDetailed,
  656. discountName, FormatPercent(absolutePercent));
  657. }
  658.  
  659. private static string GetFormattedDiscountSum(bool isDiscount, decimal absoluteSum)
  660. {
  661. return (isDiscount ? "-" : "+") + FormatMoney(absoluteSum);
  662. }
  663. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement