Groovy web console

subscribe to the feed Subscribe
to this
site

pfr_check_01

Published 3 weeks ago by axm
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
println('Start')

static def safeCompare(Integer fisrt, Integer second) {
    return fisrt == null || second == null || fisrt - 1 <= second || fisrt * 0.9 <= second
}

Integer marchCount = 2
Integer aprilCount = 2
Integer mayCount = 2
boolean isIP = true


boolean condition211 = safeCompare(marchCount, aprilCount)
boolean condition212 = safeCompare(marchCount, mayCount)
println('Workers keeped: April-' + (condition211 ? 'Yes' : 'No') + ', May- ' + (condition212 ? 'Yes' : 'No'))
if (!(condition211 || condition212)) {
    println('Workers NOT keeped. REJECT ORDER.')
    return
}
def sum
if (marchCount == null) {
    if (!isIP) {
        println(" Check FAILED: Workers in March = 0 and subject is not IP.")
        return
    } else {
        sum = 12130 * 2
    }
} else {
    if (!isIP) {
        sum = (condition211 ? 12130 * marchCount : 0) + (condition212 ? 12130 * marchCount : 0)
    } else {
        sum = (condition211 ? 12130 * (marchCount + 1) : 0) + (condition212 ? 12130 * (marchCount + 1) : 0)
    }
}
println('Check is successful.')
println('')
println('Sum=' + sum)