Beispiel #1
0
 public static string CreateTimeActivity(ApiUser hdUser, Instance_Config instanceConfig, int qb_employee_id, int qb_customer_id, int qb_service_id, decimal hours, decimal hourly_rate, string notes,
                                         DateTime date, int timeLogID, bool isProjectLog, bool is_billable, DateTime?start_date, DateTime?stop_date, decimal hoursOffset, int timeActivityID, int qb_sync_token, bool overwrite_changes, int qb_vendor_id, bool is_rate_fixed)
 {
     return(QuickBooks.CreateTimeActivity(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret,
                                          qb_employee_id, qb_customer_id, qb_service_id, hours, hourly_rate, notes, date, timeLogID, isProjectLog, is_billable, start_date, stop_date, (double)hoursOffset, timeActivityID,
                                          qb_sync_token, overwrite_changes, qb_vendor_id, is_rate_fixed));
 }
Beispiel #2
0
 ///<summary>Returns true if a deposit was created OR if the user clicked continue anyway on pop up.</summary>
 private bool CreateDepositQB(string depositAccount, string incomeAccount, double amount, string memo, bool allowContinue)
 {
     try {
         Cursor.Current = Cursors.WaitCursor;
         QuickBooks.CreateDeposit(DepositAccountsQB[comboDepositAccount.SelectedIndex]
                                  , IncomeAccountsQB[comboIncomeAccountQB.SelectedIndex], DepositCur.Amount, memo);
         Cursor.Current = Cursors.Default;
         MsgBox.Show(this, "Deposit successfully sent to QuickBooks.");
         butSendQB.Enabled = false;              //Don't let user send same deposit more than once.
     }
     catch (Exception ex) {
         Cursor.Current = Cursors.Default;
         if (allowContinue)
         {
             if (MessageBox.Show(ex.Message + "\r\n\r\nA deposit has not been created in QuickBooks, continue anyway?", "QuickBooks Deposit Create Failed", MessageBoxButtons.YesNo) != DialogResult.Yes)
             {
                 return(false);
             }
         }
         else
         {
             MessageBox.Show(ex.Message, "QuickBooks Deposit Create Failed");
             return(false);
         }
     }
     return(true);
 }
Beispiel #3
0
 public static string CreateExpense(ApiUser hdUser, Instance_Config instanceConfig, int qb_employee_id, int qb_customer_id, int qb_service_id, int qb_account_id, bool qb_is_employee,
                                    decimal amount, string notes, string note_internal, DateTime date, bool is_billable, int markup, string expense_id, int qb_expense_id, int qb_sync_token, bool overwrite_changes, int qb_vendor_id,
                                    int travel_id)
 {
     return(QuickBooks.CreateExpense(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, qb_employee_id, qb_customer_id,
                                     qb_service_id, qb_account_id, qb_is_employee, amount, notes, note_internal, date, is_billable, markup, expense_id, qb_expense_id, qb_sync_token, overwrite_changes, qb_vendor_id, travel_id));
 }
