| 1 |
package spread
|
| 2 |
|
| 3 |
// CutRate is the only number in Spread's business model: we keep this
|
| 4 |
// fraction of the savings we find, and nothing else. If savings are zero,
|
| 5 |
// our cut is zero.
|
| 6 |
const CutRate = 0.20
|
| 7 |
|
| 8 |
// LineItem is one row of an uploaded bill of materials, after parsing.
|
| 9 |
// UnitPrice is what the customer pays today (their "market" price).
|
| 10 |
type LineItem struct {
|
| 11 |
Line int `json:"line"`
|
| 12 |
PartNumber string `json:"part_number"`
|
| 13 |
Description string `json:"description"`
|
| 14 |
Manufacturer string `json:"manufacturer,omitempty"`
|
| 15 |
Quantity float64 `json:"quantity"`
|
| 16 |
UnitPrice float64 `json:"unit_price"`
|
| 17 |
}
|
| 18 |
|
| 19 |
// AnalyzedLine is a LineItem re-quoted against the supplier catalog.
|
| 20 |
type AnalyzedLine struct {
|
| 21 |
LineItem
|
| 22 |
SpreadPrice float64 `json:"spread_price"`
|
| 23 |
UnitSaving float64 `json:"unit_saving"`
|
| 24 |
LineMarket float64 `json:"line_market"`
|
| 25 |
LineSpread float64 `json:"line_spread"`
|
| 26 |
LineSaving float64 `json:"line_saving"`
|
| 27 |
// Matched is true when the part was found by exact part number in the
|
| 28 |
// catalog; false when the price was estimated from the category model.
|
| 29 |
Matched bool `json:"matched"`
|
| 30 |
}
|
| 31 |
|
| 32 |
// Totals is the summary block shown under the table.
|
| 33 |
type Totals struct {
|
| 34 |
Lines int `json:"lines"`
|
| 35 |
Market float64 `json:"market"`
|
| 36 |
Spread float64 `json:"spread"`
|
| 37 |
Savings float64 `json:"savings"`
|
| 38 |
OurCut float64 `json:"our_cut"`
|
| 39 |
NetSavings float64 `json:"net_savings"`
|
| 40 |
CutRate float64 `json:"cut_rate"`
|
| 41 |
}
|
| 42 |
|
| 43 |
// Report is the full analysis returned to the client.
|
| 44 |
type Report struct {
|
| 45 |
BOMRef string `json:"bom_ref"`
|
| 46 |
Lines []AnalyzedLine `json:"lines"`
|
| 47 |
Totals Totals `json:"totals"`
|
| 48 |
}
|