SHARE
TWEET

accounting stuffs

a guest Jan 23rd, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    /**
  2.      * Gets the total revenue.
  3.      *
  4.      * @param array $productData
  5.      * @return float
  6.      */
  7.     private function getTotalRevenue(array $productData): float
  8.     {
  9.         $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
  10.         return $productData['count'] * $sumCpFs;
  11.     }
  12.  
  13.     /**
  14.      * Get the total cost.
  15.      *
  16.      * @param array $productData
  17.      * @return float
  18.      */
  19.     private function getTotalCostFromInsight(array $productData): float
  20.     {
  21.         return $productData['insight_product']['bom_cost'] * $productData['count'];
  22.     }
  23.  
  24.     /**
  25.      * Get the Gross Margin (Not percentage)
  26.      *
  27.      * @param array $productData
  28.      * @return float
  29.      */
  30.     private function getGrossMarginFromInsight(array $productData): float
  31.     {
  32.         $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
  33.         $mulBcC = $productData['insight_product']['bom_cost'] * $productData['count'];
  34.  
  35.         return ($productData['count'] * $sumCpFs) - $mulBcC;
  36.     }
  37.  
  38.     /**
  39.      * Get the Gross Margin Percentage
  40.      *
  41.      * @param array $productData
  42.      * @return float
  43.      */
  44.     private function getGrossMarginPercentageFromInsight(array $productData): float
  45.     {
  46.         $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
  47.         $cost = ($productData['count'] * $productData['insight_product']['bom_cost']);
  48.         $total = ($sumCpFs - $cost);
  49.         $total = $productData['count'] * $total;
  50.  
  51.         if (($productData['count'] * $sumCpFs) == 0) {
  52.             return 0.0;
  53.         }
  54.  
  55.         return $total / ($productData['count'] * $sumCpFs);  
  56.     }
  57.  
  58.     /**
  59.      * Helper to calculate the BOM Cost.
  60.      *
  61.      * @param array $boms
  62.      * @return float
  63.      */
  64.     private function getBomCost(array $boms): float
  65.     {
  66.         $total = 0.00;
  67.         foreach ($boms as $bom) {
  68.             $total += $bom['master_component']['landed_cost'];
  69.         }
  70.  
  71.         return $total * $bom['quantity'];      
  72.     }
  73.  
  74.     /**
  75.      * Get total cost using bom data
  76.      *
  77.      * @param array $boms
  78.      * @param integer $count
  79.      * @return float
  80.      */
  81.     private function getTotalCostFromBom(array $boms, int $count): float
  82.     {
  83.         return $this->getBomCost($boms) * $count;
  84.     }
  85.  
  86.     /**
  87.      * Get Gross Margin from Bom data
  88.      *
  89.      * @param array $boms
  90.      * @param array $productData
  91.      * @return float
  92.      */
  93.     private function getGrossMarginFromBom(array $boms, array $productData): float
  94.     {
  95.         $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
  96.         $mulBcC = $this->getBomCost($boms) * $productData['count'];
  97.  
  98.         return ($productData['count'] * $sumCpFs) - $mulBcC;
  99.     }
  100.  
  101.     /**
  102.      * Get Gross Margin Percentage with Bom data.
  103.      *
  104.      * @param array $boms
  105.      * @param array $productData
  106.      * @return float
  107.      */
  108.     private function getGrossMarginPercentageFromBom(array $boms, array $productData): float
  109.     {
  110.         $sumCpFs = $productData['insight_product']['current_price'] + $productData['insight_product']['fulfillment_surcharge'];
  111.         $cost = ($productData['count'] * $this->getBomCost($boms));
  112.         $total = ($sumCpFs - $cost);
  113.         $total = $productData['count'] * $total;
  114.  
  115.         if (($productData['count'] * ($sumCpFs)) == 0) {
  116.             return 0.0;
  117.         }        
  118.  
  119.         return $total / ($productData['count'] * ($sumCpFs));
  120.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top