Fixes + stable gateway ids
This commit is contained in:
@@ -28,6 +28,7 @@ func DocumentTypeFromProto(t documentsv1.DocumentType) DocumentType {
|
||||
if name, ok := documentsv1.DocumentType_name[int32(t)]; ok {
|
||||
return DocumentType(name)
|
||||
}
|
||||
|
||||
return DocumentTypeUnspecified
|
||||
}
|
||||
|
||||
@@ -36,22 +37,24 @@ func (t DocumentType) Proto() documentsv1.DocumentType {
|
||||
if value, ok := documentsv1.DocumentType_value[string(t)]; ok {
|
||||
return documentsv1.DocumentType(value)
|
||||
}
|
||||
|
||||
return documentsv1.DocumentType_DOCUMENT_TYPE_UNSPECIFIED
|
||||
}
|
||||
|
||||
// ActSnapshot captures the immutable data needed to generate an acceptance act.
|
||||
type ActSnapshot struct {
|
||||
PaymentID string `bson:"paymentId" json:"paymentId"`
|
||||
Date time.Time `bson:"date" json:"date"`
|
||||
PaymentID string `bson:"paymentId" json:"paymentId"`
|
||||
Date time.Time `bson:"date" json:"date"`
|
||||
ExecutorFullName string `bson:"executorFullName" json:"executorFullName"`
|
||||
Amount decimal.Decimal `bson:"amount" json:"amount"`
|
||||
Currency string `bson:"currency" json:"currency"`
|
||||
Amount decimal.Decimal `bson:"amount" json:"amount"`
|
||||
Currency string `bson:"currency" json:"currency"`
|
||||
}
|
||||
|
||||
func (s *ActSnapshot) Normalize() {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
|
||||
s.PaymentID = strings.TrimSpace(s.PaymentID)
|
||||
s.ExecutorFullName = strings.TrimSpace(s.ExecutorFullName)
|
||||
s.Currency = strings.TrimSpace(s.Currency)
|
||||
@@ -60,21 +63,25 @@ func (s *ActSnapshot) Normalize() {
|
||||
// DocumentRecord stores document metadata and cached artefacts for a payment.
|
||||
type DocumentRecord struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
PaymentRef string `bson:"paymentRef" json:"paymentRef"`
|
||||
Snapshot ActSnapshot `bson:"snapshot" json:"snapshot"`
|
||||
StoragePaths map[DocumentType]string `bson:"storagePaths,omitempty" json:"storagePaths,omitempty"`
|
||||
Hashes map[DocumentType]string `bson:"hashes,omitempty" json:"hashes,omitempty"`
|
||||
|
||||
PaymentRef string `bson:"paymentRef" json:"paymentRef"`
|
||||
Snapshot ActSnapshot `bson:"snapshot" json:"snapshot"`
|
||||
StoragePaths map[DocumentType]string `bson:"storagePaths,omitempty" json:"storagePaths,omitempty"`
|
||||
Hashes map[DocumentType]string `bson:"hashes,omitempty" json:"hashes,omitempty"`
|
||||
}
|
||||
|
||||
func (r *DocumentRecord) Normalize() {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
|
||||
r.PaymentRef = strings.TrimSpace(r.PaymentRef)
|
||||
r.Snapshot.Normalize()
|
||||
|
||||
if r.StoragePaths == nil {
|
||||
r.StoragePaths = map[DocumentType]string{}
|
||||
}
|
||||
|
||||
if r.Hashes == nil {
|
||||
r.Hashes = map[DocumentType]string{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user