Exemple #1
0
 public async void UpdateBeleg(Beleg beleg)
 {
     if (beleg.Status == Beleg.StatusEnum.ERFASST)
     {
         BelegDAO.Instance.StoreBeleg(beleg);
     }
 }
Exemple #2
0
        public DetailPage(int?belegnummer, INavigation navigation)
        {
            InitializeComponent();
            _belegnummer = belegnummer;
            Beleg  beleg    = null;
            Action callback = new Action(() =>
            {
                navigation.PopToRootAsync();
            });

            if (_belegnummer.HasValue)
            {
                beleg = Storage.Database.GetBeleg(_belegnummer.Value).Result;
            }
            if (beleg == null)
            {
                BindingContext = new BelegDetailsViewModel();
            }
            else
            {
                BindingContext = new BelegDetailsViewModel(beleg);
            }

            //Callback setzen
            (BindingContext as BelegDetailsViewModel).Callback = callback;
        }
Exemple #3
0
        public void InitialStoreShouldResultInBeleg()
        {
            Beleg beleg = new Beleg(null, "Testbeleg", null, DateTime.UtcNow.Date, "Test", 100, Beleg.StatusEnum.ERFASST, null, null);

            database.StoreBeleg(beleg).Wait();
            Assert.IsNotNull(database.GetBeleg(beleg.Belegnummer.Value).Result);
        }
Exemple #4
0
        public async void GetBelege(string user, Action <Task <List <Beleg> > > callback)
        {
            await Task.Factory.StartNew(() =>
            {
                List <Beleg> alleBelege   = this.client.GetBelegeByUserAsync(user).Result;
                List <Beleg> belegeFromDB = BelegDAO.Instance.GetBelegeByUser(user).Result;

                foreach (var beleg in alleBelege)
                {
                    Beleg fromDb = BelegDAO.Instance.GetBelegByBelegnummer(beleg.Belegnummer.Value).Result;
                    if (fromDb == null)
                    {
                        BelegDAO.Instance.StoreBeleg(beleg);
                    }
                }

                List <Beleg> belegeToAdd = belegeFromDB.Where(b => b.Belegnummer == 0)?.ToList();

                foreach (var item in belegeToAdd)
                {
                    alleBelege.Add(item);
                }

                return(alleBelege);
            }).ContinueWith((o) => callback(o));
        }
Exemple #5
0
        public BelegDetailsViewModel(Beleg beleg)
        {
            if (beleg == null)
            {
                throw new ArgumentNullException("beleg");
            }

            _validatableLabel       = new ValidatableObject <string>(true);
            _validatableDescription = new ValidatableObject <string>(true);
            _validatableType        = new ValidatableObject <string>(true);

            Belegnummer = beleg.Belegnummer;
            _statusEnum = beleg.Status;
            Label       = beleg.Label;
            Description = beleg.Description;
            _datum      = beleg.Date;

            Type       = beleg.Type;
            _thumbnail = beleg.Thumbnail;
            _belegSize = beleg.BelegSize;
            _iconName  = beleg.Status + ".png";
            _image     = beleg.Image;
            _betrag    = beleg.Betrag / 100m;
            //decimal.Parse(beleg.Betrag / 100m)).ToString("c")); //e.g. 12345 becomes €123.45 for me)
            //_betrag = (decimal)(beleg.Betrag / 100);

            selected = false;

            Init();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            user  = Intent.Extras.GetString("USER");
            beleg = new Beleg(0, "", DateTime.Now, "", 0, Beleg.StatusEnum.ERFASST, null, null, 0, user);
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.beleg_erfassen);

            betrag       = FindViewById <EditText>(Resource.Id.et_betrag);
            bezeichnung  = FindViewById <EditText>(Resource.Id.et_bezeichnung);
            spBelegArten = FindViewById <Spinner>(Resource.Id.sp_art);

            etDate        = FindViewById <EditText>(Resource.Id.et_date);
            etDate.Click += delegate
            {
                DateTime date = beleg.Date.Value;
                new DatePickerDialog(this, this, date.Year, date.Month, date.Day).Show();
            };
            CreateDirectoryForPictures();
            ivPhoto        = FindViewById <ImageView>(Resource.Id.iv_beleg_image);
            ivPhoto.Click += delegate
            {
                takePhoto();
            };

            UIService.Instance.GetBelegarten((o) => setBelegArten(o));
        }
        public List <Beleg> GetBelegByQueryData(BelegQueryData queryData, bool includeBelegPosition, bool includePayment)
        {
            List <Beleg> wrkList = new List <Beleg>();

            using (DbCommand cmd = myRepoFactory.CreateCommand()) {
                cmd.CommandText = "select * from Beleg ";
                List <string> whereConditions = genereateConditions(queryData, cmd);
                if (whereConditions.Count > 0)
                {
                    string condCombined = whereConditions.Select(w => w).Aggregate((s1, s2) => s1 + " and " + s2);
                    cmd.CommandText += "where " + condCombined;
                }
                using (DbDataReader dbDr = cmd.ExecuteReader()) {
                    while (dbDr.Read())
                    {
                        Beleg b = new Beleg();
                        b.FillEntityWithDataReader(dbDr);
                        if (includeBelegPosition)
                        {
                            FindBelegPositionenByBelegId(b.BelegId).ForEach(p => b.Positionen.Add(p));
                        }
                        if (includePayment)
                        {
                            FindBelegZahlungByBelegId(b.BelegId).ForEach(z => b.Zahlungen.Add(z));
                        }
                        wrkList.Add(b);
                    }
                }
            }

            return(wrkList);
        }
