AH
{ A: string
B: int }
member this.SlaziyVBazu() = task {
do! Task.Delay 100
return this.A + this.B
}
Size: a a a
AH
IC
type T = { A: string; B int }
with
member this.SlazijVBazu() =
task {
do! Async.Sleep 100
return A + B
}
IC
IC
IC
R
IC
IC
R
R
AH
AH
R
AH
let getPriceControl priceControlOverride
priceControlBrandRules
priceControlCategoryRules
priceControlsManufacturerCatalog
priceControlDefaultRule
taxonomyItems
(approvedCompetitiveSourcesMap: Map<RegionId, string Set>)
(isOnePNode: NodeId->bool)
(brandOption: string option)
(offersMap: Map<RegionId, OfferAndShippingCost[]>)
(retailSku: SlimmedRetailSku)
(marginBasedPricingMap: Map<RegionId, MarginBasedPricingCalculationResults>)
: Map<RegionId, PriceControlResult option> =
let invertMapLevel mapLevel =
match mapLevel with
| PriceControlPolicies.Constants.Msp -> 1
| PriceControlPolicies.Constants.Map -> 2
| PriceControlPolicies.Constants.NoPrice -> 3
| _ -> 4
let sortOffers maybeMarginTarget offers =
offers
|> Seq.choose (fun offer ->
if offer.sourceSkuMapLevel = PriceControlPolicies.Constants.Map then
if Options.checkIfNoneOrNonPostivieDecimal offer.sourceSkuMapPrice then
None
else
let mapPrice = offer.sourceSkuMapPrice.Value * offer.originalSourceSkuFactor
Some { offer with offerKind = OfferKind.Price mapPrice }
else
match offer.offerKind with
| OfferKind.Price price ->
Some { offer with offerKind = OfferKind.Price (price * offer.originalSourceSkuFactor) }
| OfferKind.CostWithOptionalPrice (cost, Some price) ->
Some { offer with offerKind = OfferKind.CostWithOptionalPrice (cost, price * offer.originalSourceSkuFactor |> Some) }
| OfferKind.CostWithOptionalPrice (_, None) ->
Some offer
)
|> Seq.map (fun offer ->
// Amazon 3P offers should have shipping included in their price.
match (offer.source = Sources.Indirect) && (offer.merchantId <> Constants.AmazonMerchantId) with
| true ->
match offer.offerKind with
| OfferKind.Price price ->
{ offer with offerKind = OfferKind.Price (price + Option.getValueOr 0m offer.shippingAmount) }
| OfferKind.CostWithOptionalPrice _ -> offer
| false -> offer)
|> Seq.sortBy(fun offer ->
let priceControlPrice =
Offer.tryGetPriceOrTargetPrice offer maybeMarginTarget |> Option.getValueOr Decimal.MaxValue
priceControlPrice, invertMapLevel offer.sourceSkuMapLevel)
AllRegions
|> Seq.map ^fun regionId ->
//check global override first. This should apply to all regions no matter what
checkPriceControlOverride priceControlOverride retailSku.id
|> Option.orElseWith ^fun _ -> maybe {
let maybeMarginTarget =
marginBasedPricingMap.TryFind regionId
|> Option.map (fun x -> x.marginTarget)
let! notSortedOffers = offersMap.TryFind regionId
let offers =
notSortedOffers
|> Seq.map ^fun x -> x.offer
|> sortOffers maybeMarginTarget
|> Seq.toArray
AH
return!
//check manufacturer which is region specific
checkManufacturerCatalog priceControlsManufacturerCatalog offers maybeMarginTarget
|> Option.orElseWith ^fun _ -> maybe {
let retailSkuCategory: CategoryId = int retailSku.category
let! merchants = approvedCompetitiveSourcesMap.TryFind regionId
let approvedCompOffers =
offers
|> Array.filter ^fun offer -> merchants.Contains offer.merchantId ||
offer.source = OfferSource.Indirect
let directApprovedCompOffers =
approvedCompOffers
|> Array.filter ^fun offer -> offer.source = OfferSource.Merchant ||
offer.source = OfferSource.Jet
return!
//check brand override which is region specific
checkBrandOverride priceControlBrandRules taxonomyItems brandOption offers approvedCompOffers directApprovedCompOffers retailSkuCategory maybeMarginTarget
////check category override which is region specific
|> Option.orElseWith ^fun _ -> checkCategoryOverride priceControlCategoryRules taxonomyItems offers approvedCompOffers directApprovedCompOffers retailSkuCategory maybeMarginTarget
////check other overrides which is region specific
|> Option.orElseWith ^fun _ -> checkOtherSources priceControlDefaultRule isOnePNode approvedCompOffers directApprovedCompOffers maybeMarginTarget
}
}
|> tuple2 regionId
|> Map.ofSeq
R
AH
AH
R
AH