Created
October 16, 2014 13:07
-
-
Save yannvery/bbe67558cb424f031807 to your computer and use it in GitHub Desktop.
Compute invoice penalty amount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'date' | |
| puts "Enter due date (YYYY/MM/DD) : " | |
| due_date = gets.chomp | |
| puts "Enter amount VAT included: " | |
| amount = gets.chomp.to_f.round(2) | |
| puts "Enter penalty rate : " | |
| penalty_rate = gets.chomp.to_f.round(2) | |
| penalty_amount_by_day = (amount * penalty_rate / 100.00) / 365 | |
| penalty_amount_today = penalty_amount_by_day * (Date.today - Date.parse(due_date)) | |
| puts "Penalty amount by day : #{penalty_amount_by_day}" | |
| puts "Penalty amount for now : #{penalty_amount_today}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment