-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from kinegratii/develop
发布V3.3.0
- Loading branch information
Showing
37 changed files
with
396 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# coding=utf8 | ||
|
||
__version__ = '3.2.0' | ||
__version__ = '3.3.0' | ||
__author__ = 'kinegratii' |
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,20 @@ | ||
# coding=utf8 | ||
|
||
import re | ||
from decimal import Decimal | ||
|
||
from typing import Union | ||
|
||
RULES = [ | ||
(r'零角零分$', '整'), | ||
(r'零[仟佰拾]', '零'), | ||
(r'零{2,}', '零'), | ||
(r'零([亿|万])', r'\g<1>'), | ||
(r'零+元', '元'), | ||
(r'亿零{0,3}万', '亿'), | ||
(r'^元', '零元') | ||
] | ||
import warnings | ||
|
||
MAX_VALUE_LIMIT = 1000000000000 | ||
from borax.numbers import FinanceNumbers | ||
|
||
__all__ = ['financial_amount_capital'] | ||
|
||
|
||
def financial_amount_capital(num: Union[int, float, Decimal, str]) -> str: | ||
units = '仟佰拾亿仟佰拾万仟佰拾元角分' | ||
digits = '零壹贰叁肆伍陆柒捌玖' | ||
if isinstance(num, str): | ||
_n = int(num) | ||
else: | ||
_n = num | ||
if _n < 0 or _n >= MAX_VALUE_LIMIT: | ||
raise ValueError('Out of range') | ||
|
||
num_str = str(num) + '00' | ||
dot_pos = num_str.find('.') | ||
if dot_pos > -1: | ||
num_str = num_str[:dot_pos] + num_str[dot_pos + 1:dot_pos + 3] | ||
capital_str = ''.join([digits[int(i)] for i in num_str]) | ||
s_units = units[len(units) - len(num_str):] | ||
|
||
o = ''.join('{}{}'.format(u, d) for u, d in zip(capital_str, s_units)) | ||
for p, d in RULES: | ||
o = re.sub(p, d, o) | ||
|
||
return o | ||
warnings.warn( | ||
'This method is deprecated and will be removed in V3.5.Use borax.numbers.FinanceNumbers instead.', | ||
category=PendingDeprecationWarning | ||
) | ||
|
||
return FinanceNumbers.to_capital_str(num) |
Oops, something went wrong.