4.282, 30 => 3.451, 36 => 2.896, 42 => 2.500, 48 => 2.223, 54 => 2.025, 60 => 1.834 ]; $interest = isset($rates[$num_of_payments]) ? $rates[$num_of_payments] : 10; return round($PV * ($interest / 100)); } function wiaas_get_recurrent_price_mortage($principal_amount, $pay_period, $margin, $interest_rate) { $new_principal_amount = $principal_amount - $margin; $interest_rate = $interest_rate / 100; $fixed_mortage = wiaas_PMT($interest_rate, $pay_period, $new_principal_amount); return round($fixed_mortage, 2); } function wiaas_get_price_margin($fixed_price, $principal_amount, $total_cost) { $total_gain = $fixed_price + $principal_amount; return $total_gain - $total_cost; } function wiaas_get_package_product_procurement_cost($package){ $bundled_items = $package->get_bundled_items(); $total_cost = 0; foreach ($bundled_items as $bundled_item) { $product = $bundled_item->product; if (Wiaas_Product_Category::is_product($product)) { $total_cost += Wiaas_Pricing::get_product_total_cost($product) * $bundled_item->get_quantity(); } } return $total_cost; } function wiaas_get_package_installation_procurement_cost($package) { $bundled_items = $package->get_bundled_items(); $total_cost = 0; foreach ($bundled_items as $bundled_item) { if (Wiaas_Product_Category::is_installation($bundled_item->product)) { $installation_cost = Wiaas_Pricing::get_product_total_cost($bundled_item->product); $total_cost = $total_cost > $installation_cost ? $total_cost : $installation_cost; } } return $total_cost; } function wiaas_get_package_one_time_services_procurement_cost($package) { $bundled_items = $package->get_bundled_items(); $total_cost = 0; foreach ($bundled_items as $bundled_item) { if (Wiaas_Product_Category::is_service($bundled_item->product)) { $price = Wiaas_Product_Pricing::get_product_price($bundled_item->product); if (! $price['is_recurring']) { $total_cost += Wiaas_Pricing::get_product_total_cost($bundled_item->product) * $bundled_item->get_quantity(); } } } return $total_cost; } function wiaas_get_package_recurring_services_procurement_cost($package) { $bundled_items = $package->get_bundled_items(); $total_cost = 0; foreach ($bundled_items as $bundled_item) { if (Wiaas_Product_Category::is_service($bundled_item->product)) { $price = Wiaas_Product_Pricing::get_product_price($bundled_item->product); if ( $price['is_recurring']) { $total_cost += $price['price'] * $bundled_item->get_quantity(); } } } return $total_cost; }