Beispiel #4
0
        private void FillGridQB()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableChartOfAccountsQB", "Description"), 200);

            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //Get the list of accounts from QuickBooks.
            Cursor.Current = Cursors.WaitCursor;
            List <string> accountList = new List <string>();

            try {
                accountList = QuickBooks.GetListOfAccounts();
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
            Cursor.Current = Cursors.Default;
            for (int i = 0; i < accountList.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(accountList[i]);
                row.Tag = accountList[i];
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Beispiel #5
0
        public static string CreateBill(ApiUser User, Instance_Config instanceConfig, int bill_id)
        {
            string result = QuickBooks.CreateBill(User.OrganizationId, User.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey,
                                                  instanceConfig.QBoAuthSecret, bill_id);

            if (result != "ok")
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
            return(result);
        }
Beispiel #6
0
        public static QBInvoice CreateInvoice(ApiUser User, Instance_Config instanceConfig, int invoice_id)
        {
            QBInvoice qbInvoice;
            string    result = QuickBooks.CreateInvoice(User.OrganizationId, User.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey,
                                                        instanceConfig.QBoAuthSecret, invoice_id, out qbInvoice);

            if (result != "ok")
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
            return(qbInvoice);
        }
Beispiel #7
0
        private void butConnectQB_Click(object sender, EventArgs e)
        {
            if (textCompanyFileQB.Text.Trim() == "")
            {
                MsgBox.Show(this, "Browse to your QuickBooks company file first.");
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            string result = QuickBooks.TestConnection(textCompanyFileQB.Text);

            Cursor.Current = Cursors.Default;
            MessageBox.Show(result);
        }
Beispiel #8
0
        public static QBCustomer CreateCustomer(ApiUser User, Instance_Config instanceConfig, int account_id)
        {
            QBCustomer qbCustomer;
            string     result = QuickBooks.CreateCustomer(User.OrganizationId, User.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey,
                                                          instanceConfig.QBoAuthSecret, account_id, out qbCustomer);

            if (result == "ok")
            {
                return(qbCustomer);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
Beispiel #9
0
        public static QBEmployee CreateEmployee(ApiUser User, Instance_Config instanceConfig, int user_id)
        {
            QBEmployee qbEmployee;
            string     result = QuickBooks.CreateEmployee(User.OrganizationId, User.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey,
                                                          instanceConfig.QBoAuthSecret, user_id, out qbEmployee);

            if (result == "ok")
            {
                return(qbEmployee);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
Beispiel #10
0
 public static void UnlinkQuickBooksTravel(ApiUser hdUser, int travel_id)
 {
     QuickBooks.UnlinkQuickBooksTravel(hdUser.OrganizationId, hdUser.DepartmentId, travel_id);
 }
Beispiel #11
0
 public static void UnlinkQuickBooksExpense(ApiUser hdUser, string expenseID)
 {
     QuickBooks.UnlinkQuickBooksExpense(hdUser.OrganizationId, hdUser.DepartmentId, expenseID);
 }
Beispiel #12
0
 public static void DeleteQuickBooksExpense(ApiUser hdUser, Instance_Config instanceConfig, string expenseID)
 {
     QuickBooks.DeleteAndUnlinkExpense(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, expenseID);
 }
Beispiel #13
0
        ///<summary>Saves the selected rows to database.  MUST close window after this.</summary>
        private bool SaveToDB()
        {
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            //Prevent backdating----------------------------------------------------------------------------------------
            DateTime date = PIn.Date(textDate.Text);

            if (IsNew)
            {
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            else
            {
                //We enforce security here based on date displayed, not date entered
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            DepositCur.DateDeposit = PIn.Date(textDate.Text);
            //amount already handled.
            DepositCur.BankAccountInfo = PIn.String(textBankAccountInfo.Text);
            if (IsNew)
            {
                if (gridPat.SelectedIndices.Length + gridIns.SelectedIndices.Length > 18)
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "No more than 18 items will fit on a QuickBooks deposit slip. Continue anyway?"))
                    {
                        return(false);
                    }
                }
                Deposits.Insert(DepositCur);
                if (Accounts.DepositsLinked() && DepositCur.Amount > 0)
                {
                    if (PrefC.GetInt(PrefName.AccountingSoftware) == (int)AccountingSoftware.QuickBooks)
                    {
                        //Create a deposit within QuickBooks.
                        try {
                            Cursor.Current = Cursors.WaitCursor;
                            QuickBooks.CreateDeposit(DepositAccountsQB[comboDepositAccount.SelectedIndex]
                                                     , PrefC.GetString(PrefName.QuickBooksIncomeAccount), DepositCur.Amount);
                            Cursor.Current = Cursors.Default;
                        }
                        catch (Exception ex) {
                            Cursor.Current = Cursors.Default;
                            if (MessageBox.Show(ex.Message + "\r\n\r\nA deposit has not been created in QuickBooks, continue anyway?", "QuickBooks Deposit Create Failed", MessageBoxButtons.YesNo) != DialogResult.Yes)
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        //create a transaction here
                        Transaction trans = new Transaction();
                        trans.DepositNum = DepositCur.DepositNum;
                        trans.UserNum    = Security.CurUser.UserNum;
                        Transactions.Insert(trans);
                        //first the deposit entry
                        JournalEntry je = new JournalEntry();
                        je.AccountNum     = DepositAccounts[comboDepositAccount.SelectedIndex];
                        je.CheckNumber    = Lan.g(this, "DEP");
                        je.DateDisplayed  = DepositCur.DateDeposit;                     //it would be nice to add security here.
                        je.DebitAmt       = DepositCur.Amount;
                        je.Memo           = Lan.g(this, "Deposit");
                        je.Splits         = Accounts.GetDescript(PrefC.GetLong(PrefName.AccountingIncomeAccount));
                        je.TransactionNum = trans.TransactionNum;
                        JournalEntries.Insert(je);
                        //then, the income entry
                        je            = new JournalEntry();
                        je.AccountNum = PrefC.GetLong(PrefName.AccountingIncomeAccount);
                        //je.CheckNumber=;
                        je.DateDisplayed  = DepositCur.DateDeposit;                     //it would be nice to add security here.
                        je.CreditAmt      = DepositCur.Amount;
                        je.Memo           = Lan.g(this, "Deposit");
                        je.Splits         = Accounts.GetDescript(DepositAccounts[comboDepositAccount.SelectedIndex]);
                        je.TransactionNum = trans.TransactionNum;
                        JournalEntries.Insert(je);
                    }
                }
            }
            else
            {
                Deposits.Update(DepositCur);
            }
            if (IsNew)            //never allowed to change or attach more checks after initial creation of deposit slip
            {
                for (int i = 0; i < gridPat.SelectedIndices.Length; i++)
                {
                    PatPayList[gridPat.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    Payments.Update(PatPayList[gridPat.SelectedIndices[i]], false);
                }
                for (int i = 0; i < gridIns.SelectedIndices.Length; i++)
                {
                    ClaimPayList[gridIns.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    ClaimPayments.Update(ClaimPayList[gridIns.SelectedIndices[i]]);
                }
            }
            if (IsNew)
            {
                SecurityLogs.MakeLogEntry(Permissions.DepositSlips, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " New " + DepositCur.Amount.ToString("c"));
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " " + DepositCur.Amount.ToString("c"));
            }
            return(true);
        }
Beispiel #14
0
 public static void UnlinkQuickBooksCustomer(ApiUser hdUser, int account_id)
 {
     QuickBooks.UnlinkQuickBooksCustomer(hdUser.OrganizationId, hdUser.DepartmentId, account_id);
 }
Beispiel #15
0
 public static void DeleteQuickBooksCustomer(ApiUser hdUser, Instance_Config instanceConfig, int account_id)
 {
     QuickBooks.DeleteAndUnlinkCustomer(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, account_id);
 }
Beispiel #16
0
 public static void UnlinkQuickBooksBill(ApiUser hdUser, int bill_id)
 {
     QuickBooks.UnlinkQuickBooksBill(hdUser.OrganizationId, hdUser.DepartmentId, bill_id, true);
 }
Beispiel #17
0
 public static void UnlinkQuickBooksTimeActivity(ApiUser hdUser, int timeLogID, bool isProjectLog)
 {
     QuickBooks.UnlinkQuickBooksTimeActivity(hdUser.OrganizationId, hdUser.DepartmentId, timeLogID, isProjectLog);
 }
Beispiel #18
0
 public static void UpdateData(ApiUser User, int userID, int qb_employee_id, int accountID, int qb_customer_id,
                               int taskTypeID, int qb_service_id, int qb_vendor_id)
 {
     QuickBooks.UpdateData(User.OrganizationId, User.DepartmentId, userID, qb_employee_id, accountID, qb_customer_id, taskTypeID,
                           qb_service_id, qb_vendor_id);
 }
Beispiel #19
0
 public static void DeleteQuickBooksEmployee(ApiUser hdUser, Instance_Config instanceConfig, int userID)
 {
     QuickBooks.DeleteAndUnlinkEmployee(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, userID);
 }
Beispiel #20
0
 public static void DeleteQuickBooksService(ApiUser hdUser, Instance_Config instanceConfig, int task_type_id)
 {
     QuickBooks.DeleteAndUnlinkService(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, task_type_id);
 }
Beispiel #21
0
 public static void DeleteQuickBooksTravel(ApiUser hdUser, Instance_Config instanceConfig, int travel_id)
 {
     QuickBooks.DeleteAndUnlinkTravel(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, travel_id);
 }
Beispiel #22
0
 public static void DeleteQuickBooksTimeActivity(ApiUser hdUser, Instance_Config instanceConfig, int timeLogID, bool isProjectLog)
 {
     QuickBooks.DeleteAndUnlinkTimeActivity(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, timeLogID, isProjectLog);
 }
Beispiel #23
0
 public static void UnlinkQuickBooksInvoice(ApiUser hdUser, int invoice_id)
 {
     QuickBooks.UnlinkQuickBooksInvoice(hdUser.OrganizationId, hdUser.DepartmentId, invoice_id);
 }
Beispiel #24
0
 public static void UnlinkQuickBooksEmployee(ApiUser hdUser, int userID)
 {
     QuickBooks.UnlinkQuickBooksEmployee(hdUser.OrganizationId, hdUser.DepartmentId, userID);
 }
Beispiel #25
0
 public static void UnlinkQuickBooksService(ApiUser hdUser, int task_type_id)
 {
     QuickBooks.UnlinkQuickBooksService(hdUser.OrganizationId, hdUser.DepartmentId, task_type_id);
 }