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" }); }