Exemple #8
0
        public void setSavedBeleg(Beleg newBeleg)
        {
            string iconname = "navbaritem_plus";

            if (newBeleg != null)
            {
                betrag.Text       = Convert.ToString(newBeleg.Betrag.Value);
                beschreibung.Text = newBeleg.Description;
                bezeichnung.Text  = newBeleg.Label;
                artValue.Text     = newBeleg.Type;
                datumValue.Text   = newBeleg.Date.Value.ToString("dd.MM.yyyy");
                if (newBeleg.Status == Beleg.StatusEnum.ABGELEHNT)
                {
                    iconname = "navbaritem_cancel";
                }
                else if (newBeleg.Status == Beleg.StatusEnum.EXPORTIERT)
                {
                    iconname = "navbaritem_save";
                }
                else if (newBeleg.Status == Beleg.StatusEnum.GEBUCHT)
                {
                    iconname = "navbaritem_cash";
                }
                if (newBeleg.Thumbnail != null)
                {
                    beleg.Image = new UIImage(NSData.FromArray(newBeleg.Thumbnail));
                }
            }
            status.Image = UIImage.FromBundle(iconname);
        }
Exemple #9
0
        public void setCellData(Beleg newData)
        {
            betrag.Text      = newData.Betrag.ToString();
            bezeichnung.Text = newData.Label;
            datum.Text       = newData.Date.Value.ToString("dd.MM.yyyy");;
            string iconname = "navbaritem_plus";

            if (newData.Status == Beleg.StatusEnum.ABGELEHNT)
            {
                iconname = "navbaritem_cancel";
            }
            else if (newData.Status == Beleg.StatusEnum.EXPORTIERT)
            {
                iconname = "navbaritem_save";
            }
            else if (newData.Status == Beleg.StatusEnum.GEBUCHT)
            {
                iconname = "navbaritem_cash";
            }
            status.Image = UIImage.FromBundle(iconname);
            if (newData.Thumbnail != null)
            {
                image.Image = new UIImage(NSData.FromArray(newData.Thumbnail));
            }
        }
