Ejemplo n.º 1
0
        private void ProcessSingleOrder(OrderSnapshot orderSnapshot)
        {
            var order        = _hccApp.OrderServices.Orders.FindForCurrentStore(orderSnapshot.bvin);
            var transactions = _hccApp.OrderServices.Transactions.FindAllTransactionsForOrder(orderSnapshot.bvin);

            foreach (var transaction in transactions)
            {
                var action = transaction.Action;
                if (ActionTypeUtils.BalanceChangingActions.Contains(action) &&
                    !ActionTypeUtils.IsGiftCardTransaction(action) &&
                    !ActionTypeUtils.IsRewardPointTransaction(action))
                {
                    ProcessSingleTransaction(order, transaction);
                }
            }
        }
Ejemplo n.º 2
0
        private void RenderReport(IOrderedEnumerable <OrderTransaction> data)
        {
            decimal TotalGrand = 0;
            var     cardtype   = "?";
            decimal totalType  = 0;

            foreach (var dataitem in data)
            {
                if (!ActionTypeUtils.IsCreditCardTransaction(dataitem.Action) &&
                    !ActionTypeUtils.IsGiftCardTransaction(dataitem.Action))
                {
                    continue;
                }

                var cardTypeName = dataitem.CreditCard.CardTypeName;

                if (ActionTypeUtils.IsGiftCardTransaction(dataitem.Action))
                {
                    cardTypeName = Localization.GetString("GiftCard");
                }

                if (cardTypeName != cardtype)
                {
                    if (cardtype != "?")
                    {
                        RenderPreviousTotal(totalType);
                    }
                    totalType = 0;
                    RenderHeader(cardTypeName);
                    cardtype = cardTypeName;
                }

                if (dataitem.AmountAppliedToOrder != 0)
                {
                    totalType  += dataitem.AmountAppliedToOrder;
                    TotalGrand += dataitem.AmountAppliedToOrder;
                    TotalCount++;

                    var row = new TableRow {
                        CssClass = "hcGridRow hcRight"
                    };

                    row.Cells.AddRange(new[]
                    {
                        new TableCell
                        {
                            Text = DateHelper.ConvertUtcToStoreTime(HccApp, dataitem.TimeStampUtc).ToString()
                        },
                        new TableCell {
                            Text = dataitem.OrderNumber
                        },
                        new TableCell {
                            Text = dataitem.Id.ToString()
                        },
                        new TableCell {
                            Text = "XXXX XXXX XXXX " + dataitem.CreditCard.CardNumberLast4Digits
                        },
                        new TableCell {
                            Text = dataitem.AmountAppliedToOrder.ToString("C")
                        }
                    });

                    tblReport.Rows.Add(row);
                }
            }

            if (cardtype != string.Empty)
            {
                RenderPreviousTotal(totalType);
            }

            var footer = new TableRow {
                CssClass = "hcGridFooter"
            };

            footer.Cells.AddRange(new[]
            {
                new TableCell {
                    Text = Localization.GetString("TotalForAllCards"), ColumnSpan = 4
                },
                new TableCell {
                    Text = TotalGrand.ToString("C")
                }
            });

            tblReport.Rows.Add(footer);
        }
        private void RenderTransaction(OrderTransaction t, StringBuilder sb, TimeZoneInfo timezone, bool showCardNumbers)
        {
            sb.Append("<div class=\"controlarea1");
            if (t.Voided)
            {
                sb.Append(" transactionvoided");
            }
            else
            {
                if (t.Success)
                {
                    sb.Append(" transactionsuccess");
                }
                else
                {
                    sb.Append(" transactionfailed");
                }
            }
            sb.Append("\"><div style=\"overflow:auto;width:100%;\">");

            if (t.Voided)
            {
                sb.Append("VOIDED<br />");
            }
            sb.Append(t.Amount.ToString("c") + " - ");

            var paymentMethod = PaymentMethods.Find(t.MethodId);
            var methodName    = paymentMethod != null ? paymentMethod.MethodName : string.Empty;
            var methodInfo    = LocalizationUtils.GetActionType(t.Action, methodName);

            sb.Append(methodInfo + "<br />");
            sb.Append(TimeZoneInfo.ConvertTimeFromUtc(t.TimeStampUtc, timezone) + "<br />");
            if (t.Success)
            {
                sb.Append("OK<br />");
            }
            else
            {
                sb.Append("FAILED<br />");
            }
            if (t.Action == ActionType.PurchaseOrderInfo || t.Action == ActionType.PurchaseOrderAccepted)
            {
                sb.Append("PO # " + t.PurchaseOrderNumber + "<br />");
            }
            if (t.Action == ActionType.CheckReceived || t.Action == ActionType.CheckReturned)
            {
                sb.Append("Check # " + t.CheckNumber + "<br />");
            }
            if (ActionTypeUtils.IsCreditCardTransaction(t.Action))
            {
                if (t.CreditCard.IsCardNumberValid())
                {
                    if (showCardNumbers)
                    {
                        sb.Append(t.CreditCard.CardTypeName + " " + t.CreditCard.CardNumber + "<br />");
                    }
                    else
                    {
                        sb.Append(t.CreditCard.CardTypeName + " xxxx-xxxx-xxxx-" + t.CreditCard.CardNumberLast4Digits +
                                  "<br />");
                    }
                    sb.Append("exp: " + t.CreditCard.ExpirationMonth + "/" + t.CreditCard.ExpirationYear + "<br />");
                }
                else
                {
                    sb.Append("Unknown or Invalid Card Number Entered" + "<br/>");
                }
            }
            if (ActionTypeUtils.IsGiftCardTransaction(t.Action))
            {
                sb.Append("Gift Card " + t.GiftCard.CardNumber + "<br />");
            }
            if (!string.IsNullOrEmpty(t.RefNum1))
            {
                sb.Append("Ref#: " + t.RefNum1 + "<br />");
            }
            if (!string.IsNullOrEmpty(t.RefNum2))
            {
                sb.Append("Ref2#: " + t.RefNum2 + "<br />");
            }
            if (!string.IsNullOrEmpty(t.RMABvin))
            {
                sb.Append("RMA: " + t.RMABvin + "<br />");
            }
            sb.Append(t.Messages);
            sb.Append("</div></div>");
        }