Exemple #1
0
    public void openTransactionReceipt(TransactionSummaryDetailsData tsDetailsData)
    {
        this.gameObject.SetActive(false);
        transactionReceiptPanel.gameObject.SetActive(true);

        Transaction tempTransaction = tsDetailsData.getTransactionList()[0];

        //Rebuild the list of rows in the checkout panel
        transactionReceiptPanel.itemList.RemoveAllRows();
        foreach (ItemRowData rowData in tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList)
        {
            ItemRow newRow = transactionReceiptPanel.itemList.AddItem();
            newRow.SetScanString(rowData.scanString);
            newRow.SetItemDescription(rowData.itemDescription);
            newRow.SetProductOwner(rowData.productOwner);
            newRow.SetItemPrice(rowData.itemPrice);
            newRow.SetItemOriginalPrice(rowData.itemPrice);
            newRow.SetQuantity(rowData.quantity);
            newRow.UpdatePriceText();

            newRow.plusButton.gameObject.SetActive(false);
            newRow.minusButton.gameObject.SetActive(false);
            newRow.quantityInputField.readOnly = true;
            newRow.ellipsis.SetActive(false);
        }

        transactionReceiptPanel.itemList.CalculateTotals();

        //Send all data to the checkout panel
        //transactionReceiptPabel.itemList.SetItemTotal(this.itemList.GetItemTotal());
        //transactionReceiptPabel.itemList.SetPriceSubtotal(this.itemList.GetPriceSubtotal());
        //transactionReceiptPabel.itemList.SetTaxTotal(this.itemList.GetTaxTotal());
        transactionReceiptPanel.SetTransactionNumber(tsDetailsData.GetPrimaryKey());
        transactionReceiptPanel.SetPaymentMethod(tempTransaction.paymentMethod);
        transactionReceiptPanel.SetTransactionDateTime(tempTransaction.datetime);
        transactionReceiptPanel.SetTransaction(tempTransaction);
    }
