nsu

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Zero = NSU("000000000000000")

Zero is a zero valued NSU.

Variables

View Source
var (
	// ErrCannotParse is returned when a NSU cannot be parsed from a string
	ErrCannotParse = errors.New("failed to parse nsu from string")
)

Functions

func AsUint64

func AsUint64(nsu NSU) uint64

AsUint64 converts a NSU into an Integer. This function panics if the NSU is not an integer

func Compare

func Compare(source, compare NSU) int

Compare two NSU's by using this function. NSU's will be compared after being added the padding 0'es. Returns 0 if @source is the same as @compare, 1 if @source is bigger and -1 if @source is smaller

Types

type NSU

type NSU string

NSU is "Número Sequencial Único" and it's an offset used by sefaz to manage the NFes

func MustParse

func MustParse(s string) NSU

MustParse calls Parse function and panics on error

func MustParseUint64

func MustParseUint64(nsu uint64) NSU

MustParseUint64 parses an integer into an NSU

func Parse

func Parse(nsu string) (NSU, error)

Parse instantiates a new nsu from @nsu string

func ParseUint64

func ParseUint64(nsu uint64) (NSU, error)

ParseUint64 parses an integer into an NSU

func (NSU) MarshalJSON

func (nsu NSU) MarshalJSON() ([]byte, error)

MarshalJSON serializes the NSU value as a JSON value

func (NSU) MarshalZerologObject

func (nsu NSU) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements the zerolog marshaler so it can be logged using: log.With().EmbededObject(nsu).Msg("Some message")

func (NSU) String

func (nsu NSU) String() string

func (*NSU) UnmarshalJSON

func (nsu *NSU) UnmarshalJSON(b []byte) error

UnmarshalJSON deserializes a JSON value into a NSU value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL