Exemple #1
0
        public void GetBudgetForUpdate_Returns_UpdateBudgetCommand_Type()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseSqlite(connection)
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new ApplicationDbContext(options))
            {
                context.Database.EnsureCreated();
                context.Budgets.AddRange(
                    new UserBudget {
                    BudgetId = 1, Owner = "Sofia", UserId = "123"
                }
                    );
                context.SaveChanges();
            }

            // Use a separate instance edit some data
            using (var context = new ApplicationDbContext(options))
            {
                var service = new BudgetService(context);

                UpdateBudgetCommand obj = service.GetBudgetForUpdate(1);

                Assert.NotNull(obj);
                Assert.Equal("Sofia", obj.Owner);
                Assert.Equal("123", obj.UserId);
                Assert.NotEqual("Linda", obj.Owner);
            }
        }
Exemple #2
0
 public BudgetController(BudgetService service, IHttpContextAccessor accessor)
 {
     _service  = service;
     _accessor = accessor;
     wx        = new WxHelper(_accessor.HttpContext);
     userInfo  = wx.CheckAndGetUserInfo();
 }
Exemple #3
0
        public void GetBudgetsBrief_CanLoadBudgetsFromContext()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseSqlite(connection)
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new ApplicationDbContext(options))
            {
                context.Database.EnsureCreated();
                context.Budgets.AddRange(
                    new UserBudget {
                    Name = "General_house", UserId = "234"
                },
                    new UserBudget {
                    Name = "Traveling", Amount = 700, UserId = "45"
                });
                context.SaveChanges();
            }

            // Use a separate instance of the context to verify correct data was saved to database
            using (var context = new ApplicationDbContext(options))
            {
                var service = new BudgetService(context);
                var budgets = service.GetBudgets("45");

                Assert.NotNull(budgets);
                Assert.Equal(1, budgets.Count);
            }
        }
Exemple #4
0
        public void UpdateBudget_CanLoadUpdateBudgetType()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseSqlite(connection)
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new ApplicationDbContext(options))
            {
                context.Database.EnsureCreated();
                context.Budgets.AddRange(
                    new UserBudget {
                    BudgetId = 1, Owner = "Sofia"
                },
                    new UserBudget {
                    BudgetId = 2, Name = "Camilla"
                });
                context.SaveChanges();
            }

            // Use a separate instance edit some data
            using (var context = new ApplicationDbContext(options))
            {
                var service = new BudgetService(context);

                UpdateBudgetCommand toUpdate = service.GetBudgetForUpdate(2);

                Assert.NotNull(toUpdate);
            }
        }
        /// <summary>
        /// Creates the budget.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>The new budget.</returns>
        public Budget CreateBudget(AdWordsUser user)
        {
            using (BudgetService budgetService =
                       (BudgetService)user.GetService(AdWordsService.v201806.BudgetService))
            {
                Budget budget = new Budget()
                {
                    name   = "Budget #" + ExampleUtilities.GetRandomString(),
                    amount = new Money()
                    {
                        microAmount = 50000000L
                    },
                    deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD
                };

                BudgetOperation budgetOperation = new BudgetOperation()
                {
                    @operator = Operator.ADD,
                    operand   = budget
                };

                return(budgetService.mutate(new BudgetOperation[]
                {
                    budgetOperation
                }).value[0]);
            }
        }
        public ActionResult Edit(int id)
        {
            BudgetService budgetService = new BudgetService();

            Guid userid = Guid.Parse(User.Identity.GetUserId());

            var budget = new SelectList(budgetService.GetBudgets(userid), "BudgetId", "BudgetName");

            ViewBag.Budgets = budget;

            CategoryService categoryService = new CategoryService(userid);

            var category = new SelectList(categoryService.GetCategories(), "CategoryId", "Name");

            ViewBag.Categories = category;

            var service = CreateTransactionService();
            var detail  = service.GetTransactionById(id);
            var model   =
                new TransactionEdit
            {
                TransactionId   = detail.TransactionId,
                BudgetId        = detail.BudgetId,
                MerchantName    = detail.MerchantName,
                Amount          = detail.Amount,
                TransactionDate = detail.TransactionDate,
                CategoryId      = detail.CategoryId,
            };

            return(View(model));
        }
