Untitled

 avatar
unknown
plain_text
a year ago
2.2 kB
6
Indexable
public XSerializator ATM_AUT_Notes2Dispense_Currency(int montant, BigDecimal currencyId) {
    // ... (existing code)

    try {
        // ... (existing code)

        // Iterate through the cassettes
        for (XterminalComponent cassette : this.terminalCassetsList) {
            // Check if the cassette has the correct currency
            if (cassette.getComponentCurrency() != null && cassette.getComponentCurrency().equals(currencyId)) {
                // Check if the cassette has a positive value and is operational
                if (cassette.getComponentValue() != null &&
                    cassette.getComponentValue().intValueExact() > 0 &&
                    cassette.getComponentOperationalValue() != null &&
                    cassette.getComponentOperationalValue().intValueExact() > 0) {

                    // Calculate the number of notes to dispense from this cassette
                    int lToDist = remainder / cassette.getComponentValue().intValueExact();
                    if (lToDist > cassette.getComponentOperationalValue().intValueExact()) {
                        lToDist = cassette.getComponentOperationalValue().intValueExact();
                    }

                    // Update cassette and remaining amount
                    cassette.setComponentOperationalValue(cassette.getComponentOperationalValue().subtract(BigDecimal.valueOf((long) lToDist)));
                    totalNotes += lToDist;
                    remainder -= lToDist * cassette.getComponentValue().intValueExact();

                    // Update response attributes
                    String cassetteName = String.format("CASSETTE_%d", cassette.getComponentSubType().intValueExact());
                    sr_out.setAttribut(cassetteName, String.format("%02d", lToDist));

                    // Break if the requested amount has been dispensed
                    if (remainder <= 0) {
                        break;
                    }
                }
            }
        }

        // ... (remaining code)
    } catch (Throwable var17) {
        // ... (existing code)
    }

    // ... (existing code)
}
Editor is loading...
Leave a Comment