Call 0750-216-1212, 0750-217-1212
17 Dec

### PHP Rounding Iraqi Dinars

Rounding Iraqi Dinars needs extra effort because of the nature of IQD Bills. Currently, the minimum usable Bill is: 250 IQD.

### Bills of Iraqi Dinars

• 250 IQD
• 500 IQD
• 1,000 IQD
• 5,000 IQD
• 10,000 IQD
• 25,000 IQD
• 50,000 IQD
• 100,000 IQD (In the future).

The Dinar also divided into (1000 Fils) but its not usable because of unavailability of smaller bills. In Addition, 1 Dinar is also not available, it starts from 250.

### Rounding Issue

When buying items in Supermarket or any shop, the total amount might be number that not ends with (250, 500, and 750), at this case, customers can't pay that amount because the buyer can't provide the change (Difference), thus, rounding IRAQI Dinars in POS (Point Of Sale) Systems or Any accounting Systems is required to round the total to nearest (0, 250, 500, 750, or 1000).

### PHP Example

``` function RoundIQD(\$number){ if(!isset(\$number)){ return false; } //round \$number = (int) round((float) \$number); if(\$number < 1000){ if(\$number == 0) return 0; if(\$number > 0 && \$number <= 250) return 250; if(\$number > 250 && \$number <= 500) return 500; if(\$number > 500 && \$number <= 750) return 750; if(\$number > 750 && \$number <= 1000) return 1000; } elseif(\$number > 1000){ //convert integer to number // you can also do "\$number" \$nu = (string)\$number; //get last three digits of the number \$last3digit = intval(substr(\$nu, -3)); //number - last three digits //for example: 123,650 //\$last3digit = 650 //\$numberwithout3digit = 123,650 - 650 = 123000 \$numberwithout3digit = intval(\$number - \$last3digit); //check last three digits \$rounded_last3digit = RoundIQD(\$last3digit); \$number = \$numberwithout3digit + \$rounded_last3digit; return \$number; } else if(\$number == 1000) return 1000; else return \$number; } ```