Exemple #2
0
    /* Return sorted transaction list by date */
    public List <TransactionSummaryData> GetTransactionsSortedByDate()
    {
        List <Transaction>            transactionList            = transactionListContainer.transactionList;
        List <TransactionSummaryData> transactionSummaryDataList = new List <TransactionSummaryData>();

        Dictionary <string, TransactionSummaryData>           transactionSummaryDataDict           = new Dictionary <string, TransactionSummaryData>();
        Dictionary <string, TransactionSummaryFirstSubData>   transactionSummaryFirstSubDataDict   = new Dictionary <string, TransactionSummaryFirstSubData>();
        Dictionary <string, TransactionSummarySecondSubData>  transactionSummarySecondSubDataDict  = new Dictionary <string, TransactionSummarySecondSubData>();
        Dictionary <string, TransactionSummarySubDetailsData> transactionSummarySubDetailsDataDict = new Dictionary <string, TransactionSummarySubDetailsData>();

        TransactionSummaryData           transactionSummaryData;
        TransactionSummaryFirstSubData   transactionSummaryFirstSubData   = null;
        TransactionSummarySecondSubData  transactionSummarySecondSubData  = null;
        TransactionSummarySubDetailsData transactionSummarySubDetailsData = null;
        TransactionSummaryDetailsData    transactionSummaryDetailsData    = null;

        foreach (Transaction transaction in transactionList)
        {
            string date  = transaction.datetime.Substring(0, 11);
            string year  = date.Substring(7, 4);
            string month = date.Substring(3, 3);
            string day   = date.Substring(0, 2);
            string time  = transaction.datetime.Substring(12, 8);
            transactionSummaryDetailsData = null;

            transactionSummaryData = new TransactionSummaryData(year);

            foreach (ItemRowData itemRowData in transaction.itemListData.itemRowDataListContainer.itemRowDataList)
            {
                string owner = itemRowData.productOwner;

                if (transactionSummarySubDetailsDataDict.ContainsKey(year + month + day + owner))
                {
                    transactionSummarySubDetailsData = transactionSummarySubDetailsDataDict[year + month + day + owner];

                    if (transactionSummaryDetailsData == null)
                    {
                        transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                        Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                        tempTransaction.SetDateTime(transaction.datetime);
                        tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                        tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);
                        transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                        transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    }
                    else
                    {
                        transactionSummaryDetailsData.getTransactionList().First().itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);
                    }

                    transactionSummaryDetailsData.SetTotalPrice(transactionSummaryDetailsData.GetTotalPrice() + itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);

                    transactionSummarySecondSubData = transactionSummarySecondSubDataDict[year + month + day];
                    transactionSummaryFirstSubData  = transactionSummaryFirstSubDataDict[year + month];
                    transactionSummaryData          = transactionSummaryDataDict[year];

                    transactionSummarySubDetailsData.SetTotalPrice(transactionSummarySubDetailsData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummarySecondSubData.SetTotalPrice(transactionSummarySecondSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryFirstSubData.SetTotalPrice(transactionSummaryFirstSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryData.SetTotalPrice(transactionSummaryData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                }
                else if (transactionSummarySecondSubDataDict.ContainsKey(year + month + day))
                {
                    Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                    tempTransaction.SetDateTime(transaction.datetime);
                    tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                    tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);

                    transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                    transactionSummaryDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);
                    transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                    transactionSummarySubDetailsData = new TransactionSummarySubDetailsData(owner);
                    transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    transactionSummarySubDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySecondSubData = transactionSummarySecondSubDataDict[year + month + day];
                    transactionSummaryFirstSubData  = transactionSummaryFirstSubDataDict[year + month];
                    transactionSummaryData          = transactionSummaryDataDict[year];

                    transactionSummarySecondSubData.GetTransactionSummarySubDetailsData().Add(transactionSummarySubDetailsData);

                    transactionSummarySecondSubData.SetTotalPrice(transactionSummarySecondSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryFirstSubData.SetTotalPrice(transactionSummaryFirstSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryData.SetTotalPrice(transactionSummaryData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));

                    transactionSummarySubDetailsDataDict.Add(year + month + day + owner, transactionSummarySubDetailsData);
                }
                else if (transactionSummaryFirstSubDataDict.ContainsKey(year + month))
                {
                    Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                    tempTransaction.SetDateTime(transaction.datetime);
                    tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                    tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);

                    transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                    transactionSummaryDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);
                    transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                    transactionSummarySubDetailsData = new TransactionSummarySubDetailsData(owner);
                    transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    transactionSummarySubDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySecondSubData = new TransactionSummarySecondSubData(day);
                    transactionSummarySecondSubData.GetTransactionSummarySubDetailsData().Add(transactionSummarySubDetailsData);
                    transactionSummarySecondSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryFirstSubData = transactionSummaryFirstSubDataDict[year + month];
                    transactionSummaryData         = transactionSummaryDataDict[year];

                    transactionSummaryFirstSubData.GetTransactionSummarySecondSubDataList().Add(transactionSummarySecondSubData);
                    transactionSummaryFirstSubData.SetTotalPrice(transactionSummaryFirstSubData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));
                    transactionSummaryData.SetTotalPrice(transactionSummaryData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));

                    transactionSummarySubDetailsDataDict.Add(year + month + day + owner, transactionSummarySubDetailsData);
                    transactionSummarySecondSubDataDict.Add(year + month + day, transactionSummarySecondSubData);
                }
                else if (transactionSummaryDataDict.ContainsKey(year))
                {
                    Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                    tempTransaction.SetDateTime(transaction.datetime);
                    tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                    tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);

                    transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                    transactionSummaryDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);
                    transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                    transactionSummarySubDetailsData = new TransactionSummarySubDetailsData(owner);
                    transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    transactionSummarySubDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySecondSubData = new TransactionSummarySecondSubData(day);
                    transactionSummarySecondSubData.GetTransactionSummarySubDetailsData().Add(transactionSummarySubDetailsData);
                    transactionSummarySecondSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryFirstSubData = new TransactionSummaryFirstSubData(month);
                    transactionSummaryFirstSubData.GetTransactionSummarySecondSubDataList().Add(transactionSummarySecondSubData);
                    transactionSummaryFirstSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryData = transactionSummaryDataDict[year];
                    transactionSummaryData.GetTransactionSummaryFirstSubDataList().Add(transactionSummaryFirstSubData);
                    transactionSummaryData.SetTotalPrice(transactionSummaryData.GetTotalPrice() + (itemRowData.itemPrice * itemRowData.quantity));

                    transactionSummarySubDetailsDataDict.Add(year + month + day + owner, transactionSummarySubDetailsData);
                    transactionSummarySecondSubDataDict.Add(year + month + day, transactionSummarySecondSubData);
                    transactionSummaryFirstSubDataDict.Add(year + month, transactionSummaryFirstSubData);
                }
                else
                {
                    Transaction tempTransaction = new Transaction(transaction.GetTransactionID());
                    tempTransaction.SetDateTime(transaction.datetime);
                    tempTransaction.SetPaymentMethod(transaction.paymentMethod);
                    tempTransaction.itemListData.itemRowDataListContainer.itemRowDataList.Add(itemRowData);

                    transactionSummaryDetailsData = new TransactionSummaryDetailsData(transaction.GetTransactionID() + "");
                    transactionSummaryDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);
                    transactionSummaryDetailsData.SetTransactionTime(time);
                    transactionSummaryDetailsData.getTransactionList().Add(tempTransaction);

                    transactionSummarySubDetailsData = new TransactionSummarySubDetailsData(owner);
                    transactionSummarySubDetailsData.getTransactionSummaryDetailsData().Add(transactionSummaryDetailsData);
                    transactionSummarySubDetailsData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySecondSubData = new TransactionSummarySecondSubData(day);
                    transactionSummarySecondSubData.GetTransactionSummarySubDetailsData().Add(transactionSummarySubDetailsData);
                    transactionSummarySecondSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryFirstSubData = new TransactionSummaryFirstSubData(month);
                    transactionSummaryFirstSubData.GetTransactionSummarySecondSubDataList().Add(transactionSummarySecondSubData);
                    transactionSummaryFirstSubData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummaryData = new TransactionSummaryData(year);
                    transactionSummaryData.GetTransactionSummaryFirstSubDataList().Add(transactionSummaryFirstSubData);
                    transactionSummaryData.SetTotalPrice(itemRowData.itemPrice * itemRowData.quantity);

                    transactionSummarySubDetailsDataDict.Add(year + month + day + owner, transactionSummarySubDetailsData);
                    transactionSummarySecondSubDataDict.Add(year + month + day, transactionSummarySecondSubData);
                    transactionSummaryFirstSubDataDict.Add(year + month, transactionSummaryFirstSubData);
                    transactionSummaryDataDict.Add(year, transactionSummaryData);
                }
            }
        }

        transactionSummaryDataList = transactionSummaryDataDict.Values.ToList().OrderByDescending(transactionSummaryData2 => DateTime.ParseExact(transactionSummaryData2.primaryKey, "yyyy", null)).ToList();

        return(transactionSummaryDataList);
    }