Exemple #7
0
        /// <summary>
        /// Creates the budget.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <returns>The newly created budget.</returns>
        private static Budget CreateBudget(AdWordsUser user)
        {
            using (BudgetService budgetService =
                       (BudgetService)user.GetService(AdWordsService.v201705.BudgetService)) {
                // Create the campaign budget.
                Budget budget = new Budget();
                budget.name               = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString();
                budget.deliveryMethod     = BudgetBudgetDeliveryMethod.STANDARD;
                budget.amount             = new Money();
                budget.amount.microAmount = 500000;

                BudgetOperation budgetOperation = new BudgetOperation();
                budgetOperation.@operator = Operator.ADD;
                budgetOperation.operand   = budget;

                try {
                    BudgetReturnValue budgetRetval = budgetService.mutate(
                        new BudgetOperation[] { budgetOperation });
                    Budget newBudget = budgetRetval.value[0];
                    Console.WriteLine("Budget with ID = '{0}' and name = '{1}' was created.",
                                      newBudget.budgetId, newBudget.name);
                    return(newBudget);
                } catch (Exception e) {
                    throw new System.ApplicationException("Failed to add budget.", e);
                }
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="trialId">Id of the trial to be graduated.</param>
        public void Run(AdWordsUser user, long trialId)
        {
            // Get the TrialService and BudgetService.
            TrialService trialService = (TrialService)user.GetService(
                AdWordsService.v201605.TrialService);
            BudgetService budgetService = (BudgetService)user.GetService(
                AdWordsService.v201605.BudgetService);

            try {
                // To graduate a trial, you must specify a different budget from the
                // base campaign. The base campaign (in order to have had a trial based
                // on it) must have a non-shared budget, so it cannot be shared with
                // the new independent campaign created by graduation.
                Budget budget = new Budget()
                {
                    name   = "Budget #" + ExampleUtilities.GetRandomString(),
                    amount = new Money()
                    {
                        microAmount = 50000000L
                    },
                    deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD
                };

                BudgetOperation budgetOperation = new BudgetOperation()
                {
                    @operator = Operator.ADD,
                    operand   = budget
                };

                // Add budget.
                long budgetId = budgetService.mutate(
                    new BudgetOperation[] { budgetOperation }).value[0].budgetId;

                Trial trial = new Trial()
                {
                    id       = trialId,
                    budgetId = budgetId,
                    status   = TrialStatus.GRADUATED
                };

                TrialOperation trialOperation = new TrialOperation()
                {
                    @operator = Operator.SET,
                    operand   = trial
                };

                // Update the trial.
                trial = trialService.mutate(new TrialOperation[] { trialOperation }).value[0];

                // Graduation is a synchronous operation, so the campaign is already
                // ready. If you promote instead, make sure to see the polling scheme
                // demonstrated in AddTrial.cs to wait for the asynchronous operation
                // to finish.
                Console.WriteLine("Trial ID {0} graduated. Campaign ID {1} was given a new budget " +
                                  "ID {1} and is no longer dependent on this trial.", trial.id, trial.trialCampaignId,
                                  budgetId);
            } catch (Exception e) {
                throw new System.ApplicationException("Failed to graduate trial.", e);
            }
        }
Exemple #9
0
        public void TestBudgetCreateViewModelCancel()
        {
            ILoggerFactory loggerFactory = new LoggerFactory();

            using (var sqliteMemoryWrapper = new SqliteMemoryWrapper())
            {
                var currencyFactory   = new CurrencyFactory();
                var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true);
                currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity);

                var budgetService = new BudgetService(
                    loggerFactory,
                    sqliteMemoryWrapper.DbContext);

                var viewModel = new BudgetCreateViewModel(
                    loggerFactory,
                    budgetService,
                    new Mock <IBudgetTransactionListViewModelFactory>().Object
                    );

                viewModel.Name = "My First Budget";
                viewModel.CancelCommand.Execute(this);

                List <Budget> budgets = budgetService.GetAll().ToList();

                Assert.AreEqual(0, budgets.Count);
            }
        }
 public AccountPage(BankAccountService bankAccountService, BudgetService budgetService)
 {
     InitializeComponent();
     this.bankAccountService = bankAccountService;
     this.budgetService      = budgetService;
     LoadData();
 }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> validationResult = new List <ValidationResult>();

            if (string.IsNullOrWhiteSpace(this.Code))
            {
                validationResult.Add(new ValidationResult("Code is required", new List <string> {
                    "code"
                }));
            }

            if (string.IsNullOrWhiteSpace(this.Name))
            {
                validationResult.Add(new ValidationResult("Name is required", new List <string> {
                    "name"
                }));
            }

            if (validationResult.Count.Equals(0))
            {
                /* Service Validation */
                BudgetService service = (BudgetService)validationContext.GetService(typeof(BudgetService));

                if (service.DbContext.Set <Budget>().Count(r => r._IsDeleted.Equals(false) && r.Id != this.Id && r.Code.Equals(this.Code)) > 0) /* Code Unique */
                {
                    validationResult.Add(new ValidationResult("Code already exists", new List <string> {
                        "code"
                    }));
                }
            }

            return(validationResult);
        }
Exemple #12
0
 public BudgetControllerMock(IUserService userService  = null,
                             ILogService loggerService = null, BudgetService budgetservice    = null,
                             IUnitOfWork unitOfWork    = null, IProductService productService = null, IDeliverableService deliverableService = null,
                             IDeliverableServiceV2 deliverableServiceV2 = null, IPropertyService propertyService = null)
     : base(userService, loggerService, budgetservice, unitOfWork, productService, deliverableService, deliverableServiceV2, propertyService)
 {
 }
Exemple #13
0
        private BudgetService CreateService()
        {
            var userID  = Guid.Parse(User.Identity.GetUserId());
            var service = new BudgetService(userID);

            return(service);
        }
Exemple #14
0
        public long CreateBudget(AdWordsUser user)
        {
            BudgetService budgetService =
                (BudgetService)user.GetService(AdWordsService.v201705.BudgetService);

            // Create the campaign budget.
            Budget budget = new Budget();

            budget.name = "Interplanetary Cruise Budget #" + DateTime.Now.ToString(
                "yyyy-MM-dd HH:mm:ss.ffffff");
            budget.deliveryMethod     = BudgetBudgetDeliveryMethod.STANDARD;
            budget.amount             = new Money();
            budget.amount.microAmount = 500000;
            budget.isExplicitlyShared = false;

            BudgetOperation budgetOperation = new BudgetOperation();

            budgetOperation.@operator = Operator.ADD;
            budgetOperation.operand   = budget;

            BudgetReturnValue budgetRetval = budgetService.mutate(
                new BudgetOperation[] { budgetOperation });

            return(budgetRetval.value[0].budgetId);
        }
Exemple #15
0
        public void CreateTest_when_exist_record_should_update_budget()
        {
            this._budgetService = new BudgetService(_budgetRepositoryStub);

            var budgetFromDb = new Budgets {
                Amount = 999, YearMonth = "2017-02"
            };

            _budgetRepositoryStub.Read(Arg.Any <Func <Budgets, bool> >())
            .ReturnsForAnyArgs(budgetFromDb);

            var model = new BudgetAddViewModel {
                Amount = 2000, Month = "2017-02"
            };

            var wasUpdated = false;

            this._budgetService.Updated += (sender, args) => { wasUpdated = true; };

            this._budgetService.Create(model);

            _budgetRepositoryStub.Received()
            .Save(Arg.Is <Budgets>(x => x == budgetFromDb && x.Amount == 2000));


            Assert.IsTrue(wasUpdated);
        }
