[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [12913] rental: more on billing
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [12913] rental: more on billing |
Date: |
Fri, 27 Mar 2015 08:56:27 +0000 |
Revision: 12913
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12913
Author: sigurdne
Date: 2015-03-27 08:56:26 +0000 (Fri, 27 Mar 2015)
Log Message:
-----------
rental: more on billing
Modified Paths:
--------------
trunk/rental/inc/class.uibilling.inc.php
trunk/rental/inc/model/class.invoice.inc.php
trunk/rental/templates/base/billing_step2.php
Modified: trunk/rental/inc/class.uibilling.inc.php
===================================================================
--- trunk/rental/inc/class.uibilling.inc.php 2015-03-26 23:17:47 UTC (rev
12912)
+++ trunk/rental/inc/class.uibilling.inc.php 2015-03-27 08:56:26 UTC (rev
12913)
@@ -187,6 +187,7 @@
}
else
{
+ $contracts_with_one_time = array();
//... and if not start retrieving contracts for
billing
$socontract_price_item =
rental_socontract_price_item::get_instance();
@@ -199,10 +200,13 @@
$filters2 = array('contract_ids_one_time' =>
true, 'billing_term_id' => $billing_term, 'year' => $year, 'month' => $month);
$contract_price_items =
$socontract_price_item->get($start_index, $num_of_objects, $sort_field,
$sort_ascending, $search_for, $search_type, $filters2);
- foreach($contract_price_items as
$contract_price_item){
-
if(!array_key_exists($contract_price_item->get_contract_id(), $contracts)){
+ foreach($contract_price_items as
$contract_price_item)
+ {
+
if(!array_key_exists($contract_price_item->get_contract_id(), $contracts))
+ {
$aditional_contracts =
rental_socontract::get_instance()->get(null, null, null, null, null, null,
array('contract_id' => $contract_price_item->get_contract_id(), 'contract_type'
=> $contract_type));
- if(count($aditional_contracts)
== 1){
+ if(count($aditional_contracts)
== 1)
+ {
$c =
$aditional_contracts[$contract_price_item->get_contract_id()];
$c->set_bill_only_one_time();
//$contracts[$contract_price_item->get_contract_id()] = $c;
@@ -215,7 +219,14 @@
$contracts_with_one_time[$cid]
= $contracts[$cid];
}
}
-
+
+ foreach($contracts_with_one_time as $id =>
&$contract)
+ {
+ $total_price =
$socontract_price_item->get_total_price_invoice($contract->get_id(),
$billing_term, $month, $year);
+
$contract->set_total_price($total_price);
+
+ }
+ unset($contract);
// Get the number of months in selected term
for contract
$months =
rental_socontract::get_instance()->get_months_in_term($billing_term);
Modified: trunk/rental/inc/model/class.invoice.inc.php
===================================================================
--- trunk/rental/inc/model/class.invoice.inc.php 2015-03-26 23:17:47 UTC
(rev 12912)
+++ trunk/rental/inc/model/class.invoice.inc.php 2015-03-27 08:56:26 UTC
(rev 12913)
@@ -261,7 +261,7 @@
* @param bool $bill_only_one_time flag to indicate if the
the invoice should only bil one time price elements
* @return rental_invoice the newly created invoice
*/
- public static function create_invoice(int $decimals, int
$billing_id, int $contract_id, bool $override,int $timestamp_invoice_start, int
$timestamp_invoice_end, $bill_only_one_time)
+ public static function create_invoice(int $decimals, int
$billing_id, int $contract_id, bool $override,int $timestamp_invoice_start, int
$timestamp_invoice_end, $bill_only_one_time, $dry_run = false)
{
$contract =
rental_socontract::get_instance()->get_single($contract_id);
@@ -309,7 +309,10 @@
$invoice->set_project_id($contract->get_project_id());
$invoice->set_old_contract_id($contract->get_old_contract_id());
- rental_soinvoice::get_instance()->store($invoice); //
We must store the invoice at this point to have an id to give to the price item
+ if(!$dry_run)
+ {
+
rental_soinvoice::get_instance()->store($invoice); // We must store the invoice
at this point to have an id to give to the price item
+ }
// Retrieve the contract price items: only one-time or
all
if($bill_only_one_time)
@@ -435,12 +438,18 @@
$invoice_price_item->set_total_price($contract_price_item->get_total_price());
// ... and set the contract
price item as billed
$contract_price_item->set_is_billed(true);
-
rental_socontract_price_item::get_instance()->store($contract_price_item);
+ if(!$dry_run)
+ {
+
rental_socontract_price_item::get_instance()->store($contract_price_item);
+ }
}
}
- // Store the invoice price item
-
rental_soinvoice_price_item::get_instance()->store($invoice_price_item);
+ if(!$dry_run)
+ {
+ // Store the invoice price item
+
rental_soinvoice_price_item::get_instance()->store($invoice_price_item);
+ }
// Add the price item to the invoice
$invoice->add_invoice_price_item($invoice_price_item);
@@ -453,8 +462,11 @@
// Set the total sum of the invoice rounded to the
specified number of decimals
$invoice->set_total_sum(round($total_sum, $decimals));
- // ... and store the invoice
- rental_soinvoice::get_instance()->store($invoice);
+ if(!$dry_run)
+ {
+ // ... and store the invoice
+
rental_soinvoice::get_instance()->store($invoice);
+ }
return $invoice;
}
Modified: trunk/rental/templates/base/billing_step2.php
===================================================================
--- trunk/rental/templates/base/billing_step2.php 2015-03-26 23:17:47 UTC
(rev 12912)
+++ trunk/rental/templates/base/billing_step2.php 2015-03-27 08:56:26 UTC
(rev 12913)
@@ -201,6 +201,7 @@
<th><?php echo lang('composite_name')
?></th>
<th><?php echo lang('party_name')
?></th>
<th><?php echo lang('only_one_time')
?></th>
+ <th><?php echo lang('total_price')
?></th>
</tr>
</thead>
<tbody>
@@ -240,6 +241,7 @@
}
?>
</td>
+ <td><?php echo
number_format($contract->get_total_price(),2,',',' '); ?>
</tr>
<?php
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [12913] rental: more on billing,
Sigurd Nes <=