efiscal

package module
v0.0.0-...-efc34ef Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2016 License: MIT Imports: 6 Imported by: 0

README

go-enlacefiscal

Golang EnlaceFiscal.com API wrapper

Summary

Enlacefiscal.com API golang native wrapper

## Installation

go get github.com/fernandez14/go-enlacefiscal

Usage

For further information about implementing and using this wrapper please go to GoDoc documentation.

api := efiscal.API{"USERNAME", "AUTH_KEY", false} // Set third param to true in Production

// Signing RFC, Series and Folio (refer to EnlaceFiscal docs)
invoice := api.Invoice("XAXX010101000", "TEST", "1")

item := efiscal.Item{
	Quantity:    1,
	Value:       15.0,
	Unit:        "servicio",
	Description: "Servicio de Prueba",
}

// Add an item using Item struct
invoice.AddItem(item)

// Transfer current items IVA to the list of taxes
invoice.TransferIVA(16)

// One time payment using bank transfer
invoice.SetPayment(&efiscal.PAY_ONE_TIME_TRANSFER)

// Target RFC & customer
invoice.SetReceiver(&efiscal.Receiver{"XAXX010101000", "Publico en General"})

// Sign invoice
data, err := api.Sign(invoice)

if err != nil {
  panic(err)
}

Documentation

Index

Constants

View Source
const EF_DECIMALS = 2
View Source
const EF_SERVICE = "https://api.enlacefiscal.com/rest/v1/"
View Source
const EF_VERSION = "5.0"

Variables

This section is empty.

Functions

func Round

func Round(val float64, roundOn float64, places int) (newVal float64)

Types

type API

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

func Boot

func Boot(user, key string, production bool) API

func (API) Invoice

func (module API) Invoice(rfc, series, folio string) *Invoice

func (API) Sign

func (module API) Sign(invoice *Invoice) (map[string]interface{}, error)

type Address

type Address struct {
	Street       string `json:"calle"`
	Ext          string `json:"noExterior"`
	Int          string `json:"noInterior"`
	Neighborhood string `json:"colonia"`
	Locality     string `json:"localidad"`
	Town         string `json:"municipio"`
	State        string `json:"estado"`
	Country      string `json:"pais"`
	Zipcode      string `json:"cp"`
}

type Invoice

type Invoice struct {
	Mode      string   `json:"modo"`
	Version   string   `json:"versionEF"`
	Subtotal  float64  `json:"subTotal"`
	Discounts float64  `json:"descuentos"`
	Total     float64  `json:"total"`
	Decimals  int      `json:"numeroDecimales"`
	Series    string   `json:"serie"`
	Folio     string   `json:"folioInterno"`
	Emitted   JSONTime `json:"fechaEmision"`
	RFC       string   `json:"rfc"`
	Referer   string   `json:"softwareIntegrador"`

	// Nested structures
	Payment  *Payment  `json:"DatosDePago,omitempty"`
	Receiver *Receiver `json:"Receptor,omitempty"`
	Items    *Items    `json:"Partidas,omitempty"`
	Taxes    *Taxes    `json:"Impuestos,omitempty"`
	MailTo   *MailTo   `json:"EnviarCFDi,omitempty"`
}

Invoice is a representation of a sign request to EnlaceFiscal.com

func (*Invoice) AddItem

func (self *Invoice) AddItem(i Item)

Add an Item to the current invoice representation

func (*Invoice) GetSubtotal

func (self *Invoice) GetSubtotal() float64

func (*Invoice) GetTotal

func (self *Invoice) GetTotal() float64

func (*Invoice) Prepare

func (self *Invoice) Prepare()

Prepare the Invoice representation for signin

func (*Invoice) SendMail

func (self *Invoice) SendMail(list []string)

Send the invoice to list of mails

func (*Invoice) SetEmitted

func (self *Invoice) SetEmitted(t time.Time)

Sets the current invoice emitted time

func (*Invoice) SetPayment

func (self *Invoice) SetPayment(v *Payment)

Sets the current invoice representation payment settings

func (*Invoice) SetReceiver

func (self *Invoice) SetReceiver(v *Receiver)

Sets the current invoice representation receiver information (target rfc)

func (*Invoice) TransferIVA

func (self *Invoice) TransferIVA(rate float64)

Transfers IVA Taxes to the current representation

type Item

type Item struct {
	Quantity    int     `json:"cantidad"`
	Unit        string  `json:"unidad"`
	Description string  `json:"descripcion"`
	Value       float64 `json:"valorUnitario"`
	Total       float64 `json:"importe"`
}

type Items

type Items struct {
	List []Item `json:"Partida"`
}

type JSONTime

type JSONTime time.Time

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

type MailTo

type MailTo struct {
	List []string `json:"correo"`
}

type Payment

type Payment struct {
	Method string `json:"metodoDePago"`
	Type   string `json:"formaDePago"`
}
var PAY_ONE_TIME_TRANSFER Payment = Payment{
	Method: "Transferencia Electronica",
	Type:   "Pago en una sola exhibición",
}

type Receiver

type Receiver struct {
	RFC     string   `json:"rfc"`
	Name    string   `json:"nombre"`
	Address *Address `json:"DomicilioFiscal,omitempty"`
}

type Response

type Response struct {
	Body map[string]interface{} `json:"AckEnlaceFiscal"`
}

func (Response) GetError

func (self Response) GetError() error

func (Response) IsError

func (self Response) IsError() bool

type ResponseError

type ResponseError struct {
	Code        interface{}
	Reference   interface{}
	Description interface{}
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

type Tax

type Tax struct {
	Type  string  `json:"impuesto,omitempty"`
	Rate  float64 `json:"tasa,omitempty"`
	Total float64 `json:"importe,omitempty"`
}

type Taxes

type Taxes struct {
	Transfers []Tax `json:"Traslados,omitempty"`
}

Jump to

Keyboard shortcuts

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