Browse Source

AddTransaction: add preliminary structure

master
Gerdriaan Mulder 6 years ago
parent
commit
65ba799825
  1. 6
      pain/api.go
  2. 25
      pain/payment_information_transactions.go

6
pain/api.go

@ -87,6 +87,10 @@ func (d *Document) Finalize(msgId string) error {
return d.Valid() return d.Valid()
} }
func (d *Document) AddTransaction() { func (d *Document) AddTransaction(tx *DrctDbtTxInf) error {
if len(d.Contents.PaymentInformation) == 0 {
return fmt.Errorf("payment information not yet initialized")
}
return nil
} }

25
pain/payment_information_transactions.go

@ -15,6 +15,31 @@ type DrctDbtTxInf struct {
Info RmtInf `xml:"RmtInf"` Info RmtInf `xml:"RmtInf"`
} }
func NewDirectDebitTransaction(debtor Dbtr, account DbtrAcct, mandateInfo MndtRltdInf, amount float64, additionalInfo string) DrctDbtTxInf {
e2eid := fmt.Sprintf("%v%4d", time.Now().Format("20060102"), 4) // TODO: inform this function of current number of transactions
return DrctDbtTxInf{
Id: PaymentId{
InstrumentId: "asdfasdf",
EndToEndId: e2eid,
},
Amount: CurrencyWithAmount{
Currency: "EUR",
Value: fmt.Sprintf("%.2f", amount),
},
Transaction: DrctDbtTx{
MandateRelatedInfo: mandateInfo,
},
Agent: DbtrAgt{
InstitutionId: FinInstnId{
BIC: "KNABNL2H", // fixme
},
},
Debtor: debtor,
Account: account,
Info: additionalInfo,
}
}
func (d *DrctDbtTxInf) Valid() error { func (d *DrctDbtTxInf) Valid() error {
var err []string var err []string
if e := d.Id.Valid(); e != nil { if e := d.Id.Valid(); e != nil {

Loading…
Cancel
Save