示例#1
0
        private void ProcessSingleTransaction(Order order, OrderTransaction transaction)
        {
            var date            = transaction.TimeStampUtc.ToString("d", CultureInfo.InvariantCulture);
            var transactionType = GetTransactionType(transaction.Action);
            var customer        = _hccApp.MembershipServices.Customers.Find(order.UserID);
            var customerName    = order.BillingAddress.FirstName + " " + order.BillingAddress.LastName;

            var orderAccount    = _hccApp.CurrentStore.Settings.QuickbooksOrderAccount;
            var shippingAccount = _hccApp.CurrentStore.Settings.QuickbooksShippingAccount;

            var memoKey   = order.TotalOrderDiscounts == 0 ? "OrderMemo" : "OrderWithDiscountMemo";
            var orderName = LocalizationUtils.GetQuickbooksExportFormattedString(memoKey, order.OrderNumber);
            var payMeth   = GetPaymentMethodName(transaction);

            WriteLine(new[]
            {
                "TRNS", transaction.IdAsString, transactionType, date, order.OrderNumber, orderAccount, orderName,
                customerName, transaction.Amount.ToString(CultureInfo.InvariantCulture), customer.TaxExempt ? "N" : "Y",
                payMeth
            });
            foreach (var item in order.Items)
            {
                var itemTaxPortion = order.ApplyVATRules ? 0 : item.TaxPortion;
                var itemPercentage = (item.LineTotal + itemTaxPortion) / order.TotalGrand;
                var amountApplied  = itemPercentage * transaction.Amount;

                var product     = item.GetAssociatedProduct(_hccApp);
                var productType = product != null
                    ? _hccApp.CatalogServices.ProductTypes.Find(product.ProductTypeId)
                    : null;

                var productTypeName = productType != null ? productType.ProductTypeName : string.Empty;

                WriteLine(new[]
                {
                    "SPL", item.Id.ToString(), transactionType, date, productTypeName, item.ProductName, customerName,
                    (-1 * amountApplied).ToString(CultureInfo.InvariantCulture),
                    product != null && product.TaxExempt ? "N" : "Y"
                });
            }
            var shippingTaxPortion    = order.ApplyVATRules ? 0 : order.ShippingTax;
            var shippingPercentage    = (order.TotalShippingAfterDiscounts + shippingTaxPortion) / order.TotalGrand;
            var shippingAmountApplied = shippingPercentage * transaction.Amount;
            var shippingName          = LocalizationUtils.GetQuickbooksExportFormattedString("ShippingMemo");

            WriteLine(new[]
            {
                "SPL", "shipping", transactionType, date, shippingAccount, shippingName, customerName,
                (-1 * shippingAmountApplied).ToString(CultureInfo.InvariantCulture), "Y"
            });
            WriteLine(new[] { "ENDTRNS" });
        }
示例#2
0
        public bool AddPaymentTransactionToOrder(Order o, OrderTransaction t)
        {
            // Save Order First if no bvin
            Orders.Upsert(o);

            t.OrderId     = o.bvin;
            t.OrderNumber = o.OrderNumber;
            t.StoreId     = o.StoreId;

            if (Transactions.Create(t))
            {
                var previous = o.PaymentStatus;
                EvaluatePaymentStatus(o);
                OnPaymentChanged(previous, o);
                return(Orders.Update(o));
            }

            return(false);
        }
示例#3
0
        private string GetPaymentMethodName(OrderTransaction transaction)
        {
            switch (transaction.Action)
            {
            case ActionType.CashReceived:
            case ActionType.CashReturned:
                return(LocalizationUtils.GetQuickbooksExportString("PayMethCash"));

            case ActionType.CheckReceived:
            case ActionType.CheckReturned:
                return(LocalizationUtils.GetQuickbooksExportString("PayMethCheck"));

            case ActionType.CompanyAccountAccepted:
                return(LocalizationUtils.GetQuickbooksExportString("PayMethCompanyAccount"));

            case ActionType.PurchaseOrderAccepted:
                return(LocalizationUtils.GetQuickbooksExportString("PayMethPurchaseOrder"));

            case ActionType.CreditCardCapture:
            case ActionType.CreditCardCharge:
            case ActionType.CreditCardRefund:
                return(LocalizationUtils.GetQuickbooksExportString("PayMethCreditCard"));

            case ActionType.PayPalCapture:
            case ActionType.PayPalCharge:
            case ActionType.PayPalRefund:
                return(LocalizationUtils.GetQuickbooksExportString("PayMethPayPal"));

            case ActionType.ThirdPartyPayMethodCapture:
            case ActionType.ThirdPartyPayMethodCharge:
            case ActionType.ThirdPartyPayMethodRefund:
                var payMeth = PaymentMethods.Find(transaction.MethodId);
                return(LocalizationUtils.GetPaymentMethodFriendlyName(payMeth.MethodName));

            default:
                return(LocalizationUtils.GetQuickbooksExportString("PayMethUnknown"));
            }
        }
示例#4
0
        public bool AddPaymentTransactionToOrder(Order o, Transaction t)
        {
            var ot = new OrderTransaction(t);

            return(AddPaymentTransactionToOrder(o, ot));
        }
示例#5
0
 public bool AddPaymentTransactionToOrder(Order o, OrderTransaction t, HotcakesApplication app)
 {
     return(AddPaymentTransactionToOrder(o, t));
 }