private async void AddOrderLine()
        {
            var invoiceAPI = UnicontaAPIManager.GetInvoiceAPI();
            var newOrder   = new DebtorOrder
            {
            };

            newOrder.SetMaster(this.selectedCustomer);

            var timeUsage = (DateTime.Now - this.startTime).TotalHours;

            if (timeUsage < 0.5)
            {
                timeUsage = 0.5;
            }

            var newOrderLines = new List <DebtorOrderLine>();
            var newOrderLine  = new DebtorOrderLine
            {
                _Text     = "Onsite",
                _Qty      = timeUsage,
                _Price    = 890,
                _Currency = Currencies.DKK,
            };

            newOrderLine.SetMaster(newOrder);
            newOrderLines.Add(newOrderLine);

            var invoiceresult = await invoiceAPI.PostInvoice(newOrder, newOrderLines, DateTime.Now, -1, false);

            if (invoiceresult.Err != ErrorCodes.Succes)
            {
            }
        }
Example #2
0
        private async void B_Customers_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var customers = CSVUtils.ParseCustomers(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Customers.csv");

            // Creating Insert List
            var newDebtorClients = new List <DebtorClient>();

            foreach (var customer in customers)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(customer.AccountNumber) + 20000).ToString();

                // TODO: Add the customer to the newDebtorClients List
            }
            ;

            // Calling insert API
            // TODO: Call the insert API to insert newDebtorClients
        }
Example #3
0
        public App()
        {
            UnicontaAPIManager.Initialize();

            InitializeComponent();
            Initialize();
        }
        private async void CB_Companies_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var company = this.GetSelectedCompany();
            await UnicontaAPIManager.SetCurrentCompany(company);

            LoadDebtors();
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var invoiceAPI = UnicontaAPIManager.GetInvoiceAPI();
            var debtor     = this.GetSelectedCustomer();

            // QuickInvoice
            var debtorOrder = new DebtorOrder
            {
            };

            debtorOrder.SetMaster(debtor);

            var debtorOrderLines = new List <DebtorOrderLine>();
            var debtorOrderLine  = new DebtorOrderLine
            {
            };

            debtorOrderLine.SetMaster(debtorOrder);
            debtorOrderLines.Add(debtorOrderLine);

            //TODO: Use new API
            var invoiceErrorCode = await invoiceAPI.PostInvoice(debtorOrder, debtorOrderLines, DateTime.Now, 0, false, null, null, true, false);

            if (invoiceErrorCode.Err != ErrorCodes.Succes)
            {
                return;
            }
        }
        private async void CB_Company_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Setting Company
            var company = this.CB_Company.SelectedItem as Company;
            await UnicontaAPIManager.SetCurrentCompany(company);

            this.LoadCustomers();
        }
        private async void LoadDebtors()
        {
            var crudAPI = UnicontaAPIManager.GetCrudAPI();
            var debtors = await crudAPI.Query <Debtor>();

            this.CB_Customers.ItemsSource  = debtors;
            this.CB_Customers.SelectedItem = debtors.FirstOrDefault();
        }
Example #8
0
        public MainWindow()
        {
            InitializeComponent();

            var user = UnicontaAPIManager.GetUser();

            this.TB_UserWelcome.Text = $"Welcome {user._Name}, you are now logged in";
        }
Example #9
0
        public MainWindow()
        {
            InitializeComponent();

            this.CB_Company.ItemsSource       = UnicontaAPIManager.GetCompanies();
            this.CB_Company.SelectedItem      = UnicontaAPIManager.GetCurrentCompany();
            this.CB_Company.SelectionChanged += CB_Company_SelectionChanged;
        }
        private async Task RefreshCustomers()
        {
            var crudAPI   = UnicontaAPIManager.GetCrudAPI();
            var customers = await crudAPI.Query <Debtor>();

            this.selectedCustomer       = customers.FirstOrDefault();
            CustomerPicker.ItemsSource  = customers;
            CustomerPicker.SelectedItem = this.selectedCustomer;
        }
        private async void LoadCustomers()
        {
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            // TODO: Query for debtors in the current Company

            this.CB_Customer.ItemsSource  = debtors;
            this.CB_Customer.SelectedItem = debtors.FirstOrDefault();
        }
Example #12
0
 private async void Initialize()
 {
     if (await UnicontaAPIManager.IsLoggedIn())
     {
         MainPage = new NavigationPage(new MainPage());
     }
     else
     {
         MainPage = new NavigationPage(new LoginPage());
     }
 }