Exemple #10
0
        private async static void foo()
        {
            UIService.Instance.GetBelege("hugo", null);

            ReisekostenNative.RESTClient.RESTClient test = new ReisekostenNative.RESTClient.RESTClient();
            List <string> tmp = await test.GetTypesAsync();

            List <string> tmp2 = await test.GetStatiAsync();

            Beleg testBeleg = new Beleg();

            //testBeleg.BelegSize = 10;
            //testBeleg.Betrag = 11;
            testBeleg.Description = "servus";
            testBeleg.Status      = Beleg.StatusEnum.ERFASST;
            //testBeleg.Belegnummer = 12;
            //testBeleg.Thumbnail = null;
            testBeleg.Type = "Hotel";
            testBeleg.Date = DateTime.UtcNow;
            int tmp4 = await test.CreateBeleg("hugo", testBeleg);

            List <Beleg> tmp3n = await test.GetBelegeByUserAsync("hugo");

            Beleg b = tmp3n.First();

            test.UpdateImage("hugo", b.Belegnummer.Value, new byte[] { 232, 23, 54, 87 });
            b.Description = "put-test";
            test.UpdateBeleg("hugo", b.Belegnummer.Value, b);
            tmp3n = await test.GetBelegeByUserAsync("hugo");
        }
Exemple #11
0
 public Task <int> StoreBeleg(Beleg beleg)
 {
     if (beleg.Belegnummer == null || !beleg.Belegnummer.HasValue)
     {
         beleg.Belegnummer = idGenerator--;
     }
     return(database.InsertOrReplaceAsync(beleg));
 }
Exemple #12
0
        public void InitialStoreShouldResultInOneElementList()
        {
            Beleg beleg = new Beleg(null, "Testbeleg", null, DateTime.UtcNow.Date, "Test", 100, Beleg.StatusEnum.ERFASST, null, null);
            int   nr    = database.StoreBeleg(beleg).Result;

            Models.Beleg[] result = database.GetBelege().Result;
            Assert.AreEqual(1, result.Length, result.ToString());
        }
        public void OnlyBackendAbgelehntShouldNotInsert()
        {
            Beleg beleg = createBeleg(Beleg.StatusEnum.ABGELEHNT);

            Assert.AreEqual(0, helper.DoRefreshStatus(new Beleg[] { beleg }, new Beleg[0]).Result);
            Beleg[] result = database.GetBelege().Result;
            Assert.AreEqual(0, result.Length, result.ToString());
        }
        public void OnlyBackendShouldInsert()
        {
            Beleg beleg = createBeleg(Beleg.StatusEnum.ERFASST);

            Assert.AreEqual(1, helper.DoRefreshStatus(new Beleg[] { beleg }, new Beleg[0]).Result);
            Beleg[] result = database.GetBelege().Result;
            Assert.AreEqual(1, result.Length, result.ToString());
            Assert.AreEqual(beleg.Status, result[0].Status);
        }
Exemple #15
0
 public void belegClicked(Beleg beleg)
 {
     if (beleg != null)
     {
         Intent intent = new Intent(this, typeof(BelegErfassenActivity));
         intent.PutExtra("USER", user);
         intent.PutExtra("BELEG", beleg.BelegID.ToString());
         StartActivity(intent);
     }
 }
Exemple #16
0
        public static void DBTest()
        {
            Beleg b      = new Beleg(1, "test", DateTime.Now, "Hotel", 100, Beleg.StatusEnum.ERFASST);
            var   id     = BelegDAO.Instance.StoreBeleg(b).Result;
            var   loaded = BelegDAO.Instance.GetBeleg(id).Result;

            BelegArt ba   = new BelegArt("Hotel");
            var      baID = BelegArtenDAO.Instance.StoreBelegArt(ba);
            var      baL  = BelegArtenDAO.Instance.GetBelegArt("Hotel").Result.Name;
        }
        public void OnlyLocalShouldChangeNothing()
        {
            Beleg beleg = createBeleg(Beleg.StatusEnum.ERFASST);

            database.StoreBeleg(beleg).Wait();
            Assert.AreEqual(0, helper.DoRefreshStatus(new Beleg[0], new Beleg[] { beleg }).Result);
            Beleg[] result = database.GetBelege().Result;
            Assert.AreEqual(1, result.Length, result.ToString());
            Assert.AreEqual(beleg.Status, result[0].Status);
        }
Exemple #18
0
        public void DeleteAfterStoreShouldBeEmpty()
        {
            Beleg beleg = new Beleg(null, "Testbeleg", null, DateTime.UtcNow.Date, "Test", 100, Beleg.StatusEnum.ERFASST, null, null);

            database.StoreBeleg(beleg).Wait();
            Models.Beleg[] result = database.GetBelege().Result;
            Assert.AreEqual(1, result.Length, result.ToString());
            database.RemoveBeleg(result[0]).Wait();
            Assert.AreEqual(0, database.GetBelege().Result.Length, result.ToString());
        }
