/// <summary>
 /// Добавляет новое поступление ОСП.
 /// </summary>
 /// <param name="newReceipt">Новое поступление ОСП</param>
 public void AddNewOspReceipt(ReceiptDTO newReceipt)
 {
     if (newReceipt != null)
     {
         Receipts.Add(newReceipt);
     }
 }
Exemple #2
0
 public static (List <Receipt>, List <ItemsInReceipt>) SaveReceipt(List <Receipt> Receipts, UserData CurrentUser, List <ItemsInReceipt> InRec)
 {
     if (Receipts == null)
     {
         Receipts = new List <Receipt>();
     }
     if (InRec == null)
     {
         InRec = new List <ItemsInReceipt>();
     }
     (Receipt newRec, List <ItemsInReceipt> NewInRec) = AddNewReceipt(CurrentUser, InRec);
     Receipts.Add(newRec);
     return(Receipts, NewInRec);
 }
Exemple #3
0
        public void AddReceipt(decimal value)
        {
            if (value <= 0)
            {
                throw new ArgumentException("numberOfReceipts must bt greater than zero");
            }

            if (IsReceiptsCompleted)
            {
                throw new Exception("numberOfReceipts is already reached");
            }

            Receipts.Add(value);
            TotalAmount += value;
        }
Exemple #4
0
        public void Add(ModelBase obj)
        {
            if (obj is Account)
            {
                Accounts.Add(obj as Account);
            }
            else if (obj is Transaction)
            {
                Transactions.Add(obj as Transaction);

                foreach (var detail in ((Transaction)obj).Details)
                {
                    Add(detail);
                }
            }
            else if (obj is TransactionDetail)
            {
                TransactionDetails.Add(obj as TransactionDetail);
            }
            else if (obj is Receipt)
            {
                Receipts.Add(obj as Receipt);
            }
            else if (obj is ScheduledTransaction)
            {
                ScheduledTransactions.Add(obj as ScheduledTransaction);

                foreach (var detail in ((ScheduledTransaction)obj).Details)
                {
                    Add(detail);
                }
            }
            else if (obj is ScheduledTransactionDetail)
            {
                ScheduledTransactionDetails.Add(obj as ScheduledTransactionDetail);
            }
            else if (obj is Category)
            {
                Categories.Add(obj as Category);
            }
            else if (obj is Product)
            {
                Products.Add(obj as Product);
            }
        }
 /// <summary>
 /// Обновляет поступления ОСП.
 /// </summary>
 /// <param name="ospReceipts">Новый список поступлений</param>
 public void UpdateReceipts(IEnumerable <ReceiptDTO> ospReceipts)
 {
     // Если список не пустой.
     if (ospReceipts.Count() > 0)
     {
         // Получить новые объекты.
         ReceiptDTO[] added = ospReceipts.Except(Receipts, new ReceiptDTOComparer()).ToArray();
         // Получить удаленные объекты
         ReceiptDTO[] removed = Receipts.Except(ospReceipts, new ReceiptDTOComparer()).ToArray();
         // Получить существующие объекты.
         ReceiptDTO[] existing = Receipts.Intersect(ospReceipts, new ReceiptDTOComparer()).ToArray();
         // Добавить в список новые объекты.
         if (added.Any())
         {
             for (int i = 0; i < added.Count(); i++)
             {
                 Receipts.Add(added[i]);
             }
         }
         // Убрать из списка удаленные объекты.
         if (removed.Any())
         {
             for (int i = 0; i < removed.Count(); i++)
             {
                 Receipts.Remove(removed[i]);
             }
         }
         // Обновить свойства существующим объектам.
         if (existing.Any())
         {
             foreach (var exist in existing)
             {
                 UpdateReceipt(exist);
             }
         }
     }
     // Если список новых пустой очистить список поступлений.
     else
     {
         Receipts.Clear();
     }
 }
