nfs

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const CFeXMLMock = `` /* 3219-byte string literal not displayed */
View Source
const NFCeXMLMock = `` /* 6408-byte string literal not displayed */
View Source
const NFeDevolucaoXMLMock = `` /* 6980-byte string literal not displayed */
View Source
const NFeXMLMock = `` /* 5381-byte string literal not displayed */

Variables

This section is empty.

Functions

func CEP

func CEP() string

CEP generates a mock postal code.

func CFOP

func CFOP() string

CFOP generates a mock CFOP code.

func CRT

func CRT() string

CRT generates a mock Tax Regime code.

func CSOSN

func CSOSN() string

CSOSN generates a mock CSOSN code.

func CST_COFINS

func CST_COFINS() string

CST_COFINS generates a mock CST code for COFINS.

func CST_PIS

func CST_PIS() string

CST_PIS generates a mock CST code for PIS.

func DhEmi

func DhEmi() string

DhEmi generates a mock emission date.

func DigestValue

func DigestValue() string

DigestValue generates a mock digest value.

func IE

func IE() string

IE generates a mock State Registration.

func NCM

func NCM() string

NCM generates a mock NCM code.

func NatOp

func NatOp() string

NatOp generates a mock nature of operation.

func Number

func Number(min, max int) string

Number generates a mock number within a specified range.

func ReplaceTemplate

func ReplaceTemplate(template string, options ...Option) ([]byte, error)

ReplaceTemplate takes an XML template and replaces placeholders with mock values. It handles dependencies between placeholders and removes entire tags for blocked placeholders, including any surrounding whitespace and newline characters to prevent blank lines.

func SignatureValue

func SignatureValue() string

SignatureValue generates a mock signature value.

func UF

func UF() string

UF generates a mock state abbreviation.

func X509Certificate

func X509Certificate() string

X509Certificate generates a mock X509 certificate.

Types

type CFeGenerator

type CFeGenerator struct {
	// contains filtered or unexported fields
}

func NewCFeGenerator

func NewCFeGenerator() *CFeGenerator

NewCFeGenerator creates a new instance of CFeGenerator with the CFe XML template.

func (CFeGenerator) Generate

func (c CFeGenerator) Generate(options ...Option) ([]byte, error)

type DependencyGraph

type DependencyGraph map[string][]string

type NFCeGenerator

type NFCeGenerator struct {
	// contains filtered or unexported fields
}

NFCeGenerator generates a NFCe XML.

func NewNFCeGenerator

func NewNFCeGenerator() *NFCeGenerator

NewNFCeGenerator creates a new instance of NFCeGenerator with the NFCe XML template.

func (*NFCeGenerator) Generate

func (g *NFCeGenerator) Generate(options ...Option) ([]byte, error)

Generate replaces placeholders in the NFCe template, respecting blocked placeholders.

type NFeDevolucaoGenerator

type NFeDevolucaoGenerator struct {
	// contains filtered or unexported fields
}

NFeDevolucaoGenerator generates an NFe Devolucao XML.

func NewNFeDevolucaoGenerator

func NewNFeDevolucaoGenerator() *NFeDevolucaoGenerator

NewNFeDevolucaoGenerator creates a new instance of NFeDevolucaoGenerator with the NFeDevolucao XML template.

func (*NFeDevolucaoGenerator) Generate

func (g *NFeDevolucaoGenerator) Generate(options ...Option) ([]byte, error)

Generate replaces placeholders in the NFeDevolucao template, respecting blocked placeholders.

type NFeGenerator

type NFeGenerator struct {
	// contains filtered or unexported fields
}

NFeGenerator generates a standard NFe XML.

func NewNFeGenerator

func NewNFeGenerator() *NFeGenerator

NewNFeGenerator creates a new instance of NFeGenerator with the NFe XML template.

func (*NFeGenerator) Generate

func (g *NFeGenerator) Generate(options ...Option) ([]byte, error)

Generate replaces placeholders in the NFe template, respecting blocked placeholders.

type Option

type Option func(*generationConfig)

Option defines a function type for generator configuration options.

func WithBlockedPlaceholders

func WithBlockedPlaceholders(placeholders ...string) Option

WithBlockedPlaceholders returns an Option that blocks the specified placeholders.

func WithCNPJ

func WithCNPJ(cnpj string) Option

WithCNPJ returns an Option to set a custom CNPJ.

func WithCPF

func WithCPF(cpf string) Option

WithCPF returns an Option to set a custom CPF.

type TemplateGenerator

type TemplateGenerator interface {
	Generate(options ...Option) ([]byte, error)
}

TemplateGenerator is an interface for generating XML templates.

func NewTemplateGenerator

func NewTemplateGenerator(templateType TemplateType) (TemplateGenerator, error)

NewTemplateGenerator creates a TemplateGenerator based on the provided TemplateType. It returns an error if the TemplateType is unsupported.

type TemplateType

type TemplateType int

TemplateType is a custom type representing the type of XML template.

const (
	// Define the enum values using iota for automatic incrementing.
	CFe TemplateType = iota
	NFe
	NFCe
	NFeDevolucao
)

func ParseTemplateType

func ParseTemplateType(s string) (TemplateType, error)

ParseTemplateType converts a string to a TemplateType enum. It returns an error if the input string does not match any known template type.

func (TemplateType) String

func (tt TemplateType) String() string

String returns the string representation of the TemplateType.

Jump to

Keyboard shortcuts

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