Exemple #19
0
        public Beleg getToSaveBeleg()
        {
            var toSaveBeleg = new Beleg();

            toSaveBeleg.User        = user;
            toSaveBeleg.Betrag      = Convert.ToInt64(betrag.Text);
            toSaveBeleg.Description = beschreibung.Text;
            toSaveBeleg.Label       = bezeichnung.Text;
            return(toSaveBeleg);
        }
Exemple #20
0
        public void ConsecutiveStoreShouldChangeBeleg()
        {
            Beleg beleg = new Beleg(null, "Testing", "Testbeleg", DateTime.UtcNow.Date, "Test", 100, Beleg.StatusEnum.ERFASST, null, null);

            database.StoreBeleg(beleg).Wait();
            beleg = database.GetBeleg(beleg.Belegnummer.Value).Result;
            Assert.AreEqual("Testbeleg", beleg.Description);
            beleg.Description = "Changed";
            database.StoreBeleg(beleg).Wait();
            Assert.AreEqual("Changed", database.GetBeleg(beleg.Belegnummer.Value).Result.Description);
        }
Exemple #21
0
        public async void UpdateBeleg(string user, int belegNummer, Beleg beleg)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = this.baseUri;

            var json    = JsonConvert.SerializeObject(beleg);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            var response = await client.PutAsync($"belegerfassung-ui/rest/belege/{user}/{belegNummer}", content);
        }
        public void MatchedShouldChange()
        {
            Beleg backend = createBeleg(Beleg.StatusEnum.EXPORTIERT);
            Beleg local   = createBeleg(Beleg.StatusEnum.ERFASST);

            database.StoreBeleg(local).Wait();
            Assert.AreEqual(1, helper.DoRefreshStatus(new Beleg[] { backend }, new Beleg[] { local }).Result);
            Beleg[] result = database.GetBelege().Result;
            Assert.AreEqual(1, result.Length, result.ToString());
            Assert.AreEqual(backend.Status, result[0].Status);
        }
Exemple #23
0
        public async void CreateBeleg(Beleg beleg, Action <Task <int> > callback)
        {
            if (beleg.Date == null)
            {
                beleg.Date = DateTime.UtcNow.Date;
            }

            beleg.Status = Beleg.StatusEnum.ERFASST;

            BelegDAO.Instance.StoreBeleg(beleg).ContinueWith((o) => callback(o));
        }
 public int SaveBeleg(Beleg beleg)
 {
     if (beleg.BelegId == 0)
     {
         return(AddBeleg(beleg));
     }
     else
     {
         UpdateBeleg(beleg);
         return(beleg.BelegId);
     }
 }
        private int AddBeleg(Beleg beleg)
        {
            FillCommandParameter(AddBelegCmd, beleg);
            int newId = (int)AddBelegCmd.ExecuteScalar();

            beleg.BelegId = newId;
            beleg.Positionen.ForEach((p) => {
                p.BelegId         = beleg.BelegId;
                int posId         = SaveBelegPosition(beleg.BelegId, p);
                p.BelegpositionId = posId;
            });
            return(beleg.BelegId);
        }
Exemple #26
0
        public static async Task <Beleg> GetBeleg(string user, int belegnummer)
        {
            // Parameter prüfen
            if (string.IsNullOrWhiteSpace(user))
            {
                throw new ArgumentNullException(nameof(user));
            }

            Beleg result = await WebRequester.HttpGet <Beleg>(
                serviceBaseUrl,
                string.Format("/{0}/{1}", user, belegnummer));

            return(result);
        }
        public void MultipleMatchedShouldChangeAll()
        {
            Beleg backend1 = createBeleg(Beleg.StatusEnum.ABGELEHNT);
            Beleg local1   = createBeleg(Beleg.StatusEnum.ERFASST);

            database.StoreBeleg(local1).Wait();
            Beleg backend2 = createBeleg(Beleg.StatusEnum.GEBUCHT);
            Beleg local2   = createBeleg(Beleg.StatusEnum.ERFASST);

            backend2.Belegnummer = 2;
            local2.Belegnummer   = 2;
            Assert.AreEqual(2, helper.DoRefreshStatus(new Beleg[] { backend1, backend2 }, new Beleg[] { local1, local2 }).Result);
            Beleg[] result = database.GetBelege().Result;
            Assert.AreEqual(2, result.Length, result.ToString());
            Assert.AreEqual(backend1.Status, result[0].Status);
            Assert.AreEqual(backend2.Status, result[1].Status);
        }
