func (cp *CommercialPaper) SetTrading() {
	cp.state = TRADING
}
SetTrading sets the state to trading
package commercialpaper
import (
	"encoding/json"
	"fmt"
	ledgerapi "github.com/hyperledger/fabric-chaincode-integration/commercialpaper/ledger-api"
)
type State uint
const (
	ISSUED State = iota + 1
	TRADING
	REDEEMED
)
func (state State) String() string {
	names := []string{"ISSUED", "TRADING", "REDEEMED"}
	if state < ISSUED || state > REDEEMED {
		return "UNKNOWN"
	}
	return names[state-1]
}
func CreateCommercialPaperKey(issuer string, paperNumber string) string {
	return ledgerapi.MakeKey(issuer, paperNumber)
}
type commercialPaperAlias CommercialPaper
type jsonCommercialPaper struct {
	*commercialPaperAlias
	State State  `json:"currentState"`
	Class string `json:"class"`
	Key   string `json:"key"`
}
type CommercialPaper struct {
	PaperNumber      string `json:"paperNumber"`
	Issuer           string `json:"issuer"`
	IssueDateTime    string `json:"issueDateTime"`
	FaceValue        int    `json:"faceValue"`
	MaturityDateTime string `json:"maturityDateTime"`
	Owner            string `json:"owner"`
	state            State  `metadata:"currentState"`
	class            string `metadata:"class"`
	key              string `metadata:"key"`
}
func (cp *CommercialPaper) UnmarshalJSON(data []byte) error {
	jcp := jsonCommercialPaper{commercialPaperAlias: (*commercialPaperAlias)(cp)}
	err := json.Unmarshal(data, &jcp)
	if err != nil {
		return err
	}
	cp.state = jcp.State
	return nil
}
func (cp CommercialPaper) MarshalJSON() ([]byte, error) {
	jcp := jsonCommercialPaper{commercialPaperAlias: (*commercialPaperAlias)(&cp), State: cp.state, Class: "org.papernet.commercialpaper", Key: ledgerapi.MakeKey(cp.Issuer, cp.PaperNumber)}
	return json.Marshal(&jcp)
}
func (cp *CommercialPaper) GetState() State {
	return cp.state
}
func (cp *CommercialPaper) SetIssued() {
	cp.state = ISSUED
}