Ejemplo n.º 1
0
        private void Window_ContentRendered()
        {
            var invoiceCollection = invoiceData.GetAllInvoices();
            var invoice           = ConfigureAutoMapper().Map <IEnumerable <InvoiceModelUI> >(invoiceCollection.Data);

            string message  = "A aparut o eroare in baza de date!!";
            string message1 = "Nu a fost gasit niciun rezultat";

            if (invoiceCollection.Count > 0)
            {
                foreach (var item in invoice)
                {
                    Invoices.Add(item);
                }
            }
            else if (!string.IsNullOrEmpty(invoiceCollection.Error))
            {
                MsgBox.Show(message, "Eroare de executie", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                MsgBox.Show(message1, " ", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            HideProgressBar();
        }
Ejemplo n.º 2
0
        private void SeeDebitList(bool?value)
        {
            if (value == false)
            {
                InternalCommands.UpdateInvoiceList.Execute(null);
                return;
            }

            if (Invoices != null)
            {
                Invoices.Clear();
            }
            else
            {
                Invoices = new ObservableCollection <InvoiceListItemViewModel>();
            }
            _dataService.GetDebitList().Subscribe(i =>
            {
                if (i == null)
                {
                    return;
                }
                foreach (var invoiceListItemView in i)
                {
                    Invoices.Add(new InvoiceListItemViewModel(invoiceListItemView, _dataService));
                }
            });
        }
Ejemplo n.º 3
0
        public Invoice Update(Invoice invoice)
        {
            var invoiceFound = Invoices.FirstOrDefault(a => a.ID == invoice.ID);

            if (invoiceFound == null)
            {
                Invoices.Add(invoice);
                SaveChanges();
                return(invoice);
            }
            invoiceFound.AccountID     = invoice.AccountID;
            invoiceFound.Type          = invoice.Type;
            invoiceFound.Status        = invoice.Status;
            invoiceFound.EntryDate     = invoice.EntryDate;
            invoiceFound.ReferenceDate = invoice.ReferenceDate;
            invoiceFound.PaymentDate   = invoice.PaymentDate;
            invoiceFound.Value         = invoice.Value;
            invoiceFound.Fees          = invoice.Fees;
            invoiceFound.Fines         = invoice.Fines;
            invoiceFound.Amount        = invoice.Amount;
            invoiceFound.Description   = invoice.Description;
            invoiceFound.ModifyUserID  = invoice.ModifyUserID;
            invoiceFound.ModifyDate    = DateTime.Now;;
            SaveChanges();
            return(invoiceFound);
        }
Ejemplo n.º 4
0
        private void ExecuteEditInvoiceCompleted(InvoiceListItemView obj)
        {
            var invoiceLine = Invoices.SingleOrDefault(i => i.Id == obj.ID);

            if (invoiceLine == null)
            {
                Invoices.Add(new InvoiceListItemViewModel(obj, _dataService));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a list of invoices and then adds them to the invoices list
        /// </summary>
        public async void GetInvoices()
        {
            Repository repository = new Repository();

            App.Current.Dispatcher.Invoke(() =>
            {
                Invoices.Clear();
            });
            await foreach (Invoice invoice in repository.GetInvoicesForOrderAsync(SelectedOrder.OrderId))
            {
                App.Current.Dispatcher.Invoke(() =>
                {
                    Invoices.Add(invoice);
                });
            }
        }
Ejemplo n.º 6
0
        public virtual Invoice AddInvoice(DateTime invoiceDate, DateTime invoiceStartDate, DateTime invoiceEndDate, double invoiceFee)
        {
            var invoice = new Invoice();
            // Rate. Could probaply extract this some more.
            var yearFraction = this.DayCounter.GetYearFraction(invoiceStartDate, invoiceEndDate);
            var fractionRate = yearFraction * this.InterestRate / 100.0d;

            invoice.Interest = Math.Round(this.GetInterest(fractionRate), 2, MidpointRounding.AwayFromZero);

            var leftForPrincipal = this.GetPrincipal(invoice.Interest);

            invoice.Principal   = (leftForPrincipal <= this.CurrentPrincipal) ? leftForPrincipal : this.CurrentPrincipal;
            invoice.Principal   = Math.Round(invoice.Principal, 2, MidpointRounding.AwayFromZero);
            invoice.InvoiceDate = invoiceDate;
            invoice.InvoiceFee  = invoiceFee;
            Invoices.Add(invoice);
            return(invoice);
        }
Ejemplo n.º 7
0
        private async void LoadAllData()
        {
            using (UserDialogs.Instance.Loading("Đang tải"))
            {
                var invoiceRes = await invoiceService.GetInvoices(UserInfoSetting.UserInfos.PhongId);

                if (invoiceRes == null)
                {
                    UserDialogs.Instance.Alert("Có lỗi khi tải thông tin phiếu thu");
                    return;
                }
                Invoices.Clear();
                foreach (var item in invoiceRes)
                {
                    Invoices.Add(item);
                }
                CalculateHeight();
            }
        }
Ejemplo n.º 8
0
        private void OnAddInvoiceCommand()
        {
            InvoiceWindow window = new InvoiceWindow();

            bool?result = window.ShowDialog();

            if (result == true)
            {
                Invoice invoice = (window.DataContext as InvoiceWindowViewModel).Invoice;

                if (invoice != null)
                {
                    int maxId = 0;
                    if (Invoices.Count != 0)
                    {
                        maxId = Invoices.Select(x => x.Id).Max();
                    }
                    invoice.Id = maxId + 1;
                    Invoices.Add(invoice);
                }
            }
        }
Ejemplo n.º 9
0
        async Task ExecuteLoadInvoicesCommand()
        {
            IsBusy = true;

            try
            {
                this.Invoices.Clear();
                var invoices = await InvoiceInteractor.All();//await DataStore.GetInvoicesAsync(true);

                foreach (var invoice in invoices)
                {
                    Invoices.Add(invoice);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 10
0
        public void addInvoice(Invoice invoice)
        {
            List <Invoice> Invoices = new List <Invoice>();;

            Invoices = Deserialize(InvoiceFilePath) as List <Invoice>;

            if (Invoices != null)
            {
                InvoiceId += Invoices.Count() + 1;
            }
            else
            {
                Invoices   = new List <Invoice>();
                InvoiceId += 1;
            }
            invoice.Id = InvoiceId;
            Invoices.Add(invoice);

            Stream write = File.Open(InvoiceFilePath, FileMode.Create);

            Serializer.Serialize(write, Invoices);
            write.Close();
        }
Ejemplo n.º 11
0
        private void Listener_ScanerEvent(ScanerHook.ScanerCodes codes)
        {
            string[] content = codes.Result.ToString().Split(',');
            try
            {
                DateTime dateTime;
                if (!DateTime.TryParseExact(content[5], "yyyy/M/ddHH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
                {
                    DateTime.TryParseExact(content[5], "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime);
                }

                InputInvoice invoice = new InputInvoice()
                {
                    InvoiceCode      = content[2],
                    InvoiceNumber    = content[3],
                    Date             = dateTime,
                    RecDate          = DateTime.Now,
                    Verification     = content[6],
                    AcctId           = Information.AccountantId,
                    PersonId         = Properties.Settings.Default.PersonId,
                    VerificationCode = (content.Length == 8)?content[7] : null
                };
                decimal amount = 0;
                //invoice.AcctId = Information.AccountantId;
                //invoice.PersonId = Properties.Settings.Default.PersonId;
                using (var db = new DataModel())
                {
                    invoice.PersonName = db.Persons.Where(p => p.PersonId == invoice.PersonId).FirstOrDefault().PersonName;
                }
                if (decimal.TryParse(content[4], out amount))
                {
                    invoice.Amount = amount;
                }
                if (Invoices.Any(i => i.InvoiceNumber == invoice.InvoiceNumber && i.InvoiceCode == invoice.InvoiceCode))
                {
                    string time = DateTime.Now.ToString("HH:mm:ss");
                    ScanMessage = time + "  该发票已扫描,等待入库!";

                    //MessageBox.Show("该发票已经扫描等待入库", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    using (var db = new DataModel())
                    {
                        if (db.Invoices.Any(a => a.InvoiceNumber == invoice.InvoiceNumber && a.InvoiceCode == invoice.InvoiceCode))
                        {
                            string time = DateTime.Now.ToString("HH:mm:ss");
                            ScanMessage = time + "  该发票已经报销过!";
                            //MessageBox.Show("该发票已经报销过", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                        else
                        {
                            string time = DateTime.Now.ToString("HH:mm:ss");
                            ScanMessage = time + "  发票扫描成功!";
                            Message     = $"发票代码: {invoice.InvoiceCode} 发票号码: {invoice.InvoiceNumber} 税前金额: {invoice.Amount} " +
                                          $"发票日期: {invoice.Date.ToString("yyyy年MM月dd日")}";
                            invoice.AcctName    = db.Accountants.Where(o => o.AccountantId == Information.AccountantId).FirstOrDefault().Person.PersonName;
                            invoice.VerifyState = "未校验";
                            Invoices.Add(invoice);
                            InputCount = Invoices.Count;
                            BtnEnableJudgement();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ScanMessage = "非正常发票数据";
            }
        }
Ejemplo n.º 12
0
        async Task ExecuteAddInvoiceCommandAsync()
        {




            double total = 0.0;
            try
            {
                IsBusy = true;
                // 1. Add camera logic.
                await CrossMedia.Current.Initialize();

                MediaFile photo;
                if (CrossMedia.Current.IsCameraAvailable)
                {
                    photo = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                    {

                     
                        Directory = "Sample",
                        Name = "test.jpg"
                    });
                }
                else
                {
                    photo = await CrossMedia.Current.PickPhotoAsync();
                }

                if (photo == null)
                {
                    PrintStatus("Photo was null :(");
                    return;
                }



                await MakeRequestAsync();


                //// 2. Add  OCR logic.
                //OcrResults text;

                //var client = new VisionServiceClient("15e5da6a012448ef86fa94dc7e20480b");

                //using (var stream = photo.GetStream())
                //    text = await client.RecognizeTextAsync(stream);

                //var numbers = from region in text.Regions
                //              from line in region.Lines
                //              from word in line.Words
                //              where word?.Text?.Contains("$") ?? false
                //              select word.Text.Replace("$", string.Empty);


                //double temp = 0.0;
                //total = numbers?.Count() > 0 ?
                //        numbers.Max(x => double.TryParse(x, out temp) ? temp : 0) :
                //        0;



                //PrintStatus($"Found total {total.ToString("C")} " +
                //    $"and we had {text.Regions.Count()} regions");


                // 3. Add to data-bound collection.
                Invoices.Add(new Invoice
                {
                    Total = total,
                    Photo = photo.Path,
                    TimeStamp = DateTime.Now
                });
            }
            catch (Exception ex)
            {
                await (Application.Current?.MainPage?.DisplayAlert("Error",
                    $"Something bad happened: {ex.Message}", "OK") ??
                    Task.FromResult(true));

                PrintStatus(string.Format("ERROR: {0}", ex.Message));

            }
            finally
            {
                IsBusy = false;
            }

        }
Ejemplo n.º 13
0
 public void AddInvoice(object attachment)
 {
     Invoices.Add((XmlDocumentAttachment)attachment);
 }
Ejemplo n.º 14
0
        async Task ExecuteAddInvoiceCommandAsync()
        {
            try
            {
                IsBusy = true;
                // 1. Add camera logic.
                await CrossMedia.Current.Initialize();

                MediaFile photo;
                if (CrossMedia.Current.IsCameraAvailable)
                {
                    photo = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                    {
                        Directory = "Receipts",
                        Name      = "Receipt"
                    });
                }
                else
                {
                    photo = await CrossMedia.Current.PickPhotoAsync();
                }

                if (photo == null)
                {
                    PrintStatus("Photo was null :(");
                    return;
                }


                byte[] data = ReadFully(photo.GetStream());

                using (var client = new HttpClient())
                {
                    using (var content = new MultipartFormDataContent())
                    {
                        var fileContent = new ByteArrayContent(data);
                        fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") // attachment?
                        {
                            Name     = "file",                                                                  // required?
                            FileName = "test.jpg"
                        };
                        content.Add(fileContent);
                        //IsBusy = false;

                        var requestUri = "http://at-dev-vm-zxpapi-01.westus.cloudapp.azure.com/v1.0/groups/1/receipts";
                        //var requestUri = "http://requestb.in/11y6k4z1";
                        var response = await client.PostAsync(requestUri, content);

                        if (response.IsSuccessStatusCode)
                        {
                            string result = await response.Content.ReadAsStringAsync();

                            APIResponse apiResponse = JsonConvert.DeserializeObject <APIResponse>(result);

                            using (var clientML = new HttpClient())
                            {
                                string temp = apiResponse.Receipt_Url.Replace("https", "http");

                                var scoreRequest = new
                                {
                                    Inputs = new Dictionary <string, List <Dictionary <string, string> > >()
                                    {
                                        {
                                            "input1",
                                            new List <Dictionary <string, string> >()
                                            {
                                                new Dictionary <string, string>()
                                                {
                                                    //{ "Category", "" },
                                                    { "Url", temp },
                                                }
                                            }
                                        },
                                    },
                                    GlobalParameters = new Dictionary <string, string>()
                                    {
                                    }
                                };

                                var jsonToSend = JsonConvert.SerializeObject(scoreRequest);
                                var body       = new StringContent(jsonToSend, Encoding.UTF8, "application/json");

                                const string apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Replace this with the API key for the web service
                                clientML.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
                                clientML.BaseAddress = new Uri("https://xxx.services.azureml.net/subscriptions/xxxxxxxxx/services/xxxxxxx/execute?api-version=2.0&format=swagger");

                                var responseML = await clientML.PostAsync("", body);

                                if (responseML.IsSuccessStatusCode)
                                {
                                    string resultML = await responseML.Content.ReadAsStringAsync();

                                    // Convert JSON to object
                                    MLResponse obj = JsonConvert.DeserializeObject <MLResponse>(resultML);

                                    var outPuts = new List <MLOutputItem>(6);

                                    outPuts.Add(new MLOutputItem {
                                        Category = "Clothes and Accessories", Probability = (float)obj.Results.Output[0].ClothesAndAccessoriesProbability
                                    });
                                    outPuts.Add(new MLOutputItem {
                                        Category = "Daily Snacks", Probability = (float)obj.Results.Output[0].DailySnacksProbability
                                    });
                                    outPuts.Add(new MLOutputItem {
                                        Category = "Dining Out", Probability = (float)obj.Results.Output[0].DiningOutProbability
                                    });
                                    outPuts.Add(new MLOutputItem {
                                        Category = "Entertainment", Probability = (float)obj.Results.Output[0].EntertainmentProbability
                                    });
                                    outPuts.Add(new MLOutputItem {
                                        Category = "Fuel", Probability = (float)obj.Results.Output[0].FuelProbability
                                    });
                                    outPuts.Add(new MLOutputItem {
                                        Category = "Groceries", Probability = (float)obj.Results.Output[0].GroceriesProbability
                                    });

                                    outPuts = outPuts.OrderByDescending(x => x.Probability).ToList();

                                    Invoices.Add(new Invoice
                                    {
                                        ScoredLabel1 = outPuts[0].Category + " : " + outPuts[0].Probability,
                                        ScoredLabel2 = outPuts[1].Category + " : " + outPuts[1].Probability,
                                        ScoredLabel3 = outPuts[2].Category + " : " + outPuts[2].Probability,
                                        Photo        = photo.Path,
                                        TimeStamp    = DateTime.Now
                                    });
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                IsBusy = false;
            }
        }
 public void AddInvoice(Invoice invoice)
 {
     Invoices.Add(invoice);
 }
Ejemplo n.º 16
0
 public Invoice CreateNewInvoice(Invoice newInvoice)
 {
     Invoices.Add(newInvoice);
     return(newInvoice);
 }
 public void AddInvoice([MarshalAs(UnmanagedType.IDispatch)] object invoice)
 {
     Invoices.Add((InvoiceForCorrectionInfo)invoice);
 }