Browse Source

Texts are fixed price, regardless of destination

master
Gerdriaan Mulder 6 years ago
parent
commit
16e815b57f
  1. 32
      combine.go

32
combine.go

@ -5,24 +5,11 @@ import (
)
func CombineTextCDRs(cdrLines []Line, prices []Price) ([]Text, error) {
// Preprocess the price list into a map of "destination" -> Price, filter out the Text destinations, and count how many Text CDRs we have
destinationToPriceLine := make(map[string]Price)
numTextCDRs := 0
for _, l := range cdrLines {
if l.Kind != TextLine {
continue
}
if _, ok := destinationToPriceLine[l.Destination]; !ok {
for _, p := range prices {
if p.Type != PriceText {
continue
}
if p.Destination == l.Destination {
destinationToPriceLine[l.Destination] = p
break
}
}
}
numTextCDRs++
}
@ -36,8 +23,8 @@ func CombineTextCDRs(cdrLines []Line, prices []Price) ([]Text, error) {
ret[i] = Text{
PricedLine{
Line: l,
Cost: destinationToPriceLine[l.Destination].BuyEach,
Price: destinationToPriceLine[l.Destination].SellEach,
Cost: TEXT_OUTGOING_BUY,
Price: TEXT_OUTGOING_SELL,
},
}
i++
@ -59,10 +46,25 @@ func CombineDataCDRs(cdrLines []Line, prices []Price) ([]Data, error) {
}
func CombineCallCDRs(cdrLines []Line, prices []Price) ([]Call, error) {
// Preprocess the price list into a map of "destination" -> Price, filter out the Text destinations, and count how many Text CDRs we have
destinationToPriceLine := make(map[string]Price)
numCallCDRs := 0
for _, l := range cdrLines {
if l.Kind != VoiceLine {
continue
}
if _, ok := destinationToPriceLine[l.Destination]; !ok {
for _, p := range prices {
if p.Type != PriceCall {
continue
}
if p.Destination == l.Destination {
destinationToPriceLine[l.Destination] = p
break
}
}
}
numCallCDRs++
}
return nil, fmt.Errorf("not yet implemented")
}

Loading…
Cancel
Save