Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Gets the total revenue.
- *
- * @param array $productData
- * @return float
- */
- private function getTotalRevenue(array $productData): float
- {
- $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
- return $productData['count'] * $sumCpFs;
- }
- /**
- * Get the total cost.
- *
- * @param array $productData
- * @return float
- */
- private function getTotalCostFromInsight(array $productData): float
- {
- return $productData['insight_product']['bom_cost'] * $productData['count'];
- }
- /**
- * Get the Gross Margin (Not percentage)
- *
- * @param array $productData
- * @return float
- */
- private function getGrossMarginFromInsight(array $productData): float
- {
- $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
- $mulBcC = $productData['insight_product']['bom_cost'] * $productData['count'];
- return ($productData['count'] * $sumCpFs) - $mulBcC;
- }
- /**
- * Get the Gross Margin Percentage
- *
- * @param array $productData
- * @return float
- */
- private function getGrossMarginPercentageFromInsight(array $productData): float
- {
- $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
- $cost = ($productData['count'] * $productData['insight_product']['bom_cost']);
- $total = ($sumCpFs - $cost);
- $total = $productData['count'] * $total;
- if (($productData['count'] * $sumCpFs) == 0) {
- return 0.0;
- }
- return $total / ($productData['count'] * $sumCpFs);
- }
- /**
- * Helper to calculate the BOM Cost.
- *
- * @param array $boms
- * @return float
- */
- private function getBomCost(array $boms): float
- {
- $total = 0.00;
- foreach ($boms as $bom) {
- $total += $bom['master_component']['landed_cost'];
- }
- return $total * $bom['quantity'];
- }
- /**
- * Get total cost using bom data
- *
- * @param array $boms
- * @param integer $count
- * @return float
- */
- private function getTotalCostFromBom(array $boms, int $count): float
- {
- return $this->getBomCost($boms) * $count;
- }
- /**
- * Get Gross Margin from Bom data
- *
- * @param array $boms
- * @param array $productData
- * @return float
- */
- private function getGrossMarginFromBom(array $boms, array $productData): float
- {
- $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
- $mulBcC = $this->getBomCost($boms) * $productData['count'];
- return ($productData['count'] * $sumCpFs) - $mulBcC;
- }
- /**
- * Get Gross Margin Percentage with Bom data.
- *
- * @param array $boms
- * @param array $productData
- * @return float
- */
- private function getGrossMarginPercentageFromBom(array $boms, array $productData): float
- {
- $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
- $cost = ($productData['count'] * $this->getBomCost($boms));
- $total = ($sumCpFs - $cost);
- $total = $productData['count'] * $total;
- if (($productData['count'] * ($sumCpFs)) == 0) {
- return 0.0;
- }
- return $total / ($productData['count'] * ($sumCpFs));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement