intacct

package module
v0.0.0-...-008ca31 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 8 Imported by: 0

README

intacct-go

This repository is deprecated. The code has already been moved to the main repo: #2589

Go client for the Intacct API

THIS IS TECHNOLOGY DEMO THAT CAN CHANGE AT ANY TIME

Get all invoices for a customer:

package main

import (
    "log"

    "github.com/Galvanize-IT/intacct-go"
)

func main() {
    config := intacct.Config{
        Sender:         "SENDER",
        SenderPassword: "SENDER_PASSWORD",
        User:           "xml_gateway",
        UserPassword:   "USER_PASSWORD",
        Company:        "COMPANY",
        Location:       "1000",
    }

    api := intacct.NewAPI(config)

    // List all invoices for a customer
    invoices, err := api.Invoices.List(
        intacct.ListParams{MaxItems: 100},
        intacct.CustomerID.Equals("C-01"),
    )
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("Returned %d invoices", len(invoices))
    for _, invoice := range invoices {
        log.Println(
            invoice.InvoiceNumber,
            invoice.DatePosted,
            invoice.State,
            invoice.TotalAmount,
            invoice.DatePaid,
        )
    }
}

Galvanize Software, 2016

Documentation

Index

Constants

View Source
const (
	Posted = "Posted"
)
View Source
const (
	Failure = "failure"
	Success = "success"
)

Status consts

View Source
const (
	Asc  = "asc"
	Desc = "desc"
)
View Source
const ContentType = `x-intacct-xml-request`
View Source
const (
	Version3 = "3.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Client
	Invoices             Invoices
	Vendors              Vendors
	Customers            Customers
	Bills                Bills
	APRecurBills         APRecurBills
	APPayments           APPayments
	CCTransactions       CCTransactions
	CCTransactionEntries CCTransactionEntries
	EPPayments           EPPayments
	PODocuments          PODocuments
	Attachments          Attachments
}

func NewAPI

func NewAPI(requestClient *http.Client, config Config) (api API)

type APPayment

type APPayment struct {
	XMLName xml.Name `xml:"appymt"`

	RECORDNO                 string `xml:"RECORDNO"`
	PRBATCHKEY               string `xml:"PRBATCHKEY"`
	RECORDTYPE               string `xml:"RECORDTYPE"`
	RECORDID                 string `xml:"RECORDID"`
	FINANCIALENTITY          string `xml:"FINANCIALENTITY"`
	FINANCIALENTITYTYPE      string `xml:"FINANCIALENTITYTYPE"`
	FINANCIALACCOUNTNAME     string `xml:"FINANCIALACCOUNTNAME"`
	FINANCIALACCOUNTCURRENCY string `xml:"FINANCIALACCOUNTCURRENCY"`
	STATE                    string `xml:"STATE"`
	RAWSTATE                 string `xml:"RAWSTATE"`
	PAYMENTDATE              string `xml:"PAYMENTDATE"`
	PAYMENTMETHOD            string `xml:"PAYMENTMETHOD"`
	PAYMENTMETHODKEY         string `xml:"PAYMENTMETHODKEY"`
	PAYMENTREQUESTMETHOD     string `xml:"PAYMENTREQUESTMETHOD"`
	ENTITY                   string `xml:"ENTITY"`
	VENDORID                 string `xml:"VENDORID"`
	VENDORNAME               string `xml:"VENDORNAME"`
	DOCNUMBER                string `xml:"DOCNUMBER"`
	DESCRIPTION              string `xml:"DESCRIPTION"`
	DESCRIPTION2             string `xml:"DESCRIPTION2"`
	WHENCREATED              string `xml:"WHENCREATED"`
	WHENPAID                 string `xml:"WHENPAID"`
	BASECURR                 string `xml:"BASECURR"`
	CURRENCY                 string `xml:"CURRENCY"`
	EXCHRATEDATE             string `xml:"EXCH_RATE_DATE"`
	EXCHRATETYPEID           string `xml:"EXCH_RATE_TYPE_ID"`
	EXCHANGERATE             string `xml:"EXCHANGE_RATE"`
	TOTALENTERED             string `xml:"TOTALENTERED"`
	TOTALSELECTED            string `xml:"TOTALSELECTED"`
	TOTALPAID                string `xml:"TOTALPAID"`
	TOTALDUE                 string `xml:"TOTALDUE"`
	TRXTOTALENTERED          string `xml:"TRX_TOTALENTERED"`
	TRXTOTALSELECTED         string `xml:"TRX_TOTALSELECTED"`
	TRXTOTALPAID             string `xml:"TRX_TOTALPAID"`
	TRXTOTALDUE              string `xml:"TRX_TOTALDUE"`
	BILLTOPAYTOCONTACTNAME   string `xml:"BILLTOPAYTOCONTACTNAME"`
	PRBATCH                  string `xml:"PRBATCH"`
	AMOUNTTOPAY              string `xml:"AMOUNTTOPAY"`
	ACTION                   string `xml:"ACTION"`
	AUWHENCREATED            string `xml:"AUWHENCREATED"`
	WHENMODIFIED             string `xml:"WHENMODIFIED"`
	CREATEDBY                string `xml:"CREATEDBY"`
	MODIFIEDBY               string `xml:"MODIFIEDBY"`
	USERKEY                  string `xml:"USERKEY"`
	CLEARED                  string `xml:"CLEARED"`
	CLRDATE                  string `xml:"CLRDATE"`
	STATUS                   string `xml:"STATUS"`
	SYSTEMGENERATED          string `xml:"SYSTEMGENERATED"`
	PAYMENTPRIORITY          string `xml:"PAYMENTPRIORITY"`
	BILLTOPAYTOKEY           string `xml:"BILLTOPAYTOKEY"`
	ONHOLD                   string `xml:"ONHOLD"`
	PARENTPAYMENTKEY         string `xml:"PARENTPAYMENTKEY"`
	WHENPOSTED               string `xml:"WHENPOSTED"`
	MEGAENTITYKEY            string `xml:"MEGAENTITYKEY"`
	MEGAENTITYID             string `xml:"MEGAENTITYID"`
	MEGAENTITYNAME           string `xml:"MEGAENTITYNAME"`
}

type APPayments

type APPayments struct {
	Client
}

func (APPayments) List

func (apPayments APPayments) List(vendorID string, fromDate string, limit int) ([]APPayment, error)

type APRecurBill

type APRecurBill struct {
	XMLName     xml.Name    `xml:"aprecurbill"`
	Description string      `xml:"DESCRIPTION"`
	RecordID    string      `xml:"RECORDID"`
	DocNumber   string      `xml:"DOCNUMBER"`
	StartDate   IntacctDate `xml:"STARTDATE"`
	Mode        string      `xml:"MODENEW"`
	Internal    string      `xml:"INTERVAL"`

	RecurBillItems APRecurBillItems `xml:"RECURBILLITEMS"`
}

type APRecurBillItems

type APRecurBillItems struct {
	Amount string `xml:"AMOUNT"`
}

type APRecurBills

type APRecurBills struct {
	Client
}

func (APRecurBills) List

func (apRecurBills APRecurBills) List(vendorID string, fromDate string, limit int) ([]APRecurBill, error)

type Attachment

type Attachment struct {
	XMLName xml.Name `xml:"attachment"`

	AttachmentName string `xml:"attachmentname"`
	AttachmentType string `xml:"attachmenttype"`
	AttachmentData string `xml:"attachmentdata"`
}

type Attachments

type Attachments struct {
	Client
}

func (Attachments) Get

func (attachments Attachments) Get(key string) (Supdoc, error)

type AttachmentsXML

type AttachmentsXML struct {
	XMLName xml.Name `xml:"attachments"`

	Attachment []Attachment `xml:"attachment"`
}

type Authentication

type Authentication struct {
	XMLName xml.Name `xml:"authentication"`
	Login   Login
}

TODO Relationship to login?

type Bill

type Bill struct {
	XMLName xml.Name `xml:"apbill"`

	RecordNO                  string     `xml:"RECORDNO"`
	RecordType                string     `xml:"RECORDTYPE"`
	RecordID                  string     `xml:"RECORDID"`
	FinancialEntity           string     `xml:"FINANCIALENTITY"`
	State                     string     `xml:"STATE"`
	Rawstate                  string     `xml:"RAWSTATE"`
	VendorID                  string     `xml:"VENDORID"`
	VendorName                string     `xml:"VENDORNAME"`
	Form1099type              string     `xml:"FORM1099TYPE"`
	Form1099box               string     `xml:"FORM1099BOX"`
	Vendtype1099type          string     `xml:"VENDTYPE1099TYPE"`
	Trx_entitydue             string     `xml:"TRX_ENTITYDUE"`
	DocNumber                 string     `xml:"DOCNUMBER"`
	Description               string     `xml:"DESCRIPTION"`
	Description2              string     `xml:"DESCRIPTION2"`
	Termname                  string     `xml:"TERMNAME"`
	Termkey                   string     `xml:"TERMKEY"`
	Termvalue                 string     `xml:"TERMVALUE"`
	WhenCreated               string     `xml:"WHENCREATED"`
	WhenPosted                string     `xml:"WHENPOSTED"`
	WhenDiscount              string     `xml:"WHENDISCOUNT"`
	WhenDue                   string     `xml:"WHENDUE"`
	WhenPaid                  string     `xml:"WHENPAID"`
	Recpaymentdate            string     `xml:"RECPAYMENTDATE"`
	Paymentpriority           string     `xml:"PAYMENTPRIORITY"`
	Onhold                    bool       `xml:"ONHOLD"`
	Basecurr                  string     `xml:"BASECURR"`
	Currency                  string     `xml:"CURRENCY"`
	Exch_rate_date            string     `xml:"EXCH_RATE_DATE"`
	Exch_rate_type_id         string     `xml:"EXCH_RATE_TYPE_ID"`
	Exchange_rate             string     `xml:"EXCHANGE_RATE"`
	TotalEntered              float64    `xml:"TOTALENTERED"`
	TotalSelected             float64    `xml:"TOTALSELECTED"`
	TotalPaid                 float64    `xml:"TOTALPAID"`
	TotalDue                  float64    `xml:"TOTALDUE"`
	TrxTotalEntered           float64    `xml:"TRX_TOTALENTERED"`
	TrxTotalSelected          float64    `xml:"TRX_TOTALSELECTED"`
	TrxTotalPaid              float64    `xml:"TRX_TOTALPAID"`
	TrxTotalDue               float64    `xml:"TRX_TOTALDUE"`
	Billtopaytocontactname    string     `xml:"BILLTOPAYTOCONTACTNAME"`
	Shiptoreturntocontactname string     `xml:"SHIPTORETURNTOCONTACTNAME"`
	Billtopaytokey            string     `xml:"BILLTOPAYTOKEY"`
	Shiptoreturntokey         string     `xml:"SHIPTORETURNTOKEY"`
	Prbatch                   string     `xml:"PRBATCH"`
	Prbatchkey                string     `xml:"PRBATCHKEY"`
	Modulekey                 string     `xml:"MODULEKEY"`
	Schopkey                  string     `xml:"SCHOPKEY"`
	Systemgenerated           string     `xml:"SYSTEMGENERATED"`
	Auwhencreated             string     `xml:"AUWHENCREATED"`
	Whenmodified              string     `xml:"WHENMODIFIED"`
	Createdby                 string     `xml:"CREATEDBY"`
	Modifiedby                string     `xml:"MODIFIEDBY"`
	Due_in_days               string     `xml:"DUE_IN_DAYS"`
	SupdocID                  string     `xml:"SUPDOCID"`
	Megaentitykey             string     `xml:"MEGAENTITYKEY"`
	MegaentityID              string     `xml:"MEGAENTITYID"`
	MegaentityName            string     `xml:"MEGAENTITYNAME"`
	Vendor_notes              string     `xml:"VENDOR_NOTES"`
	Voucher_number            string     `xml:"VOUCHER_NUMBER"`
	Exchratedate              string     `xml:"EXCHRATEDATE"`
	Exchratetype              string     `xml:"EXCHRATETYPE"`
	Exchrate                  string     `xml:"EXCHRATE"`
	Paytocontactname          string     `xml:"PAYTOCONTACTNAME"`
	Returntocontactname       string     `xml:"RETURNTOCONTACTNAME"`
	BillItems                 []BillItem `xml:"APBILLITEMS"`
}

type BillItem

type BillItem struct {
	XMLName xml.Name `xml:"apbillitem"`

	Line_no           int     `xml:LINE_NO"`
	Accountno         string  `xml:ACCOUNTNO"`
	Accountlabel      string  `xml:ACCOUNTLABEL"`
	Offsetglaccountno string  `xml:OFFSETGLACCOUNTNO"`
	Trx_amount        float64 `xml:TRX_AMOUNT"`
	EntryDescription  string  `xml:ENTRYDESCRIPTION"`
	Form1099          bool    `xml:FORM1099"`
	Form1099type      string  `xml:FORM1099TYPE"`
	Form1099box       string  `xml:FORM1099BOX"`
	Billable          bool    `xml:BILLABLE"`
	Allocation        string  `xml:ALLOCATION"`
	LocationID        string  `xml:LOCATIONID"`
	DepartmentID      string  `xml:DEPARTMENTID"`
	ProjectID         string  `xml:PROJECTID"`
	CustomerID        string  `xml:CUSTOMERID"`
	VendorID          string  `xml:VENDORID"`
	EmployeeID        string  `xml:EMPLOYEEID"`
	ItemID            string  `xml:ITEMID"`
	ClassID           string  `xml:CLASSID"`
	ContractID        string  `xml:CONTRACTID"`
	WarehouseID       string  `xml:WAREHOUSEID"`
	// Gldim int `xml:GLDIM"`
	Custom string `xml:Custom"`
}

type Bills

type Bills struct {
	Client
}

func (Bills) List

func (bills Bills) List(vendorID string, fromDate string, limit int) ([]Bill, error)

type CCTransaction

type CCTransaction struct {
	XMLName xml.Name `xml:"cctransaction"`

	RECORDNO        string `xml:"RECORDNO"`
	FINANCIALENTITY string `xml:"FINANCIALENTITY"`
	WHENCREATED     string `xml:"WHENCREATED"`
	RECORDID        string `xml:"RECORDID"`
	RECORDTYPE      string `xml:"RECORDTYPE"`
	DESCRIPTION2    string `xml:"DESCRIPTION2"`
	DESCRIPTION     string `xml:"DESCRIPTION"`
	PRBATCHKEY      string `xml:"PRBATCHKEY"`
	BASECURR        string `xml:"BASECURR"`
	CURRENCY        string `xml:"CURRENCY"`
	EXCHRATEDATE    string `xml:"EXCH_RATE_DATE"`
	EXCHRATETYPEID  string `xml:"EXCH_RATE_TYPE_ID"`
	EXCHANGERATE    string `xml:"EXCHANGE_RATE"`
	TOTALENTERED    string `xml:"TOTALENTERED"`
	TRXTOTALENTERED string `xml:"TRX_TOTALENTERED"`
	TOTALPAID       string `xml:"TOTALPAID"`
	TRXTOTALPAID    string `xml:"TRX_TOTALPAID"`
	WHENPAID        string `xml:"WHENPAID"`
	REVERSALKEY     string `xml:"REVERSALKEY"`
	REVERSALDATE    string `xml:"REVERSALDATE"`
	REVERSEDKEY     string `xml:"REVERSEDKEY"`
	REVERSEDDATE    string `xml:"REVERSEDDATE"`
	STATE           string `xml:"STATE"`
	RAWSTATE        string `xml:"RAWSTATE"`
	CLEARED         string `xml:"CLEARED"`
	PAYMENTKEY      string `xml:"PAYMENTKEY"`
	AUWHENCREATED   string `xml:"AUWHENCREATED"`
	WHENMODIFIED    string `xml:"WHENMODIFIED"`
	CREATEDBY       string `xml:"CREATEDBY"`
	MODIFIEDBY      string `xml:"MODIFIEDBY"`
	MEGAENTITYKEY   string `xml:"MEGAENTITYKEY"`
	MEGAENTITYID    string `xml:"MEGAENTITYID"`
	MEGAENTITYNAME  string `xml:"MEGAENTITYNAME"`
}

type CCTransactionEntries

type CCTransactionEntries struct {
	Client
}

func (CCTransactionEntries) ListByTransactionIds

func (ccTransactionEntries CCTransactionEntries) ListByTransactionIds(transactionIDs []string) ([]CCTransactionEntry, error)

type CCTransactionEntry

type CCTransactionEntry struct {
	XMLName xml.Name `xml:"cctransactionentry"`

	RECORDNO        string `xml:"RECORDNO"`
	RECORDKEY       string `xml:"RECORDKEY"`
	RECORDTYPE      string `xml:"RECORDTYPE"`
	ACCOUNTKEY      string `xml:"ACCOUNTKEY"`
	ACCOUNTNO       string `xml:"ACCOUNTNO"`
	ACCOUNTTITLE    string `xml:"ACCOUNTTITLE"`
	ACCOUNTLABELKEY string `xml:"ACCOUNTLABELKEY"`
	ACCOUNTLABEL    string `xml:"ACCOUNTLABEL"`
	AMOUNT          string `xml:"AMOUNT"`
	TRXAMOUNT       string `xml:"TRX_AMOUNT"`
	DEPT            string `xml:"DEPT"`
	DEPARTMENTID    string `xml:"DEPARTMENTID"`
	DEPARTMENTNAME  string `xml:"DEPARTMENTNAME"`
	LOCATION        string `xml:"LOCATION"`
	LOCATIONID      string `xml:"LOCATIONID"`
	LOCATIONNAME    string `xml:"LOCATIONNAME"`
	DESCRIPTION     string `xml:"DESCRIPTION"`
	EXCHRATEDATE    string `xml:"EXCH_RATE_DATE"`
	EXCHRATETYPEID  string `xml:"EXCH_RATE_TYPE_ID"`
	EXCHANGERATE    string `xml:"EXCHANGE_RATE"`
	LINEITEM        string `xml:"LINEITEM"`
	LINENO          string `xml:"LINE_NO"`
	CURRENCY        string `xml:"CURRENCY"`
	BASECURR        string `xml:"BASECURR"`
	STATUS          string `xml:"STATUS"`
	TOTALPAID       string `xml:"TOTALPAID"`
	TRXTOTALPAID    string `xml:"TRX_TOTALPAID"`
	DEPARTMENTKEY   string `xml:"DEPARTMENTKEY"`
	LOCATIONKEY     string `xml:"LOCATIONKEY"`
	WHENCREATED     string `xml:"WHENCREATED"`
	WHENMODIFIED    string `xml:"WHENMODIFIED"`
	CREATEDBY       string `xml:"CREATEDBY"`
	MODIFIEDBY      string `xml:"MODIFIEDBY"`
	PROJECTDIMKEY   string `xml:"PROJECTDIMKEY"`
	PROJECTID       string `xml:"PROJECTID"`
	PROJECTNAME     string `xml:"PROJECTNAME"`
	CUSTOMERDIMKEY  string `xml:"CUSTOMERDIMKEY"`
	CUSTOMERID      string `xml:"CUSTOMERID"`
	CUSTOMERNAME    string `xml:"CUSTOMERNAME"`
	VENDORDIMKEY    string `xml:"VENDORDIMKEY"`
	VENDORID        string `xml:"VENDORID"`
	VENDORNAME      string `xml:"VENDORNAME"`
	EMPLOYEEDIMKEY  string `xml:"EMPLOYEEDIMKEY"`
	EMPLOYEEID      string `xml:"EMPLOYEEID"`
	EMPLOYEENAME    string `xml:"EMPLOYEENAME"`
	ITEMDIMKEY      string `xml:"ITEMDIMKEY"`
	ITEMID          string `xml:"ITEMID"`
	ITEMNAME        string `xml:"ITEMNAME"`
	CLASSDIMKEY     string `xml:"CLASSDIMKEY"`
	CLASSID         string `xml:"CLASSID"`
	CLASSNAME       string `xml:"CLASSNAME"`
}