Exemple #16
0
        public void SetUp()
        {
            _budgetFactory = A.Fake <IBudgetFactory>();
            _repository    = A.Fake <IRepository <Budget> >();

            _sut = new BudgetService(_budgetFactory, _repository);
        }
    /// <summary>
    /// Creates the budget for the campaign.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <returns>The budget.</returns>
    private Budget CreateBudget(AdWordsUser user) {
      // Get the BudgetService.
      using (BudgetService budgetService =
          (BudgetService) user.GetService(AdWordsService.v201802.BudgetService)) {

        // Create the campaign budget.
        Budget budget = new Budget {
          name = "Interplanetary Cruise App Budget #" + ExampleUtilities.GetRandomString(),
          deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD,
          amount = new Money {
            microAmount = 5000000
          },

          // Universal app campaigns don't support shared budgets.
          isExplicitlyShared = false
        };

        BudgetOperation budgetOperation = new BudgetOperation {
          @operator = Operator.ADD,
          operand = budget
        };

        BudgetReturnValue budgetRetval = budgetService.mutate(
          new BudgetOperation[] { budgetOperation });
        Budget newBudget = budgetRetval.value[0];

        Console.WriteLine("Budget with ID = '{0}' and name = '{1}' was created.",
            newBudget.budgetId, newBudget.name);
        return newBudget;
      }
    }
        /// <summary>
        /// Creates the budget for the campaign.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <returns>The budget instance.</returns>
        private static Budget CreateBudget(AdWordsUser user)
        {
            using (BudgetService budgetService =
                       (BudgetService)user.GetService(AdWordsService.v201806.BudgetService)) {
                // Create the campaign budget.
                Budget budget = new Budget {
                    name           = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(),
                    deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD,
                    amount         = new Money {
                        microAmount = 500000
                    }
                };

                BudgetOperation budgetOperation = new BudgetOperation {
                    @operator = Operator.ADD,
                    operand   = budget
                };

                try {
                    BudgetReturnValue budgetRetval = budgetService.mutate(
                        new BudgetOperation[] { budgetOperation });
                    return(budgetRetval.value[0]);
                } catch (Exception e) {
                    throw new System.ApplicationException("Failed to add shared budget.", e);
                }
            }
        }
        /// <summary>
        /// Creates an explicit budget to be used only to create the Campaign.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="name">The budget name.</param>
        /// <param name="amount">The budget amount.</param>
        /// <returns>The budget object.</returns>
        private Budget CreateSharedBudget(AdWordsUser user, string name, long amount)
        {
            using (BudgetService budgetService =
                       (BudgetService)user.GetService(AdWordsService.v201806.BudgetService))
            {
                // Create a shared budget
                Budget budget = new Budget
                {
                    name   = name,
                    amount = new Money
                    {
                        microAmount = amount
                    },
                    deliveryMethod     = BudgetBudgetDeliveryMethod.STANDARD,
                    isExplicitlyShared = true
                };

                // Create operation.
                BudgetOperation operation = new BudgetOperation
                {
                    operand   = budget,
                    @operator = Operator.ADD
                };

                // Make the mutate request.
                return(budgetService.mutate(new BudgetOperation[]
                {
                    operation
                }).value[0]);
            }
        }