Exemple #28
0
        public void TestObjektbaum()
        {
            Mitarbeiter m = new Mitarbeiter();

            m.Vorname  = "Test";
            m.Nachname = "Objektbaum";
            Reise r = new Reise();

            r.Zweck = "Reisezweck";
            Beleg b = new Beleg("Taxi", 30.4);

            r.AddKostenpunkt(b);
            m.Hinzufuegen(r);

            Assert.AreEqual(NDOObjectState.Transient, m.NDOObjectState, "Mitarbeiter muss Transient sein");
            Assert.AreEqual(NDOObjectState.Transient, r.NDOObjectState, "Reise muss Transient sein");
            Assert.AreEqual(NDOObjectState.Transient, b.NDOObjectState, "Beleg muss Transient sein");


            pm.MakePersistent(m);

            Assert.AreEqual(NDOObjectState.Created, m.NDOObjectState, "Mitarbeiter muss Created sein");
            Assert.AreEqual(NDOObjectState.Created, r.NDOObjectState, "Reise muss Created sein");
            Assert.AreEqual(NDOObjectState.Created, b.NDOObjectState, "Beleg muss Created sein");

            pm.Save();

            Assert.AreEqual(NDOObjectState.Persistent, m.NDOObjectState, "1 Mitarbeiter muss Persistent sein");
            Assert.AreEqual(NDOObjectState.Persistent, r.NDOObjectState, "1 Reise muss Persistent sein");
            Assert.AreEqual(NDOObjectState.Persistent, b.NDOObjectState, "1 Beleg muss Persistent sein");

            pm.UnloadCache();

            NDOQuery <Mitarbeiter> q = new NDOQuery <Mitarbeiter>(pm, null);

            m = (Mitarbeiter)q.ExecuteSingle(true);
            Assert.AreEqual(1, m.Reisen.Count, "Reise nicht gefunden");
            r = (Reise)m.Reisen[0];
            Assert.AreEqual(1, r.Kostenpunkte.Count, "Kostenpunkt nicht gefunden");
            b = (Beleg)r.Kostenpunkte[0];
            double k = b.Kosten;

            Assert.AreEqual(NDOObjectState.Persistent, m.NDOObjectState, "2 Mitarbeiter muss Persistent sein");
            Assert.AreEqual(NDOObjectState.Persistent, r.NDOObjectState, "2 Reise muss Persistent sein");
            Assert.AreEqual(NDOObjectState.Persistent, b.NDOObjectState, "2 Beleg muss Persistent sein");
        }
        private void UpdateBeleg(Beleg beleg)
        {
            UpdateBelegkopf(beleg);
            // bestehende Positionen aktualisieren bzw. neue Positionen hinzufügen
            beleg.Positionen.ForEach((p) => {
                SaveBelegPosition(beleg.BelegId, p);
            });
            // entfernte Positionen lokalisieren und aus Beleg entfernen
            List <Belegposition> altePos = FindBelegPositionenByBelegId(beleg.BelegId);

            altePos.ForEach(ap => {
                if (beleg.Positionen.Where(pos => pos.BelegpositionId == ap.BelegpositionId).Count() == 0)
                {
                    RemoveBelegPositionById(ap.BelegpositionId);
                }
            });
        }
Exemple #30
0
        public async Task <int> CreateBeleg(string user, Beleg beleg)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = this.baseUri;

            var json    = JsonConvert.SerializeObject(beleg);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            var response = await client.PostAsync($"belegerfassung-ui/rest/belege/{user}", content);

            var responseContent = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <IntWrapper>(responseContent);

            return(result.Value.Value);
        }