RECORDKEY is foreign key of CCTransaction.RECORDNO

type CCTransactions

type CCTransactions struct {
	Client
}

func (CCTransactions) List

func (ccTransactions CCTransactions) List(fromDate string, limit int) ([]CCTransaction, error)

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

func (Client) CheckResponseErrors

func (c Client) CheckResponseErrors(body Response) error

func (Client) NewRequest

func (c Client) NewRequest(m Method) (*http.Request, error)

NewRequest creates a request, but does not execute it TODO Errors? TODO accept method? TODO Pass operations instead?

type Config

type Config struct {
	Sender         string
	SenderPassword string
	User           string
	UserPassword   string
	Company        string
	Location       string // Optional
}

Config hold the required and optional credentials for a query

func Env

func Env() Config

TODO Create a config from ENV variables

func Parse

func Parse() (config Config)

TODO Parse a JSON file

func (Config) IsValid

func (config Config) IsValid() bool

IsValid returns true if sender, sender password, user, user password, and company are all set

type Content

type Content struct {
	Functions []interface{} `xml:"function"`
}

type Control

type Control struct {
	XMLName           xml.Name `xml:"control"`
	Status            string   `xml:"status,omitempty"` // Only response
	SenderID          string   `xml:"senderid"`
	Password          string   `xml:"password"`
	ControlID         string   `xml:"controlid"`
	UniqueID          bool     `xml:"uniqueid"`
	DTDVersion        string   `xml:"dtdversion"`
	Includewhitespace bool     `xml:"includewhitespace"`
}

func NewControlV2

func NewControlV2(sender, password string) Control

type Customer

type Customer struct{}

type Customers

type Customers struct {
	Client
}

func (Customers) Get

func (cust Customers) Get(id string) (Customer, error)

Get returns a Customer by customer ID

func (Customers) List

func (cust Customers) List(params ...ListParams) ([]Customer, error)

TODO What about meta information? Attach to a List type?

type Data

type Data struct {
	NumRemaining int    `xml:"numRemaining,attr"`
	ResultId     string `xml:"resultId,attr"`
	TotalCount   int    `xml:"totalcount,attr"`

	Invoices             []Invoice            `xml:"invoice"`
	Vendors              []Vendor             `xml:"vendor"`
	Bills                []Bill               `xml:"apbill"`
	APRecurBills         []APRecurBill        `xml:"aprecurbill"`
	APPayments           []APPayment          `xml:"appymt"`
	CCTransactions       []CCTransaction      `xml:"cctransaction"`
	CCTransactionEntries []CCTransactionEntry `xml:"cctransactionentry"`
	EPPayments           []EPPayment          `xml:"eppayment"`
	PODocuments          []PODocument         `xml:"podocument"`
	Customers            []Customer           `xml:"customer"`

	Supdocs []Supdoc `xml:"supdoc"`
}

type Date

type Date struct {
	time.Time
}

func NewDate

func NewDate(year int, month time.Month, day int) Date

func (Date) MarshalXML

func (date Date) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (Date) String

func (d Date) String() string

Use american format 1/2/2006

func (*Date) UnmarshalXML

func (date *Date) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type DateParts

type DateParts struct {
	Year  int        `xml:"year"`
	Day   int        `xml:"day"`
	Month time.Month `xml:"month"`
}

TODO Case sensitivity?

type EPPayment

type EPPayment struct {
	XMLName xml.Name `xml:"eppayment"`

	RecordNo    string `xml:"RECORDNO"`
	WhenCreated string `xml:"WHENCREATED"`
	Description string `xml:"DESCRIPTION"`
	WhenPaid    string `xml:"WHENPAID"`
	Currency    string `xml:"CURRENCY"`
	Total       string `xml:"TOTALENTERED"`
}

type EPPayments

type EPPayments struct {
	Client
}

func (EPPayments) List

func (epPayments EPPayments) List(fromDate string, limit int) ([]EPPayment, error)

type Error

type Error struct {
	Number       string `xml:"error>errorno"`
	Description  string `xml:"error>description"`
	Description2 string `xml:"error>description2"`
	Correction   string `xml:"error>correction"`
}

func (Error) String

func (err Error) String() string

type ErrorMessage

type ErrorMessage struct {
	XMLName xml.Name `xml:"errormessage"`

	Errors []ResponseError `xml:"error"`
}

type Expression

type Expression struct {
	XMLName  xml.Name `xml:"expression"`
	Field    string   `xml:"field"`
	Operator string   `xml:"operator"`
	Value    string   `xml:"value"`
}

func Equal

func Equal(field, value string) Expression

TODO string or String() interface?

func GTE

func GTE(field, value string) Expression

func GreaterThan

func GreaterThan(field, value string) Expression

func LTE

func LTE(field, value string) Expression

func LessThan

func LessThan(field, value string) Expression

func NewExpression

func NewExpression(field, operator, value string) Expression

func (Expression) IsEmpty

func (ex Expression) IsEmpty() bool

type Field

type Field string
const (
	Name        Field = "name"
	CustomerID  Field = "customerid"
	InvoiceNo   Field = "invoiceno"
	DateCreated Field = "datecreated"
	DatePosted  Field = "dateposted"
	DateDue     Field = "datedue"
	DatePaid    Field = "datepaid"
	State       Field = "state"
)

TODO list all possible fields?

func (Field) Equals

func (f Field) Equals(value string) Expression

func (Field) GTE

func (f Field) GTE(value string) Expression

func (Field) GreaterThan

func (f Field) GreaterThan(value string) Expression

func (Field) LTE

func (f Field) LTE(value string) Expression

func (Field) LessThan

func (f Field) LessThan(value string) Expression

type Function

type Function struct {
	XMLName xml.Name `xml:"function"`
	Method
	ControlID string `xml:"controlid,attr"`
}

type Get

type Get struct {
	XMLName xml.Name `xml:"get"`

	Object string `xml:"object,attr"`
	Key    string `xml:"key,attr"`
}

type GetList

type GetList struct {
	XMLName xml.Name `xml:"get_list"`
	Object  string   `xml:"object,attr"`
	ListParams
}

TODO Or Common method and change the Name field...?

type IntacctDate

type IntacctDate struct {
	Year  string `xml:"YEAR"`
	Month string `xml:"MONTH"`
	Day   string `xml:"DAY"`
}

type Invoice

type Invoice struct {
	XMLName       xml.Name  `xml:"invoice"`
	Key           string    `xml:"key"`
	CustomerID    string    `xml:"customerid"`
	DateCreated   Date      `xml:"datecreated"`
	DatePosted    Date      `xml:"dateposted"`
	DateDue       Date      `xml:"datedue"`
	DatePaid      Date      `xml:"datepaid"`
	TermName      string    `xml:"termname"` // TODO ENUM?
	BatchKey      string    `xml:"batchkey"` // int?
	InvoiceNumber string    `xml:"invoiceno"`
	PONumber      string    `xml:"ponumber"`
	TotalAmount   float64   `xml:"totalamount"`
	TotalPaid     float64   `xml:"totalpaid"`
	TotalDue      float64   `xml:"totaldue"`
	Description   string    `xml:"description"`
	Currency      string    `xml:"currency"`
	BillTo        string    `xml:"billto>contactname"`
	ShipTo        string    `xml:"shipto>contactname"`
	State         string    `xml:"state"`
	Items         LineItems `xml:"invoiceitems>lineitem"`
}

type Invoices

type Invoices struct {
	Client
}

func (Invoices) Get

func (inv Invoices) Get(id string) (Invoice, error)

Get returns an Invoice by invoice ID

func (Invoices) List

func (inv Invoices) List(params ...interface{}) ([]Invoice, error)

TODO Accept params - filtering and sorting Allow params: * ListParams * Expression * SortField TODO common list building

type LineItem

type LineItem struct {
	LineNumber      string  `xml:"line_num"`
	AccountLabel    string  `xml:"accountlabel"`
	GLAccountNumber string  `xml:"glaccountno"`
	Amount          float64 `xml:"amount"`
	Memo            string  `xml:"memo"`
	LocationID      string  `xml:"locationid"`   // TODO int?
	DepartmentID    string  `xml:"departmentid"` // TODO int?
	Key             string  `xml:"key"`          // TODO int?
	TotalPaid       float64 `xml:"totalpaid"`
	TotalDue        float64 `xml:"totaldue"`
	// TRX?
	Currency    string `xml:"currency"`
	CustomerKey string `xml:"customerkey"`
}

type LineItems

type LineItems []LineItem

type ListParams

type ListParams struct {
	MaxItems uint64  `xml:"maxitems,attr"`
	Filter   Logical `xml:"filter,omitempty"`
	Sorts    Sorts   `xml:"sorts"`
}

TODO params should include filters, sorts, max items? Filters and sorts can be attached to the params or passed directly to List TODO How to support multiple or nested filter expressions?

func (ListParams) Merge

func (l ListParams) Merge(other ListParams) ListParams

Merge will merge two ListParams - the given values (if non-zero) take precedence

type Logical

type Logical struct {
	Filters  []Expression `xml:"expression"`
	Operator string       `xml:"-"`
}

TODO the dream of nesting is not yet alive

func AllOf

func AllOf(expressions ...Expression) (logical Logical)

func AnyOf

func AnyOf(expressions ...Expression) (logical Logical)

func (Logical) MarshalXML

func (l Logical) MarshalXML(e *xml.Encoder, start xml.StartElement) error

TODO errors ignored

type Login

type Login struct {
	XMLName    xml.Name `xml:"login"`
	UserID     string   `xml:"userid"`
	CompanyID  string   `xml:"companyid"`
	Password   string   `xml:"password"`
	LocationID string   `xml:"locationid,omitempty"`
}

func NewLogin

func NewLogin(user, company, password string) Login

type Method

type Method interface{}

TODO Method is not a good name... TODO Having an empty interface is also terrible

type PODocument

type PODocument struct {
	XMLName xml.Name `xml:"podocument"`

	RecordNo     string `xml:"RECORDNO"`
	DocNo        string `xml:"DOCNO"`
	DocID        string `xml:"DOCID"`
	PONumber     string `xml:"PONUMBER"`
	WhenCreated  string `xml:"WHENCREATED"`
	CustVendID   string `xml:"CUSTVENDID"`
	CustVendName string `xml:"CUSTVENDNAME"`
	DocParClass  string `xml:"DOCPARCLASS"`
	Note         string `xml:"NOTE"`
	Message      string `xml:"MESSAGE"`
	Total        string `xml:"TOTAL"`
	Currency     string `xml:"CURRENCY"`
}

type PODocuments

type PODocuments struct {
	Client
}

func (PODocuments) List

func (poDocuments PODocuments) List(vendorID string, fromDate string, limit int) ([]PODocument, error)

type ReadByQuery

type ReadByQuery struct {
	XMLName  xml.Name `xml:"readByQuery"`
	Object   string   `xml:"object"`
	Fields   string   `xml:"fields"`
	Query    string   `xml:"query"`
	Pagesize int      `xml:"pagesize"`
}

type ReadMore

type ReadMore struct {
	XMLName  xml.Name `xml:"readMore"`
	ResultId string   `xml:"resultId"`
}

type Request

type Request struct {
	XMLName   xml.Name `xml:"request"`
	Control   Control
	Operation RequestOperation
}

func NewRequestV2

func NewRequestV2(config Config, fn interface{}) Request

type RequestOperation

type RequestOperation struct {
	XMLName        xml.Name `xml:"operation"`
	Authentication Authentication
	Content        Content `xml:"content"`
}

type Response

type Response struct {
	XMLName   xml.Name `xml:"response"`
	Control   Control
	Operation ResultOperation
	Errors    []Error `xml:"errormessage"`
}

TODO Set result type method?

type ResponseError

type ResponseError struct {
	XMLName xml.Name `xml:"error"`

	ErrorNo      string `xml:"errorno"`
	Description  string `xml:"description"`
	Description2 string `xml:"description2"`
	Correction   string `xml:"correction"`
}

type Result

type Result struct {
	Status       string `xml:"status"`
	Function     string `xml:"function"`
	ControlID    string `xml:"controlid"`
	ListType     string `xml:"listtype"`
	ErrorMessage ErrorMessage

	Data Data `xml:"data"`
}

TODO Or use delayed parsing?

type ResultOperation

type ResultOperation struct {
	XMLName        xml.Name `xml:"operation"`
	Authentication Authentication
	Content        Content `xml:"content"`
	Result         Result  `xml:"result"`
}

type SortField

type SortField struct {
	XMLName xml.Name `xml:"sortfield"`
	Order   string   `xml:"order,attr"`
	Value   string   `xml:",chardata"`
}

func SortAsc

func SortAsc(value string) SortField

TODO value type?

func SortDesc

func SortDesc(value string) SortField

type Sorts

type Sorts []SortField

func (Sorts) MarshalXML

func (sorts Sorts) MarshalXML(e *xml.Encoder, start xml.StartElement) error

Omit if zero length

type Supdoc

type Supdoc struct {
	XMLName xml.Name `xml:"supdoc"`

	Recordno     string `xml:"recordno"`
	Supdocid     string `xml:"supdocid"`
	Supdocname   string `xml:"supdocname"`
	Folder       string `xml:"folder"`
	Description  string `xml:"description"`
	Creationdate string `xml:"creationdate"`
	Createdby    string `xml:"createdby"`

	Attachments AttachmentsXML `xml:"attachments"`
}

type Vendor