Example #13
0
        // MenuPosition
        // 0 = General Ledger
        // 1 = Customer
        // 2 = Vendor
        // 3 = Inventory
        // 4 = Project
        // 5 = Company
        // 6 = Tools
        // 7 = None
        // 8 = CRM

        private async void Button_TrackGenres(object sender, RoutedEventArgs e)
        {
            //TODO: Change to test Company
            var company = UnicontaAPIManager.GetCompanyByName("TT-WEEK3");
            var crudAPI = UnicontaAPIManager.GetCrudAPI(company);

            // TrackGenres
            // TODO: Create a TableHeader with the TrackGenre

            // TODO: Call Insert API to insert the TrackGenere Table
        }
        public MainPage()
        {
            this.InitializeComponent();

            this.Initialize();

            this.TB_User.Text = UnicontaAPIManager.GetUserName();

            this.CB_Companies.ItemsSource       = UnicontaAPIManager.GetCompanies();
            this.CB_Companies.SelectedItem      = UnicontaAPIManager.GetCurrentCompany();
            this.CB_Companies.SelectionChanged += CB_Companies_SelectionChanged;
        }
        private async void CompanyPicker_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            var picker        = (Picker)sender;
            int selectedIndex = picker.SelectedIndex;

            if (selectedIndex == -1)
            {
                return;
            }

            var company = picker.ItemsSource[selectedIndex] as Company;
            await UnicontaAPIManager.SetCurrentCompany(company);

            await RefreshCustomers();
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var username = this.TB_Username.Text;
            var password = this.TB_Password.Text;

            var loginErrorCode = await UnicontaAPIManager.Login(username, password);

            if (loginErrorCode != ErrorCodes.Succes)
            {
                return;
            }

            await UnicontaAPIManager.InitializeCompanies();

            Frame.Navigate(typeof(MainPage));
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var loginErrorCode = await UnicontaAPIManager.Login(this.TB_Username.Text, this.PB_Password.Password);

            if (loginErrorCode != ErrorCodes.Succes)
            {
                MessageBox.Show("ERROR: Login Failed" + loginErrorCode.ToString());
                return;
            }

            await UnicontaAPIManager.InitializeCompanies();

            var window = new MainWindow();

            window.Show();
            window.Activate();
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var debtor     = this.CB_Customer.SelectedItem as DebtorClient;
            var invoiceAPI = UnicontaAPIManager.GetInvoiceAPI();

            // Creating DebtorOrder
            // TODO: Create a DebtorOrderClient + Master Relation

            // Creating DebtorOrderLine's
            var debtorOrderLines = new List <DebtorOrderLineClient>();

            // TODO: Create a DebtorOrderLineClient + Master Relation

            // Calling Invoice API.
            // TODO: Call InvoiceAPI with Post + Error Handle

            MessageBox.Show($"Invoice has been send InvoiceNumber:{invoiceResult.Header._InvoiceNumber}");
        }
Example #19
0
        private async void LoginButton_Clicked(object sender, System.EventArgs e)
        {
            var username = UsernameEntry.Text;
            var password = PasswordEntry.Text;

            var loginErrorCode = await UnicontaAPIManager.Login(username, password);

            if (loginErrorCode != ErrorCodes.Succes)
            {
                MessageLabel.Text  = $"Login failed {loginErrorCode.ToString()}";
                PasswordEntry.Text = string.Empty;
                return;
            }

            await UnicontaAPIManager.InitializeCompanies();

            await Navigation.PushAsync(new MainPage());
        }
Example #20
0
        private async void B_Customers_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var customers = CSVUtils.ParseCustomers(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Customers.csv");

            // Creating Insert List
            var newDebtorClients = new List <DebtorClient>();

            foreach (var customer in customers)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(customer.AccountNumber) + 20000).ToString();

                newDebtorClients.Add(new DebtorClient
                {
                    _Account  = accountNumber.ToString(),
                    _Name     = customer.AccountName,
                    _Address1 = customer.Address1,
                    _Address2 = customer.Address2,
                    _ZipCode  = customer.ZIP,
                    _Phone    = customer.Telephone
                });
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newDebtorClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import customers {errorCode.ToString()}");
            }
            else
            {
                MessageBox.Show("Import Completed");
            }
        }
        private async void Initialize()
        {
            // Saying hello to the current user
            WelcomeMessage.Text = $"Welcome {UnicontaAPIManager.GetCurrentUsername()}";

            // Creating CompanyPicker
            CompanyPicker.ItemDisplayBinding    = new Binding("Name");
            CompanyPicker.ItemsSource           = UnicontaAPIManager.GetCompanies();
            CompanyPicker.SelectedItem          = UnicontaAPIManager.GetCurrentCompany();
            CompanyPicker.SelectedIndexChanged += CompanyPicker_SelectedIndexChanged;

            // Create CustomerPicker
            CustomerPicker.ItemDisplayBinding    = new Binding("KeyName");
            CustomerPicker.SelectedIndexChanged += CustomerPicker_SelectedIndexChanged;

            // Create ToggleButton
            ToggleButton.Clicked += ToggleButton_Clicked;

            // Refreshing Data
            await RefreshCustomers();
        }
Example #22
0
        private async void B_Items_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var items = CSVUtils.ParseItems(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Items.csv");

            // Creating Insert List
            var newInvItemClients = new List <InvItemClient>();

            foreach (var item in items)
            {
                // TODO: Add the item to the newInvItemClients List
            }
            ;

            // Calling insert API
            // TODO: Call the insert API to insert newInvItemClients
        }
Example #23
0
        private async void B_Items_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var items = CSVUtils.ParseItems(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Items.csv");

            // Creating Insert List
            var newInvItemClients = new List <InvItemClient>();

            foreach (var item in items)
            {
                newInvItemClients.Add(new InvItemClient
                {
                    _Item        = item.Item,
                    _Name        = item.ItemName,
                    _SalesPrice1 = item.SalesPrice,
                    _Group       = "Grp1"
                });
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newInvItemClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import items {errorCode.ToString()}");
            }
            else
            {
                MessageBox.Show("Import Completed");
            }
        }
Example #24
0
        private async void Button_Tracks(object sender, RoutedEventArgs e)
        {
            //TODO: Change to test Company
            var company = UnicontaAPIManager.GetCompanyByName("TT-WEEK3");
            var crudAPI = UnicontaAPIManager.GetCrudAPI(company);

            // Tracks
            // TODO: Create a TableHeader with the Track

            // Inserting Table
            // TODO: Call Insert API to insert the Track Table

            // Creating Fields
            var tracksFields = new List <TableField>();

            // Title
            // TODO: Create a TableField for the Title

            // Artist
            // TODO: Create a TableField for the Artist

            // Genre
            // TODO: Create a TableField for the Genre

            // Vibe
            // TODO: Create a TableField for the Vibe

            // Length
            // TODO: Create a TableField for the Length

            // LicensePaid
            // TODO: Create a TableField for the LicensePaid

            // Inserting Fields
            // TODO: Call Insert API to insert the Track Fields
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var debtor     = this.CB_Customer.SelectedItem as DebtorClient;
            var invoiceAPI = UnicontaAPIManager.GetInvoiceAPI();

            // Creating DebtorOrder
            var debtorOrder = new DebtorOrderClient
            {
                _Currency = Currencies.DKK,
            };

            debtorOrder.SetMaster(debtor);

            // Creating DebtorOrderLine's
            var debtorOrderLines = new List <DebtorOrderLineClient>();
            var debtorOrderLine  = new DebtorOrderLineClient
            {
                _Item  = "OnSiteSupport",
                _Qty   = 2.0,
                _Price = 890,
            };

            debtorOrderLine.SetMaster(debtorOrder);
            debtorOrderLines.Add(debtorOrderLine);

            // Calling Invoice API.
            var invoiceResult = await invoiceAPI.PostInvoice(debtorOrder, debtorOrderLines, DateTime.Now, 0, false, SendEmail : true, Emails : "*****@*****.**", OnlyToThisEmail : true);

            if (invoiceResult.Err != ErrorCodes.Succes)
            {
                MessageBox.Show($"Failed to send invoice: {invoiceResult.Err.ToString()}");
                return;
            }

            MessageBox.Show($"Invoice has been send InvoiceNumber:{invoiceResult.Header._InvoiceNumber}");
        }
        // MenuPosition
        // 0 = General Ledger
        // 1 = Customer
        // 2 = Vendor
        // 3 = Inventory
        // 4 = Project
        // 5 = Company
        // 6 = Tools
        // 7 = None
        // 8 = CRM

        private async void Button_TrackGenres(object sender, RoutedEventArgs e)
        {
            //TODO: Change to test Company
            var company = UnicontaAPIManager.GetCompanyByName("TT-WEEK3");
            var crudAPI = UnicontaAPIManager.GetCrudAPI(company);

            // TrackGenres
            var trackGenres = new TableHeader
            {
                // Key
                _HasPrimaryKey = true,
                _PKprompt      = "TrackGenreId",
                _AutoKey       = true,

                // Description
                _Name          = "TrackGenres",
                _Prompt        = "Track Genres",
                _MenuPosition  = 3,
                _UserDefinedId = 2050,

                // Settings
                _EditLines = true
            };

            var errorCode = await crudAPI.Insert(trackGenres);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"Failed to insert Track Genres {errorCode.ToString()}");
                return;
            }
            else
            {
                MessageBox.Show("Track Genres table has been created");
            }
        }
