This commit is contained in:
BoHung Chiu 2020-10-15 15:49:25 +08:00
parent 320d0f91b8
commit b717ce7a14
1 changed files with 10 additions and 2 deletions

View File

@ -73,10 +73,18 @@ class VenueManagementBill
i = find_insert_index(days,delay_in_days)
ref = JSON.parse(\"{\\\"annual_interest\\\": #{1/365.0},\\\"double_dividend\\\": #{1/2.0},\\\"daily_interest\\\": #{1/1.0}}\")
if(days[i-1] < delay_in_days && interest_types[i-1] != undefined ){
if(interest_types[i-1] == 'double_dividend'){
result = _interests[i - 1] * (delay_in_days * ref[interest_types[i-1]]).ceil()
}else{
result = _interests[i - 1] * (delay_in_days * ref[interest_types[i-1]])
}
}else{
if(i != 1 && days[i-2] < delay_in_days && interest_types[i-2] != undefined ){
if(interest_types[i-2] == 'double_dividend'){
result = _interests[i - 2] * (delay_in_days * ref[interest_types[i-2]]).ceil()
}else{
result = _interests[i - 2] * (delay_in_days * ref[interest_types[i-2]])
}
}else{
result = 0
}