致远二开-越南币大写公式问题

问题描述

1.在致远OA中,针对数字进行到大写公式时默认最大单位为万亿,且格式为写死格式为XXX元整,在实际业务需求时,可能不需要元整。

2.在针对其他外国用户时,到大写可能不适用,例如此处的越南币转换问题,需要小数点为XXX盾

此时就需要通过致远自定义公式完成此类定制化问题

groovy函数示例 -针对越南盾转换问题

def CN_NUM = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"]
def UNIT = "盾"
def amount = param[0]
def integerPart = (long) amount
def decimalPart = ((int) ((amount - integerPart) * 100 + 0.5))

 def amount2 =param[1]
 
 def index = amount2.indexOf("元")
 def integerStr =""
if (index != -1) {
      integerStr = amount2.substring(0, index)
}
def decimalStr = ""
if (decimalPart > 0) {
    def tens = decimalPart / 10
    def units = decimalPart % 10
    if (tens > 0) {
        decimalStr += CN_NUM[tens.toInteger()]
    }
    if (units > 0) {
        decimalStr += CN_NUM[units.toInteger()]
    }
}
def result = ""
if (integerStr.length() == 0 && decimalStr.length() == 0) {
    result = "零" + UNIT + "整"
} else if (decimalPart == 0) {
    result = integerStr + UNIT + "整"
} else if (integerStr.length() == 0) {
    result = "零." + decimalStr + UNIT + "整"
} else {
    result = integerStr + "." + decimalStr + UNIT + "整"
}
return result;

本次公式对照内容为 其中文本2为正常公式到大写功能,文本3为此处自定义公式定制展示功能
致远二开-越南盾大写公式问题-01.png