You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
1.9 KiB
91 lines
1.9 KiB
package pain
|
|
|
|
import (
|
|
// "fmt"
|
|
"time"
|
|
)
|
|
|
|
func NewDocument(initParty string) *Document {
|
|
return &Document{
|
|
XmlnsXsi: PAIN_XMLNS_XSI,
|
|
Namespace: PAIN_XMLNS,
|
|
Contents: &PainXML{
|
|
GroupHeader: NewGrpHdr(initParty),
|
|
PaymentInformation: make([]PmtInf, 0),
|
|
TransactionInformation: make([]TxInf, 0),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (d *Document) SetMeta(creditorName, creditorAddr1, creditorAddr2, creditorIBAN, creditorBIC,
|
|
creditorId string, collectionDate time.Time, sequenceType string) {
|
|
creditor := Cdtr{
|
|
Name: creditorName,
|
|
PostalAddress: PstlAdr{
|
|
Country: "NL", // XXX: make customizable?
|
|
AddressLines: []AdrLine{
|
|
AdrLine(creditorAddr1),
|
|
AdrLine(creditorAddr2),
|
|
},
|
|
},
|
|
}
|
|
creditorAccount := CdtrAcct{
|
|
Id: IBAN{
|
|
IBAN: creditorIBAN,
|
|
},
|
|
}
|
|
creditorAgent := CdtrAgt{
|
|
InstitutionId: FinInstnId{
|
|
BIC: creditorBIC,
|
|
},
|
|
}
|
|
creditorSchemeId := CdtrSchmeId{
|
|
Id: NewPartyIdSEPA3(creditorId),
|
|
}
|
|
|
|
paymentInfo := PmtInf{
|
|
//Id: set in Finalize()
|
|
Method: "DD",
|
|
PaymentMeta: PmtTpInf{
|
|
ServiceLevel: Code{
|
|
Code: "SEPA",
|
|
},
|
|
LocalInstrument: Code{
|
|
Code: "CORE",
|
|
},
|
|
SequenceType: sequenceType,
|
|
},
|
|
CollectionDate: collectionDate.Format("2006-01-02"),
|
|
Creditor: creditor,
|
|
CreditorAccount: creditorAccount,
|
|
CreditorAgent: creditorAgent,
|
|
SchemeId: creditorSchemeId,
|
|
Transactions: make([]DrctDbtTxInf, 0),
|
|
}
|
|
d.Contents.PaymentInformation = append(d.Contents.PaymentInformation, paymentInfo)
|
|
}
|
|
|
|
func (d *Document) Finalize(msgId string) error {
|
|
// GroupHeader:
|
|
// Calculate CtrlSum
|
|
// Set Timestamp
|
|
// Set number of transactions
|
|
// Set msgId
|
|
|
|
/*
|
|
if len(d.Contents.PaymentInformation) == 0 {
|
|
return fmt.Errorf("no payment information, aborting")
|
|
}
|
|
if len(d.Contents.TransactionInformation) == 0 {
|
|
return fmt.Errorf("no transaction information, aborting")
|
|
}
|
|
*/
|
|
|
|
//csum := 0.0
|
|
|
|
return d.Valid()
|
|
}
|
|
|
|
func (d *Document) AddTransaction() {
|
|
|
|
}
|
|
|