The procedure below details how to calculate DBR days in IQ. This calculation is intended to parallel the chargeable days figure on the Operations and Accounting DBRs when the "DBR Day Method" setting in Edit Misc Control Fields is set to "N" or blank. Note that this procedure comes as close as possible to the CARS+ calculation, but may not exactly match it.

The procedure starts by calculating the total elapsed days and hours of the RA. Next, it takes multiplies the elapsed hours times the hourly rate and compares that product (the "hour charge") against the daily rate.

NOTE: The part of the procedure below that is highlighted in yellow assumes that all rates have 59 or 60 minutes (i.e., 1 hour) grace. If this is not the case, a different vale can be used. If the amount of grace varies widely be rate, the procedure should be enhanced to examine the amount of grace on a per-RA basis.

The text below can be pasted into any IQ procedure. The field DBR-DAYS is the chargeable days of the RA and that is the field to report.

# Calculation of DBR Days -------------
MOVE 0 TO ELAPS-DAYS.
MOVE 0 TO TMP-HOURS.
MOVE 0 TO ELAPS-HOURS.
MOVE 0 TO HOUR-CHARGE SCALE 3.3.
MOVE 0 TO PARTIAL-DAY SCALE 1.2.
MOVE 0 TO DBR-DAYS SCALE 3.2.
#
# Calculate the elapsed days and hours of the RA
#
SUBTRACT R-CLOSDATE MINUS R-OPENDATE GIVING ELAPS-DAYS.
IF R-CLOSHOUR >= R-OPENHOUR
SUBTRACT R-CLOSHOUR MINUS R-OPENHOUR GIVING ELAPS-HOURS.
IF R-CLOSHOUR < R-OPENHOUR
SUBTRACT ELAPS-DAYS MINUS 1 GIVING ELAPS-DAYS
SUBTRACT R-OPENHOUR MINUS R-CLOSHOUR GIVING TMP-HOURS
SUBTRACT 24 MINUS TMP-HOURS GIVING ELAPS-HOURS.
#
# Compare hour rate x number of hours against day rate
#
IF RAC-TYPE = 'R' AND RAC-REC-TYPE = ' '
AND RAC-TOUR-VCHR-SEQ-NO = 0
AND RAC-CANCEL-FLAG = ' '
AND RAC-POSTED-FLAG = 'Y'
MOVE RAC-PRIMARY-RATE TO DAY-RATE
MOVE RAC-HOURLY-RATE TO HOUR-RATE.
MULTIPLY ELAPS-HOURS BY HOUR-RATE GIVING HOUR-CHARGE.
IF HOUR-CHARGE = 0.000 AND ELAPS-HOURS >= 1
MOVE ELAPS-DAYS TO DBR-DAYS
ADD 1 TO DBR-DAYS GIVING DBR-DAYS.
IF HOUR-CHARGE = 0.000 AND ELAPS-HOURS < 1

MOVE ELAPS-DAYS TO DBR-DAYS.

IF HOUR-CHARGE = 0.000 AND ELAPS-DAYS = 0
MOVE 1.00 TO DBR-DAYS.
IF HOUR-CHARGE >= DAY-RATE, ADD 1 TO ELAPS-DAYS GIVING DBR-DAYS.
IF HOUR-CHARGE < DAY-RATE AND HOUR-CHARGE > 0
DIVIDE HOUR-CHARGE BY DAY-RATE GIVING PARTIAL-DAY ROUND
ADD PARTIAL-DAY TO ELAPS-DAYS GIVING DBR-DAYS.
# End DBR Day Calc ------------------