Exemple #20
0
        public static Budget CreateBudget(AdWordsUser user, CampaignLo campaignDto)
        {
            using (BudgetService budgetService =
                       (BudgetService)user.GetService(AdWordsService.v201710.BudgetService))
            {
                // Create the campaign budget.
                Budget budget = new Budget();
                budget.isExplicitlyShared = false;
                budget.name               = campaignDto.Budget.Name;
                budget.deliveryMethod     = BudgetBudgetDeliveryMethod.STANDARD;
                budget.amount             = new Money();
                budget.amount.microAmount = campaignDto.Budget.MicroAmount;


                BudgetOperation budgetOperation = new BudgetOperation();
                budgetOperation.@operator = Operator.ADD;
                budgetOperation.operand   = budget;

                try
                {
                    BudgetReturnValue budgetRetval = budgetService.mutate(
                        new BudgetOperation[] { budgetOperation });
                    return(budgetRetval.value[0]);
                }
                catch (Exception e)
                {
                    throw new System.ApplicationException("Failed to add budget.", e);
                }
            }
        }
        /// <summary>
        /// Creates the budget for the campaign.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <returns>The budget.</returns>
        private Budget CreateBudget(AdWordsUser user)
        {
            // [START createBudget] MOE:strip_line
            // Get the BudgetService.
            BudgetService budgetService =
                (BudgetService)user.GetService(AdWordsService.v201609.BudgetService);

            // Create the campaign budget.
            Budget budget = new Budget();

            budget.name               = "Interplanetary Cruise App Budget #" + ExampleUtilities.GetRandomString();
            budget.deliveryMethod     = BudgetBudgetDeliveryMethod.STANDARD;
            budget.amount             = new Money();
            budget.amount.microAmount = 5000000;

            // Universal app campaigns don't support shared budgets.
            budget.isExplicitlyShared = false;

            BudgetOperation budgetOperation = new BudgetOperation();

            budgetOperation.@operator = Operator.ADD;
            budgetOperation.operand   = budget;

            BudgetReturnValue budgetRetval = budgetService.mutate(
                new BudgetOperation[] { budgetOperation });
            // [END createBudget] MOE:strip_line
            Budget newBudget = budgetRetval.value[0];

            Console.WriteLine("Budget with ID = '{0}' and name = '{1}' was created.",
                              newBudget.budgetId, newBudget.name);
            return(newBudget);
        }
Exemple #22
0
        public BudgetControllerTest()
        {
            ContextOptions = new DbContextOptionsBuilder <SkrillaDbContext>()
                             .UseSqlite(CreateInMemoryDatabase())
                             .Options;

            _connection = RelationalOptionsExtension.Extract(ContextOptions).Connection;

            dbContext = new SkrillaDbContext(ContextOptions);
            dbContext.Database.EnsureDeleted();
            dbContext.Database.EnsureCreated();

            category  = new Category("ExampleCategory", false, "mockUser", "exampleIcon");
            category2 = new Category("ExampleCategory2", false, "mockUser", "exampleIcon");

            dbContext.Add(category);
            dbContext.Add(category2);
            dbContext.SaveChanges();

            List <BudgetItemRequest> budgetItems = new List <BudgetItemRequest>
            {
                new BudgetItemRequest
                {
                    category = category.CategoryId,
                    amount   = 23.5
                },

                new BudgetItemRequest
                {
                    category = category2.CategoryId,
                    amount   = 101.5
                }
            };

            budgetRequest = new BudgetRequest
            {
                StartDate   = new DateTime(2019, 05, 06),
                EndDate     = new DateTime(2030, 04, 17),
                Amount      = 123.5,
                BudgetItems = budgetItems
            };

            var budgetLoggerMock     = new Mock <ILogger <BudgetService> >();
            var controllerLoggerMock = new Mock <ILogger <BudgetController> >();

            budgetService = new BudgetService(budgetLoggerMock.Object,
                                              dbContext,
                                              GetMockHttpAccesor());

            controller = new BudgetController(controllerLoggerMock.Object, budgetService);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = principal
                }
            };
        }
 public SalaryAddingWindow(int accountID, BudgetService budgetService, AccountPage mainWindow)
 {
     this.budgetService = budgetService;
     this.accountID     = accountID;
     this.mw            = mainWindow;
     InitializeComponent();
     InitializeData();
 }
Exemple #24
0
        // GET: Budget
        public ActionResult Index()
        {
            var userID  = Guid.Parse(User.Identity.GetUserId());
            var service = new BudgetService(userID);
            var model   = service.GetBudgets();

            return(View(model));
        }
