Groovy web console

subscribe to the feed Subscribe
to this
site

pfr_check

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('Сохранение мест: Апрель-' + (condition211 ? 'Да' : 'Нет') + ', Май- ' + (condition212 ? 'Да' : 'Нет'))
if (!(condition211 || condition212)) {
    println('Раб места не сохранены, Отказ')
    return
}
def sum
if (marchCount == null) {
    if (!isIP) {
        println(" Проверка не пройдена: кол-во работиков в марте 0 и субъект не ИП.")
        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('Проверка пройдена.')
println('Сумма=' + sum)