SefazDanfe.Format (sefaz_danfe v0.1.0)

Copy Markdown View Source

The Brazilian presentation of the values of a DANFE: tax ids, CEP, dates, money, quantities and the access key. Every function takes what the XML holds (text, nil when absent) and answers text, or nil when there is nothing to show, so a missing field stays blank.

Summary

Functions

The 44 digits of an access key in groups of four.

The date of an ISO 8601 date or date-time as dd/mm/yyyy, as the issuer wrote it (no zone shift).

An ISO 8601 date-time as dd/mm/yyyy HH:MM:SS.

A decimal as money: two places, . for thousands and , for decimals (1.234,50).

The number of the document as 000.000.001 (9 digits in groups of three).

A rate as a percentage with 2 to 4 places (12.0000 is 12,00).

A phone as (00) 0000-0000 or (00) 00000-0000 when it has the area code, as is otherwise.

A decimal with at least 2 places and the ones that matter up to max (default 10), as quantities and unit prices are written (10.0000 is 10,00; 25.1234500000 is 25,12345).

The series of the document with 3 digits (001).

A CNPJ (digits or letters, 14) as 00.000.000/0000-00, a CPF (11) as 000.000.000-00.

The time of an ISO 8601 date-time as HH:MM:SS, as the issuer wrote it.

A CEP as 00000-000.

Functions

access_key(key)

@spec access_key(String.t() | nil) :: String.t() | nil

The 44 digits of an access key in groups of four.

date(arg1)

@spec date(String.t() | nil) :: String.t() | nil

The date of an ISO 8601 date or date-time as dd/mm/yyyy, as the issuer wrote it (no zone shift).

datetime(value)

@spec datetime(String.t() | nil) :: String.t() | nil

An ISO 8601 date-time as dd/mm/yyyy HH:MM:SS.

money(value)

@spec money(String.t() | nil) :: String.t() | nil

A decimal as money: two places, . for thousands and , for decimals (1.234,50).

number(value)

@spec number(String.t() | integer() | nil) :: String.t() | nil

The number of the document as 000.000.001 (9 digits in groups of three).

percent(value)

@spec percent(String.t() | nil) :: String.t() | nil

A rate as a percentage with 2 to 4 places (12.0000 is 12,00).

phone(value)

@spec phone(String.t() | nil) :: String.t() | nil

A phone as (00) 0000-0000 or (00) 00000-0000 when it has the area code, as is otherwise.

quantity(value, max \\ 10)

@spec quantity(String.t() | nil, pos_integer()) :: String.t() | nil

A decimal with at least 2 places and the ones that matter up to max (default 10), as quantities and unit prices are written (10.0000 is 10,00; 25.1234500000 is 25,12345).

series(value)

@spec series(String.t() | integer() | nil) :: String.t() | nil

The series of the document with 3 digits (001).

tax_id(value)

@spec tax_id(String.t() | nil) :: String.t() | nil

A CNPJ (digits or letters, 14) as 00.000.000/0000-00, a CPF (11) as 000.000.000-00.

time(arg1)

@spec time(String.t() | nil) :: String.t() | nil

The time of an ISO 8601 date-time as HH:MM:SS, as the issuer wrote it.

zip(value)

@spec zip(String.t() | nil) :: String.t() | nil

A CEP as 00000-000.