Skip to content

Commit

Permalink
add approved proposals list to invoice record
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp committed Aug 12, 2020
1 parent 9fe258c commit c08e17b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions politeiawww/api/cms/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ type InvoiceRecord struct {
Input InvoiceInput `json:"input"` // Decoded invoice from invoice.json file
Payment PaymentInformation `json:"payment"` // Payment information for the Invoice
Total int64 `json:"total"` // Total amount that the invoice is billing
ApprovedProposals []string `json:"approvedproposals"` // List of proposals from this invoice that have been approved
CensorshipRecord www.CensorshipRecord `json:"censorshiprecord"`
}

Expand Down
1 change: 1 addition & 0 deletions politeiawww/cmsdatabase/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type Invoice struct {
ContractorContact string
ContractorRate uint
PaymentAddress string
ApprovedProposals []string

LineItems []LineItem // All line items parsed from the raw invoice provided.
Changes []InvoiceChange // All status changes that the invoice has had.
Expand Down
16 changes: 16 additions & 0 deletions politeiawww/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,22 @@ func convertRecordToDatabaseInvoice(p pd.Record) (*cmsdatabase.Invoice, error) {
payment.AmountReceived = s.AmountReceived
}
dbInvoice.Payments = payment
case mdstream.IDInvoiceProposalApprove:
ipa, err := mdstream.DecodeInvoiceProposalApprove([]byte(m.Payload))
if err != nil {
log.Errorf("convertInvoiceFromCache: decode md stream: "+
"token:%v error:%v payload:%v",
p.CensorshipRecord.Token, err, m)
continue
}
var approvedProposals []string
for _, s := range ipa {
if approvedProposals == nil {
approvedProposals = make([]string, 0, 1048)
} else {
approvedProposals = append(approvedProposals, s.Token)
}
}
default:
// Log error but proceed
log.Errorf("initializeInventory: invalid "+
Expand Down

0 comments on commit c08e17b

Please sign in to comment.