Package org.internna.ossmoney.model

Examples of org.internna.ossmoney.model.Bill


      createBill(period, description, amount, due, payee, locale.split("_"), subcategory);
      return dashboard.index(modelMap);
    }

    protected void createBill(RECURRING_INTERVAL period, String description, Double amount, Date due, Long payee, String[] locale, Long subcategory) {
      Bill bill = new Bill();
      bill.setPeriod(period);
      bill.setAmount(amount);
      bill.setLastTrigger(due);
      bill.setDescription(description);
      bill.setPayee(Payee.findPayee(payee));
      bill.setOwner(UserDetails.findCurrentUser());
      bill.setCurrency(new Locale(locale[0], locale[1], ""));
      bill.setCategory(Subcategory.findSubcategory(subcategory));
      bill.persist();
    }
View Full Code Here


    }

    @RequestMapping("/pay/{id}")
    public String pay(@PathVariable Long id, ModelMap modelMap) {
      UserDetails user = UserDetails.findCurrentUser();
      Bill bill = Bill.findBill(id);
      if (bill.belongsTo(user)) {
        modelMap.addAttribute("bill", bill);
        modelMap.addAttribute("origin", user.getBankAccounts(bill.getCurrency()));
        modelMap.addAttribute("currency", Currency.getInstance(bill.getCurrency()).getCurrencyCode());
      }
      return "bills/pay";
    }
View Full Code Here

    }

    @RequestMapping(value = "/pay", method = RequestMethod.POST)
    public String pay(Long id, Long origin, Double amount, Date operationDate, ModelMap modelMap) {
      UserDetails user = UserDetails.findCurrentUser();
      Bill bill = Bill.findBill(id);
      if (bill.belongsTo(user)) {
        accountService.payBill(user, bill, origin, amount, operationDate);
      }
      return dashboard.index(modelMap);
    }
View Full Code Here

    }

    @Test
    public void testPayBill() {
      UserDetails user = UserDetails.findCurrentUser();
      Bill bill = new Bill();
      bill.setOwner(user);
      bill.setAmount(100D);
      bill.setCurrency(Locale.US);
      bill.setLastTrigger(new Date());
      bill.setPayee(Payee.findMySelf(user));
      bill.setPeriod(RECURRING_INTERVAL.MONTHLY);
      bill.setCategory(Subcategory.findSubcategory(1L));
      bill.setDescription("a bill");
      bill.persist();
      Account account = Account.findAccount(3L);
      int transactions = account.getTransactions().size();
      accountService.payBill(user, bill, 3L, 101D, new Date());
      assertNotNull("Bill updated", bill.getLastPayment());
      assertTrue("Transaction created", (transactions + 1) == account.getTransactions().size());
    }
View Full Code Here

TOP

Related Classes of org.internna.ossmoney.model.Bill

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.