Example #27
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     UnicontaAPIManager.Initialize();
 }
 public App()
 {
     UnicontaAPIManager.Initialize();
 }
Example #29
0
        private async void B_Orders_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var orders = CSVUtils.ParseOrders(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Orders.csv");

            // Creating SQLCache's
            // TODO: Create a customer (DebtorClient) SQLCache

            // TODO: Create a inventory (InvItemClient) SQLCache

            // Creating Insert List
            var newDebtorOrderClients = new List <DebtorOrderClient>();

            foreach (var order in orders)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(order.AccountNumber) + 20000).ToString();

                // Finding customer in cache
                // TODO: Use the customerCache to get the customer by accountNumber

                // TODO: Add the order to the newDebtorOrderClients List + SetMaster
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newDebtorOrderClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import orders {errorCode.ToString()}");
            }

            // Creating order lines
            var newDebtorOrderLineClients = new List <DebtorOrderLineClient>();
            var inventoryList             = inventoryCache.GetRecords as InvItemClient[];

            var index = 0;

            foreach (var debtorOrder in newDebtorOrderClients)
            {
                var orderItems = orders[index].Items;
                foreach (var item in orderItems)
                {
                    var inventoryItem = inventoryList.FirstOrDefault(i => i.Name == item.ItemName);

                    // TODO: Add the item to the newDebtorOrderLineClients List + SetMaster
                }
                ;

                index++;
            }
            ;

            // Calling insert API
            // TODO: Call the insert API to insert newDebtorOrderLineClients
        }
Example #30
0
        private async void B_Orders_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var orders = CSVUtils.ParseOrders(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Orders.csv");

            // Creating SQLCache's
            SQLCache customerCache = crudAPI.CompanyEntity.GetCache(typeof(DebtorClient));

            if (customerCache == null)
            {
                customerCache = await crudAPI.CompanyEntity.LoadCache(typeof(DebtorClient), crudAPI);
            }

            SQLCache inventoryCache = crudAPI.CompanyEntity.GetCache(typeof(InvItemClient));

            if (inventoryCache == null)
            {
                inventoryCache = await crudAPI.CompanyEntity.LoadCache(typeof(InvItemClient), crudAPI);
            }

            // Creating Insert List
            var newDebtorOrderClients = new List <DebtorOrderClient>();

            foreach (var order in orders)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(order.AccountNumber) + 20000).ToString();

                // Finding customer in cache
                var customer = customerCache.Get(accountNumber) as DebtorClient;

                var newDebtorOrderClient = new DebtorOrderClient
                {
                    _Created = order.CreatedDate
                };
                newDebtorOrderClient.SetMaster(customer);
                newDebtorOrderClients.Add(newDebtorOrderClient);
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newDebtorOrderClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import orders {errorCode.ToString()}");
            }

            // Creating order lines
            var newDebtorOrderLineClients = new List <DebtorOrderLineClient>();
            var inventoryList             = inventoryCache.GetRecords as InvItemClient[];

            var index = 0;

            foreach (var debtorOrder in newDebtorOrderClients)
            {
                var orderItems = orders[index].Items;
                foreach (var item in orderItems)
                {
                    var inventoryItem = inventoryList.FirstOrDefault(i => i.Name == item.ItemName);

                    var orderLine = new DebtorOrderLineClient
                    {
                        _Item  = inventoryItem.Item,
                        _Qty   = 1,
                        _Price = inventoryItem.SalesPrice1
                    };
                    orderLine.SetMaster(debtorOrder);
                    newDebtorOrderLineClients.Add(orderLine);
                }
                ;

                index++;
            }
            ;

            // Calling insert API
            var errorCode2 = await crudAPI.Insert(newDebtorOrderLineClients);

            if (errorCode2 != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import order lines {errorCode2.ToString()}");
            }
            else
            {
                MessageBox.Show("Import Completed");
            }
        }