Refund payment and the customer's balance

eugene.k's Avatar


01 Dec, 2014 12:58 PM

Hello, guys. Again. When jBilling creates the payment using PaymentBL class, it uses
  // may be this is a refund
        if (dto.getIsRefund() == 1) {
            // now all refunds have balance = 0
            // todo refund balance is always set to ZERO
            LOG.debug("dto of paymentDTOEX contains "+dto);
            if (dto.getPayment() != null) {
                LOG.debug("Refund is linked to some payment "+dto.getPayment());
                // this refund is link to a payment
                PaymentBL linkedPayment = new PaymentBL(dto.getPayment().getId());

So, refund payment always has zero balance.

On the other hand jBilling calculates customer's balance due to the next lines:

    public BigDecimal findTotalBalanceByUser(Integer userId) {
        //user's payments which are not refunds
        Criteria criteria = getSession().createCriteria(PaymentDTO.class);
        criteria.add(Restrictions.eq("deleted", 0))
            .createAlias("baseUser", "u")
            .add(Restrictions.eq("", userId))
            .add(Restrictions.eq("isRefund", 0));
        BigDecimal paymentBalances = (criteria.uniqueResult() == null ? BigDecimal.ZERO : (BigDecimal) criteria.uniqueResult());

        //calculate refunds
        Criteria criteria2 = getSession().createCriteria(PaymentDTO.class);
        criteria2.add(Restrictions.eq("deleted", 0))
                .createAlias("baseUser", "u")
                    .add(Restrictions.eq("", userId))
                    .add(Restrictions.eq("isRefund", 1));
        BigDecimal refunds= criteria2.uniqueResult() == null ? BigDecimal.ZERO : (BigDecimal) criteria2.uniqueResult();

        return paymentBalances.subtract(refunds);

As I can see refund calculation looks through balance of the each refund. It causes the situation when refund does not affect customer's balance. Please explain me why should it or it should not affect the balance and if not how can we see refund in the customer's balance? Thank you!

  1. Support Staff 1 Posted by Technical Suppo... on 21 Jan, 2015 09:28 AM

    Technical Support's Avatar

    Please let us know about the version details of the jbilling software you are using.
    and please let us know the scenario about what you are doing.

    Thank you ,
    Technical Support Team

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac