示例#1
0
        public object Delete(QB_Expense_Delete request)
        {
            ApiUser         hdUser         = request.ApiUser;
            Instance_Config instanceConfig = new Instance_Config(hdUser);

            CheckQBOnlineIntegration(instanceConfig);
            bool is_travel = request.is_travel ?? false;

            if (request.is_unlink)
            {
                try
                {
                    if (is_travel)
                    {
                        QBExpenses.UnlinkQuickBooksTravel(hdUser, int.Parse(request.key));
                    }
                    else
                    {
                        QBExpenses.UnlinkQuickBooksExpense(hdUser, request.key);
                    }
                    return(new HttpResult("", HttpStatusCode.OK));
                }
                catch (Exception ex)
                {
                    throw new HttpError(Utils.ClearString(ex.Message));
                }
            }
            else
            {
                try
                {
                    if (is_travel)
                    {
                        QBExpenses.DeleteQuickBooksTravel(hdUser, instanceConfig, int.Parse(request.key));
                    }
                    else
                    {
                        QBExpenses.DeleteQuickBooksExpense(hdUser, instanceConfig, request.key);
                    }
                    return(new HttpResult("", HttpStatusCode.OK));
                }
                catch (Exception ex)
                {
                    throw new HttpError(Utils.ClearString(ex.Message));
                }
            }
        }
示例#2
0
        public object Put(QB_Expense_Update request)
        {
            ApiUser         hdUser         = request.ApiUser;
            Instance_Config instanceConfig = new Instance_Config(hdUser);

            CheckQBOnlineIntegration(instanceConfig);
            int travel_id = 0;

            if (request.travel_id.HasValue)
            {
                travel_id = request.travel_id.Value;
            }
            CheckExpenseAndUpdateQBAccount(hdUser, request.expense_id, request.qb_account_id, travel_id);
            string   notes             = "";
            string   note_internal     = "";
            int      qb_employee_id    = 0;
            int      qb_vendor_id      = 0;
            int      markup            = 0;
            DateTime date              = DateTime.Now;
            bool     overwrite_changes = false;

            if (request.overwrite_changes.HasValue)
            {
                overwrite_changes = request.overwrite_changes.Value;
            }
            if (request.notes != null)
            {
                notes = request.notes;
            }
            if (request.note_internal != null)
            {
                note_internal = request.note_internal;
            }
            if (request.qb_employee_id.HasValue)
            {
                qb_employee_id = request.qb_employee_id.Value;
            }
            if (request.qb_vendor_id.HasValue)
            {
                qb_vendor_id = request.qb_vendor_id.Value;
            }
            if (request.date.HasValue)
            {
                date = request.date.Value;
            }
            if (request.markup.HasValue)
            {
                markup = request.markup.Value;
            }
            bool qb_is_employee = request.qb_is_employee ?? false;
            bool is_billable    = request.is_billable ?? true;

            try
            {
                string result = QBExpenses.CreateExpense(hdUser, instanceConfig, qb_employee_id, request.qb_customer_id, request.qb_service_id, request.qb_account_id,
                                                         qb_is_employee, request.amount, notes, note_internal, date, is_billable, markup, request.expense_id, request.key, request.qb_sync_token, overwrite_changes, qb_vendor_id, travel_id);
                if (result == "ok")
                {
                    return(new HttpResult("", HttpStatusCode.OK));
                }
                else
                {
                    throw new HttpError(Utils.ClearString(result));
                }
            }
            catch (Exception ex)
            {
                throw new HttpError(Utils.ClearString(ex.Message));
            }
        }