Class AmtInWords_ZH

java.lang.Object
org.compiere.util.AmtInWords_ZH
All Implemented Interfaces:
AmtInWords

public class AmtInWords_ZH extends Object implements AmtInWords
Amount in Words for Zh_CN (CNY in Simplified Chinese)
Version:
$Id: AmtInWords_ZH.java,v1.0 2017/09/21 00:54:35 $ The class is based on the AmtInWords_EN.java written by jjanke The algorithm is based on code named snhongtenzone@foxmail.com Rule: 1. CNY is an currency of 10000-unit scale, dislike dollar with 1000-unit scale. 2. CNY currency accuracy is 0.01. And it's under a strict decimal number system. 3. Option of add an "zero" after "Yuan" is false. (Line 186) Reference: [1997]393 People's Bank of China "the Measures for Payment and Settlement" 参考: 中国人民银行 银发[1997]393号 《支付结算办法》附件《正确填写票据和结算凭证的基本规定》 Results: (Rule 3 = true) 0.00 零元整 (测试:金额为 0) 0.03 叁分 (测试:角0分非0,外加 元0) 0.234 贰角叁分 (测试:角非0分非0,舍4) 1.001 壹元整 (测试:角0分0,加 “ 整 ”,舍1) 1.035 壹元零肆分 (规则4.4:角0分非0,加零,入5) 1.205 壹元贰角壹分 (测试:角非0分0,入5后,角非0分非0) 1.3345 壹元叁角叁分 (测试:小数点4位) 10.03 壹拾元零叁分 (规则4.4:角0分非0,加零) 10.23 壹拾元零贰角叁分 (规则4.3:元0角非0,可选加零) 23.00 贰拾叁元整 (规则2:加 “ 整 ”) 100.20 壹佰元零贰角 (规则4.2 多零写一零,角非0分0) 103.45 壹佰零叁元肆角伍分 (规则4.1:有0加 “ 零 ”,角非0分非0) 2,345 贰仟叁佰肆拾伍元整 (规则2:加 “ 整 ”) 1020.45 壹仟零贰拾元零肆角伍分 (规则4.1+4.3:有0加 “ 零 ”;元0角非0,可选加零) 1,234.56 壹仟贰佰叁拾肆元伍角陆分 (测试:千分位 是否正确) 12345.78 壹万贰仟叁佰肆拾伍元柒角捌分 (测试:千分位 是否正确) 100457.89 壹拾万零肆佰伍拾柒元捌角玖分 (规则4.2:多零写一零) 103457.89 壹拾万零叁仟肆佰伍拾柒元捌角玖分 (规则4.3:万0千非零,可选加零) 107000.03 壹拾万零柒仟元零叁分 (规则4.3+4.4:万0元0千非0,中间多0,角0,可选加零) 9,000,000.00 玖佰万元整 (规则: 4位进制) 10,000,000.00 壹仟万元整 (测试:4位进制) 10220134 壹仟零贰拾贰万零壹佰叁拾肆元整 (测试:无千分位 “是否正确) 100,234,578.90 壹亿零贰拾叁万肆仟伍佰柒拾捌元玖角 (测试:亿) 203010000.56 贰亿零叁佰零壹万元零伍角陆分 (测试:亿零,万零,元) 103,004,000.90 壹亿零叁佰万零肆仟元零玖角 (规则4.2+4.3:多零写一零,万0千非零,中间多0,可选加零) 1,201,034,578.90 壹拾贰亿零壹佰零叁万肆仟伍佰柒拾捌元玖角 (测试:十亿,3个千分位 是否正确) 90,000,000,000 玖佰亿元整 (测试:4位进制) 100,000,000,000 壹仟亿元整 (测试:4位进制) 1,932,110,345,780 壹兆玖仟叁佰贰拾壹亿壹仟零叁拾肆万伍仟柒佰捌拾元整 (测试:13位整数,兆,4个千分位) 10,000,000,000,000 错误 (测试:超过或等于最大位数10兆,数字必须小于14位) -1220.354 负壹仟贰佰贰拾元零叁角伍分 (测试:负数,四舍五入) 1.222,33 错误 (测试:非法字符)
Author:
z5k1@qq.com
  • Constructor Details

    • AmtInWords_ZH

      public AmtInWords_ZH()
      AmtInWords_ZH
  • Method Details

    • getAmtInWords

      public String getAmtInWords(String amount) throws Exception
      Get Amount in Words
      Specified by:
      getAmtInWords in interface AmtInWords
      Parameters:
      amount - numeric amount (352.80)
      Returns:
      amount in words
      Throws:
      Exception
    • main

      public static void main(String[] args)
      Test
      Parameters:
      args - ignored