1s 8.3 number in words in the genitive case. Number in words, detailed description. Main components of the algorithm
When displaying various reports, it is often necessary to convert a numeric value into a string in words. In 1C this is solved very simply: the function NumberInWord() is provided for this.
When forming a number in words, it is possible to display side by side the subject of calculating this number in the required gender and case. Subject of calculus- this is what the converted number measures, for example, money, boxes, carriages, televisions, etc.
- Without the subject of calculus:
- Twenty two;
- Three hundred eighty four.
- With the subject of calculus:
- Thirty-eight doubloons;
- Twelve ships;
- Two houses.
Examples
First, let's give examples of conversion to find out the capabilities of 1C:
// ***** Output numbers: ***** NumberIn Words(9876.54); // Nine thousand eight hundred seventy six 54 NumberIn words (1234.56, "L=ru_RU;DP=TRUE" , "whole, whole, whole, f, hundredth, hundredth, hundredth, f, 2"); // One thousand two hundred thirty-four point fifty-six hundredths NumberIn words (7432, "L=ru_RU;NP=False" , ",0" ); // Seven thousand four hundred thirty two // ***** Withdrawal of funds: ***** NumberIn words (9845.11, "Л=ru_RU" , ); // Nine thousand eight hundred forty-five rubles 11 kopecks Number in words (2845.11, "L=ru_RU;DP=True" , "ruble, ruble, ruble, m, kopeck, kopeck, kopeck, w, 2"); // Two thousand eight hundred forty-five rubles eleven kopecks Number in words (555.16, "L=ru_RU;DP=True" , "dollar, dollar, dollars, m, cent, cent, cents, m, 2"); // Five hundred fifty-five dollars sixteen cents Number in words (453.23, "L=ru_RU;DP=True" , "euro, euro, euro, m, cent, cent, cents, m, 2"); // Four hundred fifty-three euros twenty-three cents Number in words (812.44, "L=en_US;DP=True" , "dollar, dollars, cent, cents, 2"); // Eight hundred twelve dollars forty four cents NumberIn Words (3945.76, "L=en_US;DP=True" , "euro, euros, cent, cents, 2" ); // Three thousand nine hundred forty five euros seventy six cents // ***** You can convert not only monetary units: ***** Number in words (535 , "Л=ru_RU" , "box, boxes, boxes, w, w, 0"); // Five hundred thirty-five boxes Number in words (342 , "Л=ru_RU" , "TV, TV, TVs, m, m, 0"); // Three hundred forty-two TVsDescription of working with the function
As we found out, to get a number in words, use the function
NumberIn words (< Число >, < FormatString>, < Item ParametersCalculus>)The function returns a string value. The following are passed as input parameters:
- Number is the value to be converted;
- FormatString - formatting options:
- L — Localization code (for example, u_RU — Russian; en_US — English, de_DE — German). By default, the operating system settings are used.
- NP - Display the name of the subject of calculus, by default - True.
- ND - Display the name of the decimal parts of the subject of calculus, by default - True.
- DP - Display the fractional part in words/numbers, default - False.
- AI - Deduce the conjunction and. Analyzed only for English localization. Possible values: “Not Use”, “Use”.
- Calculus Subject Parameters - comma-separated listing of the parameters of the calculus subject. The format depends on the localization.
For the Russian language, the parameters of the subject of calculus have the form “ruble, ruble, rubles, m, kopeck, kopecks, kopecks, zh, 2”, where:
- ruble – singular nominative case;
- ruble – singular genitive case;
rubles – plural genitive case;
m – masculine (w – feminine, s – neuter);
“kopeck, kopeck, kopeck, w” – fractional part, similar to the subject of calculus (may be absent);
“2” – the number of digits of the fractional part (may be absent, default is 2).
Use in standard solutions
In configurations built on , in a common module WorkWithRatesCurrencies there is a function
FormAmountInWords(AmountNumber, Currency, Withdraw Amount Without Kopecks= False)The function is used to convert currency amounts into a string in words.
Parameters:
<Значение>
The value to be formatted.
<ФорматнаяСтрока>
A format string is a string value that includes formatting options.
Formatting options are listed separated by the ";" symbol. The presence of a parameter means that the formatting differs from the standard one.
If the parameter is not specified, then standard formatting is applied, which basically corresponds to converting the value to a string. However, for values of type Number and Date, the default value (0 and 01/01/0001 00:00:00, respectively) will return an empty string.
Each parameter is specified by the parameter name, the "=" character, and the parameter value. The parameter value can be specified in single or double quotes. This is necessary if the parameter value contains characters used in format string syntax.
Arbitrary characters can be specified inside the parameter value, which will be displayed as is when generating the resulting string. This way, for example, you can specify hour, minute, and second separators when formatting time. If these characters match format string values, they must be enclosed in single quotes.
Names and values of format string parameters:
- L - name of the language, country for which standard formatting will be performed.
- CC - the total number of displayed decimal places of the integer and fractional parts. The original number is rounded in accordance with the rounding rules. If this parameter is specified, then to display the fractional part of a number, it is necessary to specify the NPV parameter, otherwise the fractional part will not be displayed.
- NDT - the number of decimal places in the fractional part. The original number is rounded in accordance with the rounding rules.
- ES - shift of digits: positive - division, negative - multiplication. In other words, this means that the original number will be multiplied or divided by 10*C, where C is the absolute value of the parameter.
- CRD is a symbol separating the integer and fractional parts.
- CHRG is a group separator symbol for an integer part of a number. If you use an empty string as a delimiter, then the delimiter will be a non-breaking space character.
- CN is a string representing the zero value of a number. If not specified, then represented as an empty string. If "CHN=" is specified, then in the form of "0". Not used for numeric input fields.
- CHN - whether leading zeros should be output. Meaning this parameter is not specified; the presence of the parameter itself determines the output of leading zeros.
- CHG - the order of grouping the digits of a number. The values are numbers, separated by commas, indicating the number of grouped digits from right to left. Only the first two numbers make sense. The first of these indicates the primary grouping, that is, the one that will be used for the least significant digits of the integer part of the number. If the second number is not specified, only the least significant digits will be grouped. If 0 is specified as the second number, then for all digits of the integer part of the number the value specified for the primary grouping will be applied. If a value other than 0 is used as the second number, then this value will be used to group all digits except the least significant ones already grouped.
- СО - representation of negative numbers.
- 0 (0) - a string like "(1,1)";
- 1 (1) - a string like "-1,1";
- 2 (2) - a string like "- 1,1";
- 3 (3) - a string like "1,1-";
- 4 (4) - a string like "1,1 -".
- DF - date format.
- d - day of the month (in numbers) without leading zero;
- dd - day of the month (in numbers) with a leading zero;
- ddd - short name of the day of the week;
- dddd - full name of the day of the week;
- M - month number (in numbers) without leading zero;
- MM - month number (in digits) with leading zero;
- MMM - short name of the month;
- MMMM - full name of the month;
- k - number of the quarter in the year;
- r - number of the year without a century and a leading zero;
- yy - number of the year without a century with a leading zero;
- yyyy - year number with century;
- h - hour in the 12-hour version without leading zeros;
- hh - hour in 12-hour clock with leading zero;
- H - hour in 24-hour format without leading zeros;
- HH (HH) - hour in 24-hour mode with a leading zero;
- m - minute without leading zero;
- mm - minute with leading zero;
- s - second without a leading zero;
- ss - second with leading zero;
- bb - display half of the day AM/PM (valid only for configuration languages that support the 12-hour time display option).
- DLF - local date format. Specifies the option for displaying date parts.
- D - date (in numbers);
- DD - long date (month in words);
- B - full time, date can be combined with time;
- DV - date time.
- DP - a string representing an empty date (for example, Format("00010101000000" ,"DP=""empty date""") will return the string "empty date").
- BL - a string representing a Boolean value Lie.
- BI - a string representing a logical value True.
NumberInWords
Syntax:
NumberIn words(<Число>, <Форматная строка>, <Параметры предмета исчисления>)
Parameters:
<Число>(required)
Type: Number. The number to be converted to a written string.
<Форматная строка>(optional)
Type: String. A format string is a string value that includes formatting options. Formatting options are listed separated by the ";" symbol. (semicolon). If a parameter is not specified, the parameter's default value is used.
Each parameter is specified by the parameter name, the "=" (equals) symbol, and the value of the parameter. The parameter value can be specified in single or double quotes. This is necessary if the parameter value contains characters used in format string syntax.
L (L) - Localization code. The default localization code is set to operating system. Examples of localization codes: ru_RU - Russian (Russia); en_US - English (USA).
NP (SN) - Include/do not include the name of the subject of calculus (Boolean), default - True.
ND (FN) - Include/do not include the name of the decimal parts of the subject of calculus (Boolean), by default - True.
DP (FS) - Display the fractional part in words/numbers (Boolean), by default - False.
<Параметры предмета исчисления>(optional)
Type: String. Represents a string value that defines the parameters of the subject of calculus. Calculus subject parameters are listed separated by "," (comma). The string format depends on the localization code.
For Russian and Belarusian languages (ru_RU, be_BY)
"ruble, ruble, rubles, m, kopeck, kopecks, kopecks, w, 2", where:
“ruble, ruble, rubles, m” – subject of calculation:
ruble – singular nominative case,
ruble – singular genitive case,
rubles – plural genitive case,
For Ukrainian language (uk_UA)
"hryvnia, hryvnia, hryvnia, m, kopeck, kopeck, kopeck, w, 2", where:
“hryvnia, hryvnia, hryvnia, m” – subject of calculation:
"hryvnia – singular nominative case,
hryvnia – singular genitive case,
hryvnia – plural genitive case,
m – masculine (w – feminine, s – neuter);
“kopeck, kopeck, kopeck, zh” – fractional part, similar to the subject of calculus (may be absent);
"2" – the number of digits of the fractional part (may be absent, default is 2).
For Polish (pl_PL)
złoty, złote, złotych, m, grosz, grosze, groszy, m, 2
Where:
"złoty, złote, złotych, m" - subject of calculation (m - masculine, ż - feminine, ń - neuter, mo - personal masculine)
złoty - singular nominative case
złote - singular accusative case
złotych - plural accusative
m - masculine (ż - feminine, ń - neuter, mo - personal masculine)
"grosz, grosze, groszy, m" - fractional part (may be absent) (similar to the integer part)
2 - number of digits of the fractional part (may be absent, default is 2)
Example:
In words = NumberIn words(1832, “L=pl_PL;SN=true;FN=true;FS=true”, “złoty, złote, złotych, m, grosz, grosze, groszy, m, 2”);
For English, Finnish and Kazakh languages (en_US, fi_FI, kk_KZ)
"dollar, dollars, cent, cents, 2", where:
"dollar, dollars" – subject of calculation in singular and plural;
"cent, cents" – fractional part in singular and plural (may be absent);
"2" – the number of digits of the fractional part (may be absent, default is 2).
For German (de_DE)
"EURO, EURO, M, Cent, Cent, M, 2", where:
"EURO, EURO, M" – subject of calculation:
EURO, EURO – subject of calculation in singular and plural;
M – masculine (F – feminine, N – neuter);
“Cent, Cent, M” – fractional part, similar to the subject of calculus (may be absent);
"2" – the number of digits of the fractional part (may be absent, default is 2).
For Latvian language (lv_LV)
"lats, lati, latu, V, santīms, santīmi, santīmu, V, 2, J, J", where:
"lats, lati, latu, v" – subject of calculus:
lats – for numbers ending in 1, except 11
lati – for numbers ending in 2-9 and 11
latu – plural (genitive case) is used after the numerals 0, 10, 20,..., 90, 100, 200, ..., 1000, ..., 100000,
v – masculine (s – feminine);
“santīms, santīmi, santīmu, V” – fractional part, similar to the subject of calculus (may be absent);
"2" – number of digits of the fractional part (may be absent, default is 2);
"J" - the number 100 is displayed as "One hundred" for the subject of calculus (N - as "One hundred"),
may be absent, defaults to "J";
"J" - the number 100 is displayed as "One hundred" for the fractional part (N - as "One hundred"),
may be absent, defaults to "J".
For Lithuanian language (lt_LT)
"litas, litai, litų, M, centas, centai, centų, M, 2", where:
"litas, litai, litų, M" – subject of calculation:
litas - singular number of the integer part,
litai - plural of the integer part from 2 to 9,
litų - plural of the integer part others,
m - gender of the integer part (f - feminine gender),
“centas, centai, centų, M” – fractional part, similar to the subject of calculus (may be absent);
"2" - the number of digits of the fractional part (may be absent, default is 2).
For Estonian language (et_EE)
"kroon, krooni, sent, senti, 2", where:
"kroon, krooni" – – subject of calculation in singular and plural;
"sent, senti" – fractional part in singular and plural (may be absent);
2 – number of digits of the fractional part (may be absent, default is 2).
For Bulgarian (bg_BG)
"lev, leva, m, stotinka, stotinki, w, 2", where:
“lev, leva, m” – subject of calculation:
lion is the singular number of the integer part,
leva - plural of an integer part,
m - genus of the whole part,
"stotinka, stotinki, zh" - fractional part:
stotinka is the singular number of the fractional part,
stotinki - plural of the fractional part,
g - genus of the fractional part,
For Romanian language (ro_RO)
"leu, lei, M, ban, bani, W, 2"
"leu, lei, M" – subject of calculus:
leu is the singular number of the integer part,
lei - plural of an integer part,
M is the genus of the integer part,
"ban, bani, W" - fractional part:
ban is the singular number of the fractional part,
bani - plural of the fractional part,
W - genus of the fractional part,
"2" - the number of digits of the fractional part.
For Georgian language (ka_GE)
"ლარი, თეთრი, 2"
ლარი - whole part
თეთრი - fractional part
"2" - the number of digits of the fractional part.
For Vietnamese language (vi_VN)
"dong, xu, 2"
dong, - whole part
xu, - fractional part
2 - the number of digits of the fractional part.
........
Default value: Empty string
Return value:
Type: String. Representation of numbers in words.
Description:
Forms a representation of a number in words in accordance with the specified format string and parameters of the subject calculated
Code 1C v 8.x
// An example of a format string for displaying a number in words in Russian
// language, with the output of the integer and fractional parts in words and output
// subject of calculus.
FormString = "L = ru_RU; DP = True";
ItemPar="dollar,dollar,dollars,m,cent,cent,cents,m,2";
Numbers in Words = Number in Words(2341.56, FormString, ItemPart);
// Calculation result: "Two thousand three hundred forty-one dollars fifty-six cents"
NumberIn words(Number, Format string, Calculus subject parameters)
Number - The number that needs to be converted to a string in words.
A format string is a string value that includes formatting options. Formatting options are listed separated by the ";" symbol. (semicolon). If a parameter is not specified, the parameter's default value is used.
Each parameter is specified by the parameter name, the "=" (equals) symbol, and the value of the parameter. The parameter value can be specified in single or double quotes. This is necessary if the parameter value contains characters used in format string syntax.
L (L) - Localization code. By default, the localization code installed in the operating system is used. Examples of localization codes: ru_RU - Russian (Russia); en_US - English (USA).
NP (SN) - Include/do not include the name of the subject of calculus (Boolean), default - True.
ND (FN) - Include/do not include the name of the decimal parts of the subject of calculus (Boolean), by default - True.
DP (FS) - Display the fractional part in words/numbers (Boolean), by default - False.
Calculus Subject Parameters - Represents a string value that defines the parameters of the calculus subject. Calculus subject parameters are listed separated by "," (comma). The string format depends on the localization code.
For Russian and Belarusian languages (ru_RU, be_BY)
"ruble, ruble, rubles, m, kopeck, kopecks, kopecks, w, 2", where:
"ruble, ruble, rubles, m" - subject of calculation:
ruble - singular nominative case,
ruble - singular genitive case,
rubles - plural genitive case,
For Ukrainian language (uk_UA)
"hryvnia, hryvnia, hryvnia, m, kopeck, kopeck, kopeck, w, 2", where:
"hryvnia, hryvnia, hryvnia, m" - subject of calculation:
"hryvnia - singular nominative case,
hryvnia - singular genitive case,
hryvnia - plural genitive case,
m - masculine (w - feminine, s - neuter);
“kopeck, kopeck, kopeck, zh” - fractional part, similar to the subject of calculus (may be absent);
"2" - the number of digits of the fractional part (may be absent, default is 2).
For Polish (pl_PL)
z?oty, z?ote, z?otych, m, grosz, grosze, groszy, m, 2
Where:
"z?oty, z?ote, z?otych, m" - subject of calculation (m - masculine, ? - feminine, ? - neuter, mo - personal masculine)
z?oty - singular nominative case
z?ote - singular accusative
z?otych - plural accusative
m - masculine (? - feminine, ? - neuter, mo - personal masculine)
"grosz, grosze, groszy, m" - fractional part (may be absent) (similar to the integer part)
2 - number of digits of the fractional part (may be absent, default is 2)
Code 1C v 8.x
In words = NumberIn words(1832, “L=pl_PL;SN=true;FN=true;FS=true”, “z?oty, z?ote, z?otych, m, grosz, grosze, groszy, m, 2”) ;
For English, Finnish and Kazakh languages (en_US, fi_FI, kk_KZ)
"dollar, dollars, cent, cents, 2", where:
"dollar, dollars" - subject of calculation in singular and plural;
"cent, cents" - fractional part in singular and plural (may be absent);
"2" - the number of digits of the fractional part (may be absent, default is 2).
For German (de_DE)
"EURO, EURO, M, Cent, Cent, M, 2", where:
"EURO, EURO, M" - subject of calculation:
EURO, EURO - subject of calculation in singular and plural;
M - masculine (F - feminine, N - neuter);
"Cent, Cent, M" - fractional part, similar to the subject of calculus (may be absent);
"2" - the number of digits of the fractional part (may be absent, default is 2).
Examples:
Code 1C v 8.x x = Number in words (123456.78,"DP=True","ton, tons, tons, f, kg., kg., kg., m, 3");
//x = "One hundred twenty-three thousand four hundred fifty-six tons seven hundred eighty kg."
X = NumberIn Word(123456.78,",0");
//x = "One hundred twenty-three thousand four hundred fifty-seven"
X = NumberIn Word(123456.78,",2");
//x = "One hundred twenty-three thousand four hundred fifty-six 78 "
X = NumberIn words(123456.78,"L=ru_RU; DP=False","ruble, ruble, rubles, m, kopeck, kopeck, kopeck, w");
//x = "One hundred twenty-three thousand four hundred fifty-six rubles 78 kopecks"
X = NumberIn Words(123456.78, "L = ru_RU; DP = True", "dollar,dollar,dollars,m,cent,cent,cents,m,2");
//x = "One hundred twenty-three thousand four hundred fifty-six dollars seventy-eight cents"
Information taken from the site
According to current legislation, payment documents and financial reports must contain total amounts written in words. IN accounting program 1s number in words can be obtained using a special function in the global context. The specialist sets the necessary parameters in the format string and receives the number in words as output in the document. The algorithm of actions is the same for all 1c Enterprise configurations.
Main components of the algorithm
In order to correctly format a number in capital letters, you need to understand the meaning of all components of the diagram. Key indicators:
- A number is a set of numbers that should be converted into words;
- The format line is a place in the program for specifying the necessary language parameters. The requirements for the type of fractional part are also specified there. Composite elements are indicated separated by semicolons;
Format string elements:
- The localization code is indicated by the letter L (L). You can change it yourself by specifying the required language;
- Reproduce/do not reproduce the name of the units of measurement (ND = false or true);
- Reproduce/do not reproduce fractional parts of the sum (DP = false or true);
- Calculus subject parameters are a precise description of the units of measurement of the amount that must be written in words. For example, ruble, dollar, kopeck.
Important. All elements of the diagram should be specified as accurately as possible. You can double-check the correctness of the entered data in the syntax assistant.
How to write a number output scheme in words
You can write the 1st number in words using the following scheme: NumberIn Words (Number, “Format Line”, “Calculus Subject Parameters”), where
A number is a set of numbers, for example 2358.879.
Format String - the name of the language and method of displaying the number. In Russian it will look like this: L = ru_RU. If the fractional part must be written in words, indicate DP = True. By default, this indicator is switched to False.
Parameters of the Subject of Calculus - the name of the unit of measurement in all cases, indicating the gender. For example, the ruble is masculine, the kopeck is feminine. They are designated by the letters “m” and “f”.
Parameters are indicated in quotes and separated by commas. For the Russian language, the scheme will look like this: NumberIn words (2358.879, “L = ru_RU; DP = True”, “ruble, ruble, rubles, m, kopek, kopecks, kopecks, w, 3”) In this case, the number 3 means the quantity decimal places.
This method is not suitable if the exact number of characters after the decimal point is not known. To simplify the task, use the representation of sum and currency. As a rule, in such situations it is customary to leave two digits after the decimal point.
How to write a diagram correctly
In order to correctly give the program a task to complete, you must take the following steps:
- At the first stage, determine the desired language encoding. The most popular in Russia:
- English - en_US;
- Russian - L = ru_RU.
- Next, set the type of units of measurement and fractional part (ND, DP);
- When preparing documents, it may be necessary to withdraw the amount in rubles to English or vice versa, write the words dollar, euro in Russian. To do this, the name of the currency is written down in detail in all cases, indicating the gender.
Parameters of the subject of calculus in different languages.
Next, 1c the amount in words in different languages is collected according to the standard scheme. The output will be a document with the total amount written in words. For example, you need to create a financial document in the 1c program for foreign partners who speak English. Currency – euro. The scheme will look like this: NumberIn Words (10 125.67, “L=en_US; DP=True”, “euro,euros,eurocent,eurocents,2”)
Advice. There is no need to memorize these designs. They are all standard, only the parameters of the item change. Therefore, it is better to prepare templates in advance and use them as a cheat sheet.