Exemple #6
0
        async Task GetReicipts()
        {
            if (IsBusy)
            {
                return;
            }

            Exception error = null;

            try
            {
                IsBusy = true;

                var service = DependencyService.Get <AzureReceiptService>();
                var items   = await service.GetReceiptsAsync();

                Receipts.Clear();
                foreach (var item in items)
                {
                    Receipts.Add(item);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error: " + ex);
                error = ex;
            }
            finally
            {
                IsBusy = false;
            }

            if (error != null)
            {
                await Application.Current.MainPage.DisplayAlert("Error!", error.Message, "OK");
            }
        }
        public async Task Refresh()
        {
            _receiptItems.Clear();
            _goodsItems.Clear();

            List <AlbumItem> receipts = await _azure.GetAllImages(CurrentTransaction.ID, true);

            foreach (AlbumItem t in receipts)
            {
                Receipts.Add(t);
            }

            receipts.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = true
            });
            int            i       = 0;
            ImageListItems tempILI = new ImageListItems();

            foreach (AlbumItem t in receipts)
            {
                //RESET temp class for next ListEntry
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                //Add Image
                tempILI.ItemImages.Add(t);

                //Add ListEntry content and reset for next Entry
                if (i >= 3)
                {
                    ReceiptItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                ReceiptItems.Add(tempILI);
            }

            //Reset Values to refresh Goods
            tempILI = null;
            i       = 0;


            List <AlbumItem> goods = await _azure.GetAllImages(CurrentTransaction.ID, false);

            foreach (AlbumItem t in goods)
            {
                Goods.Add(t);
            }

            goods.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = false
            });
            foreach (AlbumItem t in goods)
            {
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                tempILI.ItemImages.Add(t);
                if (i >= 3)
                {
                    GoodsItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                GoodsItems.Add(tempILI);
            }
            HockeyApp.MetricsManager.TrackEvent("Images Page Loaded");
        }
 public void AddReceipt(object receipt)
 {
     Receipts.Add((ReceiptAttachment)receipt);
 }
Exemple #9
0
 public void AddReceipt(Receipt newReceipt)
 {
     Balance += newReceipt.Value;
     Receipts.Add(newReceipt);
 }
Exemple #10
0
        public async Task Refresh()
        {
            // NEED TO REWORK FOR THE NEW VIEW - OUTDATED

            IsLoading = true;

            #region Receipts
            Receipts.Clear();
            List <AlbumItem> receipts = await _azure.GetAllImages(CurrentTransaction.ID, true);

            foreach (AlbumItem t in receipts)
            {
                Receipts.Add(t);
            }

            receipts.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = true
            });
            int            i       = 0;
            ImageListItems tempILI = new ImageListItems();

            //ClearItems before applying new items
            ReceiptItems.Clear();
            foreach (AlbumItem t in receipts)
            {
                //RESET temp class for next ListEntry
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                //Add Image
                tempILI.ItemImages.Add(t);

                //Add ListEntry content and reset for next Entry
                if (i >= 3)
                {
                    ReceiptItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                ReceiptItems.Add(tempILI);
            }
            #endregion

            //Reset Values to refresh Goods
            tempILI = null;
            i       = 0;

            #region Goods
            Goods.Clear();
            List <AlbumItem> goods = await _azure.GetAllImages(CurrentTransaction.ID, false);

            foreach (AlbumItem t in goods)
            {
                Goods.Add(t);
            }

            goods.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = false
            });
            //ClearItems before applying new items
            GoodsItems.Clear();
            foreach (AlbumItem t in goods)
            {
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                tempILI.ItemImages.Add(t);
                if (i >= 3)
                {
                    GoodsItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                GoodsItems.Add(tempILI);
            }
            #endregion

            List <AlbumItem> images = await _azure.GetAllImages(CurrentTransaction.ID);

            foreach (AlbumItem image in images)
            {
                Images.Add(image);
            }

            if (!IsUnitTesting)
            {
                HockeyApp.MetricsManager.TrackEvent("Images Page Loaded");
            }

            IsLoading = false;
        }