type Vendor struct {
	XMLName xml.Name `xml:"vendor"`

	VendorID              string `xml:"VENDORID"`
	Name                  string `xml:"NAME"`
	Printas               string `xml:"DISPLAYCONTACT>PRINTAS"`
	Companyname           string `xml:"DISPLAYCONTACT>COMPANYNAME"`
	Taxable               string `xml:"DISPLAYCONTACT>TAXABLE"`
	Taxgroup              string `xml:"DISPLAYCONTACT>TAXGROUP"`
	Prefix                string `xml:"DISPLAYCONTACT>PREFIX"`
	Firstname             string `xml:"DISPLAYCONTACT>FIRSTNAME"`
	Lastname              string `xml:"DISPLAYCONTACT>LASTNAME"`
	Initial               string `xml:"DISPLAYCONTACT>INITIAL"`
	Phone1                string `xml:"DISPLAYCONTACT>PHONE1"`
	Phone2                string `xml:"DISPLAYCONTACT>PHONE2"`
	Cellphone             string `xml:"DISPLAYCONTACT>CELLPHONE"`
	Pager                 string `xml:"DISPLAYCONTACT>PAGER"`
	Fax                   string `xml:"DISPLAYCONTACT>FAX"`
	Email1                string `xml:"DISPLAYCONTACT>EMAIL1"`
	Email2                string `xml:"DISPLAYCONTACT>EMAIL2"`
	Url1                  string `xml:"DISPLAYCONTACT>URL1"`
	Url2                  string `xml:"DISPLAYCONTACT>URL2"`
	Address1              string `xml:"DISPLAYCONTACT>MAILADDRESS>ADDRESS1"`
	Address2              string `xml:"DISPLAYCONTACT>MAILADDRESS>ADDRESS2"`
	City                  string `xml:"DISPLAYCONTACT>MAILADDRESS>CITY"`
	State                 string `xml:"DISPLAYCONTACT>MAILADDRESS>STATE"`
	Zip                   string `xml:"DISPLAYCONTACT>MAILADDRESS>ZIP"`
	Country               string `xml:"DISPLAYCONTACT>MAILADDRESS>COUNTRY"`
	Onetime               bool   `xml:"ONETIME"`
	Status                string `xml:"STATUS"`
	Hidedisplaycontact    string `xml:"HIDEDISPLAYCONTACT"`
	Vendtype              string `xml:"VENDTYPE"`
	Parentid              string `xml:"PARENTID"`
	Glgroup               string `xml:"GLGROUP"`
	Taxid                 string `xml:"TAXID"`
	Name1099              string `xml:"NAME1099"`
	Form1099type          string `xml:"FORM1099TYPE"`
	Form1099box           string `xml:"FORM1099BOX"`
	Supdocid              string `xml:"SUPDOCID"`
	Apaccount             string `xml:"APACCOUNT"`
	Creditlimit           string `xml:"CREDITLIMIT"`
	Onhold                string `xml:"ONHOLD"`
	Donotcutcheck         string `xml:"DONOTCUTCHECK"`
	Comments              string `xml:"COMMENTS"`
	Currency              string `xml:"CURRENCY"`
	Contactinfo           string `xml:"CONTACTINFO>CONTACTNAME"`
	Payto                 string `xml:"PAYTO>CONTACTNAME"`
	ReturnTo              string `xml:"CONTACTNAME>RETURNTO"`
	Paymethodkey          string `xml:"PAYMETHODKEY"`
	Mergepaymentreq       string `xml:"MERGEPAYMENTREQ"`
	Paymentnotify         bool   `xml:"PAYMENTNOTIFY"`
	Billingtype           string `xml:"BILLINGTYPE"`
	Paymentpriority       string `xml:"PAYMENTPRIORITY"`
	Termname              string `xml:"TERMNAME"`
	Displaytermdiscount   string `xml:"DISPLAYTERMDISCOUNT"`
	Achenabled            string `xml:"ACHENABLED"`
	Achbankroutingnumber  string `xml:"ACHBANKROUTINGNUMBER"`
	Achaccountnumber      string `xml:"ACHACCOUNTNUMBER"`
	Achaccounttype        string `xml:"ACHACCOUNTTYPE"`
	Achremittancetype     string `xml:"ACHREMITTANCETYPE"`
	Vendoraccountno       string `xml:"VENDORACCOUNTNO"`
	Displayacctnocheck    string `xml:"DISPLAYACCTNOCHECK"`
	Objectrestriction     string `xml:"OBJECTRESTRICTION"`
	Restrictedlocations   string `xml:"RESTRICTEDLOCATIONS"`
	Restricteddepartments string `xml:"RESTRICTEDDEPARTMENTS"`
	Customfield1          string `xml:"CUSTOMFIELD1"`
}

type Vendors

type Vendors struct {
	Client
}

func (Vendors) List

func (vendors Vendors) List(limit int) ([]Vendor, error)

func (Vendors) ListByQuery

func (vendors Vendors) ListByQuery(limit int, query string) ([]Vendor, error)

Jump to

Keyboard shortcuts

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