@@ -25,6 +25,10 @@ type priceCalculatorItem interface {
2525 // The current bid price will be adjusted according to the source correction factor and the commission share factor
2626 BidViewPrice () billing.Money
2727
28+ // PrepareBidViewPrice prepares the price for the action
29+ // The price is adjusted according to the source correction factor and the commission share factor
30+ PrepareBidViewPrice (price billing.Money ) billing.Money
31+
2832 // Price returns price for the target action (view, click, lead, etc)
2933 Price (action adtype.Action ) billing.Money
3034}
@@ -59,13 +63,19 @@ func CalculatePurchasePrice(item priceCalculatorItem, action adtype.Action) bill
5963 return bidPrice
6064 }
6165 }
62- price := item .Price (action )
63- return billing .MoneyFloat (
64- price .Float64 () *
65- max (1. - item .SourceCorrectionFactor (), 0. ) *
66- max (1. - item .TargetCorrectionFactor (), 0. ) *
67- max (1. - item .CommissionShareFactor (), 0. ),
66+ var (
67+ price = item .Price (action )
68+ newPrice = billing .MoneyFloat (
69+ price .Float64 () *
70+ max (1. - item .SourceCorrectionFactor (), 0. ) *
71+ max (1. - item .TargetCorrectionFactor (), 0. ) *
72+ max (1. - item .CommissionShareFactor (), 0. ),
73+ )
6874 )
75+ if action == adtype .ActionView {
76+ return item .PrepareBidViewPrice (newPrice )
77+ }
78+ return newPrice
6979}
7080
7181// CalculatePotentialPrice returns the base price without any corrections or commissions
@@ -83,11 +93,7 @@ func CalculatePotentialPrice(item priceCalculatorItem, action adtype.Action) bil
8393 return val
8494}
8595
86- // CalculateFinalPrice returns final price for the item which is including all possible commissions with all corrections
87- //
88- // Formula:
89- //
90- // FinalPrice = Price - SourceCorrectionFactor[%] - TargetCorrectionFactor[%]
96+ // CalculateFinalPrice returns final price for the advertiser which will be charged
9197func CalculateFinalPrice (item priceCalculatorItem , action adtype.Action ) billing.Money {
9298 sourceCorrection := item .SourceCorrectionFactor ()
9399 targetCorrection := item .TargetCorrectionFactor ()
0 commit comments