Exemple #25
0
        public void InserUpdate_CanUpdate()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseSqlite(connection)
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new ApplicationDbContext(options))
            {
                context.Database.EnsureCreated();
                Expense exp1 = new Expense();
                exp1.Amount = 300;
                exp1.Name   = "hotel";
                List <Expense> explist = new List <Expense>();
                explist.Add(exp1);
                context.Budgets.AddRange(
                    new UserBudget {
                    BudgetId = 1, Owner = "Sofia"
                },
                    new UserBudget {
                    BudgetId = 2, Name = "Camilla", Expenses = explist
                });
                context.SaveChanges();
            }

            // Use a separate instance edit some data
            using (var context = new ApplicationDbContext(options))
            {
                var service = new BudgetService(context);

                Expense exp1 = new Expense();
                exp1.Amount = 2;
                exp1.Name   = "milk";
                List <Expense> explist = new List <Expense>();
                explist.Add(exp1);
                //explist.Add(exp2);
                var user1 = new UserBudget
                {
                    BudgetId = 1,
                    Owner    = "Bob",
                    Expenses = explist
                };

                service.InsertOrUpdateBudget(user1);

                var budget   = service.GetBudget(1);
                var expenses = budget.Expenses.ToArray();

                Assert.NotNull(budget);
                Assert.NotNull(budget.Expenses);
                Assert.Equal("milk", expenses[0].Name);
                Assert.NotEqual("Sofia", budget.Owner);
                Assert.Equal("Bob", budget.Owner);
            }
        }
 public void SetUp()
 {
     _dateProvider  = new TestDateProvider();
     _budgetService = new BudgetService(_dateProvider);
     _budget        = new Budget(
         new DateTime(2019, 02, 1),
         new DateTime(2019, 02, 5),
         500.00);
 }
Exemple #27
0
        public void SetUp()
        {
            _budgetFactory      = A.Fake <IBudgetFactory>();
            _budgetRepository   = A.Fake <IRepository <Budget> >();
            _templateRepository = A.Fake <IRepository <BudgetTemplate> >();
            _accountRepository  = A.Fake <IRepository <Account> >();

            _sut = new BudgetService(_budgetFactory, _budgetRepository, _templateRepository, _accountRepository);
        }
 public BudgetApiController(
     BudgetService service,
     ILogger <BudgetApiController> log,
     IAuthorizationService authService,
     UserManager <ApplicationUser> userManager)
 {
     _budgetService = service;
     _log           = log;
     _userManager   = userManager;
 }
 public HomeController(
     BudgetService service,
     UserManager <ApplicationUser> userService,
     IAuthorizationService authService,
     ILogger <HomeController> log)
 {
     _service     = service;
     _userService = userService;
     _authService = authService;
     _log         = log;
 }
        public void CreateTest_should_invoke_repository_one_time()
        {
            this._budgetService = new BudgetService(_budgetRepositoryStub);
            var model = new BudgetAddViewModel {
                Amount = 2000, Month = "2017-02"
            };

            this._budgetService.Create(model);
            _budgetRepositoryStub.Received()
            .Save(Arg.Is <Budget>(x => x.Amount == 2000 && x.YearMonth == "2017-02"));
        }
    /// <summary>
    /// Creates an explicit budget to be used only to create the Campaign.
    /// </summary>
    /// <param name="budgetService">The budget service.</param>
    /// <param name="name">The budget name.</param>
    /// <param name="amount">The budget amount.</param>
    /// <returns>The budget object.</returns>
    private Budget CreateSharedBudget(BudgetService budgetService, String name, long amount) {
      // Create a shared budget
      Budget budget = new Budget();
      budget.name = name;
      budget.period = BudgetBudgetPeriod.DAILY;
      budget.amount = new Money();
      budget.amount.microAmount = amount;
      budget.deliveryMethod = BudgetBudgetDeliveryMethod.STANDARD;
      budget.isExplicitlyShared = true;

      // Create operation.
      BudgetOperation operation = new BudgetOperation();
      operation.operand = budget;
      operation.@operator = Operator.ADD;

      // Make the mutate request.
      return budgetService.mutate(new BudgetOperation[] {operation}).value[0];
    }