lib/app/transaction-services.go

29 lines
832 B
Go
Raw Permalink Normal View History

2021-02-02 04:19:16 +00:00
package app
import (
"code.tnxs.net/taxnexus/lib/api/regs/regs_client/transaction"
"code.tnxs.net/taxnexus/lib/api/regs/regs_models"
)
// PostTransactions is a first class object type storage method
func PostTransactions(objList []*TaxTransaction, principal *User) error {
swagList := []*regs_models.Transaction{}
for _, itm := range objList {
swagList = append(swagList, &regs_models.Transaction{
AccountID: itm.AccountID,
TaxTransactionID: itm.ID,
TaxTypeID: itm.TaxTypeID,
Valid: true,
})
}
regsParams := transaction.NewPostTransactionsParamsWithTimeout(postTimeout)
regsParams.TransactionRequest = &regs_models.TransactionRequest{
Data: swagList,
}
_, err := regsClient.Transaction.PostTransactions(regsParams, principal.Auth)
if err != nil {
return err
}
return nil
}