Examples of CreditPaths


Examples of org.zeroexchange.mcredit.CreditPaths

     */
    @Override
    @Transactional(rollbackFor = DebtRotingException.class)
    public CreditPaths roteDebt(CreditPaths originalTwoPartnerPaths,
            BigDecimal value) throws DebtRotingException {
        CreditPaths twoPartnerPaths = null;
        try {
            twoPartnerPaths = (CreditPaths) originalTwoPartnerPaths.clone();
        } catch (CloneNotSupportedException e) {
            //Should never happen
        }
        BigDecimal rest = value;
        for(CreditPath path: twoPartnerPaths.getPaths()) {
            if(value.compareTo(BigDecimal.ZERO) <= 0) {
                break;
            }
            BigDecimal valueToMove = rest;
            BigDecimal pathAvailableAmount = creditLineReader.getAvailableAmount(path.getPath());
View Full Code Here

Examples of org.zeroexchange.mcredit.CreditPaths

     */
    @Override
    public List<CreditPaths> findPaths(User debtor, Collection<User> creditors, BigDecimal requiredValue) {
        List<CreditPaths> paths = new ArrayList<CreditPaths>();
        for(User creditor: creditors) {
            CreditPaths twoUsersPaths = new CreditPaths();
            find2UsersPaths(debtor, creditor, twoUsersPaths, new LinkedList<CreditLine>());
            if(!twoUsersPaths.isEmpty()) {
                twoUsersPaths.setCreditor(creditor);
                twoUsersPaths.setDebtor(debtor);
                paths.add(twoUsersPaths);
            }
        }
        return paths;
    }
View Full Code Here

Examples of org.zeroexchange.mcredit.CreditPaths

        Collection<CreditLine> creditLines = path.getPath();
        creditLines.add(l1);
        creditLines.add(l2);
        creditLines.add(l3);
       
        CreditPaths paths = new CreditPaths();
        paths.setPaths(Collections.singletonList(path));
       
        try {
            paths = creditLineWriter.roteDebt(paths, BigDecimal.ONE);
            path = paths.getPaths().iterator().next();
            for(CreditLine nextLine: path.getPath()) {
                Assert.assertTrue(BigDecimal.ONE.equals(nextLine.getCurrentCredit()));
            }
            Assert.assertTrue(new BigDecimal(9).equals(
                    creditLineReader.getAvailableAmount(path.getPath().iterator().next())));
View Full Code Here

Examples of org.zeroexchange.mcredit.CreditPaths

            @Override
            public void populateItem(
                    Item<ICellPopulator<CreditPaths>> cellItem,
                    String componentId, IModel<CreditPaths> rowModel) {
                CreditPaths twoPartnersPaths = rowModel.getObject();
                User creditor = twoPartnersPaths.getCreditor();
                cellItem.add(new Label(componentId, creditor == null ? "???" : creditor.getDisplayName()));
            }
        });
       
        //Available amount
        columns.add(new AbstractColumn<CreditPaths, String>(new ResourceModel(MKEY_MAX_AMOUNT)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<CreditPaths>> cellItem, String componentId,
                    IModel<CreditPaths> rowModel) {
                CreditPaths twoPartnersPaths = rowModel.getObject();
                BigDecimal maxAmount = BigDecimal.ZERO;
                for(CreditPath path: twoPartnersPaths.getPaths()) {
                    maxAmount = maxAmount.add(creditLineReader.getAvailableAmount(path.getPath()));
                }
                cellItem.add(new Label(componentId, maxAmount.toString()));
            }

        });
       
        //Number of paths between two partners
        columns.add(new AbstractColumn<CreditPaths, String>(new ResourceModel(MKEY_PATHS_COUNT)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<CreditPaths>> cellItem, String componentId,
                    IModel<CreditPaths> rowModel) {
                CreditPaths twoPartnersPaths = rowModel.getObject();
                cellItem.add(new Label(componentId, String.valueOf(twoPartnersPaths.getPaths().size())));
            }
        });
       
        //Amount input column
        columns.add(new AbstractColumn<CreditPaths, String>(new ResourceModel(MKEY_AMOUNT)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<CreditPaths>> cellItem, String componentId,
                    final IModel<CreditPaths> rowModel) {
                final CreditPaths twoPartnersPathsContainer = rowModel.getObject();
               
                cellItem.add(new AttributeAppender("style", ";width:110px;"));//TODO: constant
                cellItem.add(new AjaxEditorLink<BigDecimal>(componentId,  new Model<BigDecimal>(BigDecimal.ZERO)) {
                    private static final long serialVersionUID = 1L;
                    private NumberTextField<BigDecimal> amountInput;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.