Exemplo n.º 1
0
        private static ISubledgerTransaction BuildSubledgerTransaction(TransactionType type, TransactionStatus status, decimal amount)
        {
            ISubledgerTransaction subledgerTransaction = null;

            if (type == TransactionType.Invoice)
            {
                subledgerTransaction = new InvoiceTransaction(status, amount);
            }
            else if (type == TransactionType.Credit)
            {
                subledgerTransaction = new CreditTransaction(amount);
            }
            else if (type == TransactionType.JournalAr || type == TransactionType.JournalNar)
            {
                subledgerTransaction = new JournalTransaction(amount);
            }
            else if (type == TransactionType.Receipt)
            {
                subledgerTransaction = new ReceiptTransaction(amount);
            }
            else if (type == TransactionType.Overpayment)
            {
                subledgerTransaction = new OverpaymentTransaction(amount);
            }
            else if (type == TransactionType.CreditBalanceTransferCredit || type == TransactionType.CreditBalanceTransferDebit || type == TransactionType.Allocation)
            {
                subledgerTransaction = new CreditBalanceTransferTransaction(amount);
            }
            else if (type == TransactionType.Discount)
            {
                subledgerTransaction = new DiscountTransaction(amount);
            }
            else if (type == TransactionType.Repurchase)
            {
                subledgerTransaction = new RepurchaseTransaction(amount);
            }
            return(subledgerTransaction);
        }
Exemplo n.º 2
0
        public static void ReceiptTransactionExport(List <Receipt> Receipts, string filepath, bool run)
        {
            List <ReceiptTransaction> export = new List <ReceiptTransaction>();

            string rawdata = string.Empty;

            foreach (Receipt r in Receipts)
            {
                foreach (var t in r.transactions)
                {
                    ReceiptTransaction rt = new ReceiptTransaction();
                    rt.transaction_id = t.transaction_id;
                    rt.quanity        = t.quantity;
                    StringBuilder sbVariations = new StringBuilder();
                    foreach (var v in t.variations)
                    {
                        sbVariations.AppendFormat("Variation: {0}, {1} , {2}; ", v.formatted_value, v.formatted_name, v.value_id);
                    }
                    rt.seller_user_id     = r.seller_user_id;
                    rt.variations         = sbVariations.ToString();
                    rt.order_id           = r.order_id;
                    rt.name               = r.name;
                    rt.first_line         = r.first_line;
                    rt.second_line        = r.second_line;
                    rt.city               = r.city;
                    rt.state              = r.state;
                    rt.zip                = r.zip;
                    rt.country_id         = r.country_id;
                    rt.message_from_buyer = r.message_from_buyer;
                    rt.was_paid           = r.was_paid;
                    rt.buyer_email        = r.buyer_email;

                    export.Add(rt);
                }
            }

            using (StreamWriter writer = new StreamWriter(filepath.Replace(".txt", "_transactionsdata.txt")))
            {
                StringBuilder sbHeader   = new StringBuilder();
                List <string> properties = new ReceiptTransaction().GetType().GetProperties().Select(x => x.Name).ToList();

                foreach (var prop in properties)
                {
                    sbHeader.AppendFormat("{0}\t", prop);
                }
                writer.WriteLine(sbHeader.ToString());
                foreach (var rt in export)
                {
                    StringBuilder sbData = new StringBuilder();
                    foreach (var prop in properties)
                    {
                        var o = rt.GetType().GetProperty(prop).GetValue(rt, null);
                        if (o == null)
                        {
                            o = "";
                        }
                        sbData.AppendFormat("{0}\t", o.ToString());
                    }
                    writer.WriteLine(sbData.ToString());
                }
            }
        }