mohd-faraz

_blogs

// blogs / 20260622.md

Dev Log: June 22 Wrap-up

2026-06-22
#java#backend#refactoring#ui-design#billing

Overview

Today was all about making our invoicing system behave like it actually exists in the real world. I spent most of my time refining how we handle payments and restoring some CRM logic that seemed to have gone missing in a previous shuffle.

What I Worked On

More than just 'Paid' or 'Unpaid'

Up until now, our invoice status tracking was pretty bare-bones. But as anyone who's ever dealt with a bill knows, things are rarely that binary. I spent the morning expanding our status enums to include DRAFT, PARTIALLY_PAID, OVERDUE, and CANCELLED. It sounds like a small change, but it ripples through the whole system—especially when you have to decide exactly when an order transitions from 'Pending' to 'Processed'.

Refactoring the Payment Flow

I had to touch the logic that updates orders when an invoice gets paid. Previously, the method was only taking an ID, but I realized I needed the full invoice context to actually record how someone paid. I updated the helper methods to pass the full object so we can now capture the paymentMode and paymentReference directly into the payment schedules.

// Sanitized snippet of the logic update
private void syncStatusWithOrder(Context ctx, String orderId, InvoiceData invoice, STATUS status) {
    var order = OrderHelper.getById(orderId);
    if (order == null) return;

    var schedules = order.getSchedules();
    for (var schedule : schedules) {
        if (invoice.getId().equals(schedule.getLinkedId())) {
            schedule.updateStatus(status.toString());
            // Now we actually track the metadata
            schedule.setMetadata("mode", invoice.getPaymentMethod());
            schedule.setMetadata("ref", invoice.getTransactionRef());
        }
    }
}

The 'Mark Paid' Modal

On the frontend, I added a new modal for the billing module. Clicking 'Mark as Paid' shouldn't just be a blind toggle. Now, it triggers a UI prompt that asks the user for the payment method and reference number. It’s a simple quality-of-life improvement that ensures our data stays clean and searchable later on.

Restoring CRM Logic

I also had to do a bit of a 'rescue mission' on the CRM side. It looks like some of the BPMN integration logic—the stuff that handles automated workflow triggers when a customer is added—had been stripped out or reverted. I spent some time restoring those decorators and ensuring the process instances are firing off correctly again. Dealing with disappearing code is always a bit frustrating, but I'm glad I caught it before it caused a headache in production.

Wrapping Up

The invoicing flow feels a lot more robust now. Tomorrow, I’ll probably dive deeper into the overdue logic to see if we can automate some of those status transitions based on the calendar. Catch you then.