[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16419] rental: avoid zero-billing
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16419] rental: avoid zero-billing |
Date: |
Thu, 9 Mar 2017 12:24:49 -0500 (EST) |
Revision: 16419
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16419
Author: sigurdne
Date: 2017-03-09 12:24:49 -0500 (Thu, 09 Mar 2017)
Log Message:
-----------
rental: avoid zero-billing
Modified Paths:
--------------
trunk/rental/inc/class.uibilling.inc.php
trunk/rental/inc/class.uiinvoice_price_item.inc.php
trunk/rental/inc/class.uiparty.inc.php
trunk/rental/inc/model/class.invoice.inc.php
Modified: trunk/rental/inc/class.uibilling.inc.php
===================================================================
--- trunk/rental/inc/class.uibilling.inc.php 2017-03-09 12:10:01 UTC (rev
16418)
+++ trunk/rental/inc/class.uibilling.inc.php 2017-03-09 17:24:49 UTC (rev
16419)
@@ -129,7 +129,7 @@
(array)
$contract_ids_override,
phpgw::get_var('export_format'),
$existing_billing,
-
$contract_bill_only_one_time,
+ (array)
$contract_bill_only_one_time,
$_dry_run = true
);
$simulation_data = array();
@@ -403,7 +403,21 @@
if ($missing_billing_info == null ||
count($missing_billing_info) == 0)
{
- $billing_job =
rental_sobilling::get_instance()->create_billing(isset($GLOBALS['phpgw_info']['user']['preferences']['rental']['currency_decimal_places'])
?
isset($GLOBALS['phpgw_info']['user']['preferences']['rental']['currency_decimal_places'])
: 2, phpgw::get_var('contract_type'), phpgw::get_var('billing_term'),
phpgw::get_var('year'), phpgw::get_var('month'), phpgw::get_var('title'),
$GLOBALS['phpgw_info']['user']['account_id'], $contract_ids,
$contract_ids_override, phpgw::get_var('export_format'), $existing_billing,
$contract_bill_only_one_time);
+ $billing_job =
rental_sobilling::get_instance()->create_billing(
+
isset($GLOBALS['phpgw_info']['user']['preferences']['rental']['currency_decimal_places'])
?
isset($GLOBALS['phpgw_info']['user']['preferences']['rental']['currency_decimal_places'])
: 2,
+
phpgw::get_var('contract_type'),
+
phpgw::get_var('billing_term'),
+ phpgw::get_var('year'),
+ phpgw::get_var('month'),
+ phpgw::get_var('title'),
+
$GLOBALS['phpgw_info']['user']['account_id'],
+ $contract_ids,
+ $contract_ids_override,
+
phpgw::get_var('export_format'),
+ $existing_billing,
+
$contract_bill_only_one_time,
+ $_dry_run = false
+ );
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uibilling.view',
'id' =>
$billing_job->get_id()));
return;
@@ -1483,7 +1497,7 @@
$sort_field = ($columns[$order[0]['column']]['data']) ?
$columns[$order[0]['column']]['data'] : 'id';
$sort_ascending = ($order[0]['dir'] == 'desc') ? false
: true;
// Form variables
- $search_for = $search['value'];
+ $search_for = (string)$search['value'];
$search_type = phpgw::get_var('search_option',
'string', 'REQUEST', 'all');
// Create an empty result set
@@ -1495,7 +1509,7 @@
$export = phpgw::get_var('export', 'bool');
if ($export)
{
- $num_of_objects = null;
+ $num_of_objects = 0;
}
switch ($query_type)
Modified: trunk/rental/inc/class.uiinvoice_price_item.inc.php
===================================================================
--- trunk/rental/inc/class.uiinvoice_price_item.inc.php 2017-03-09 12:10:01 UTC
(rev 16418)
+++ trunk/rental/inc/class.uiinvoice_price_item.inc.php 2017-03-09 17:24:49 UTC
(rev 16419)
@@ -40,7 +40,7 @@
if ($export)
{
- $num_of_objects = null;
+ $num_of_objects = 0;
}
// Create an empty result set
Modified: trunk/rental/inc/class.uiparty.inc.php
===================================================================
--- trunk/rental/inc/class.uiparty.inc.php 2017-03-09 12:10:01 UTC (rev
16418)
+++ trunk/rental/inc/class.uiparty.inc.php 2017-03-09 17:24:49 UTC (rev
16419)
@@ -131,7 +131,7 @@
if ($export)
{
- $num_of_objects = null;
+ $num_of_objects = 0;
}
//Retrieve a contract identifier and load corresponding
contract
Modified: trunk/rental/inc/model/class.invoice.inc.php
===================================================================
--- trunk/rental/inc/model/class.invoice.inc.php 2017-03-09 12:10:01 UTC
(rev 16418)
+++ trunk/rental/inc/model/class.invoice.inc.php 2017-03-09 17:24:49 UTC
(rev 16419)
@@ -326,7 +326,7 @@
* @param bool $override flag to indicate if the invoice
start period should be overridden with the billing start date of contract
* @param int $timestamp_invoice_start the startdate of the
invoice period
* @param int $timestamp_invoice_end the enddate of the
invoice period
- * @param bool $bill_only_one_time flag to indicate if the
the invoice should only bil one time price elements
+ * @param bool $bill_only_one_time flag to indicate if the
the invoice should only bill 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, $dry_run = false,
$billing_term = 0 )
@@ -355,33 +355,7 @@
}
}
- // Create invoice ...
- $invoice = new rental_invoice(
- -1, // no identifier
- $billing_id, // the billing identifier
- $contract_id, // the contract identifier
- time(), // the creation time
- $timestamp_invoice_start, // the invoice start
date
- $timestamp_invoice_end, // the invoice end date
- 0, // the total sum of invoice (not calculated
yet)
- $contract->get_rented_area(), // the area
rented on the contract
- $contract->get_invoice_header(), // the invoice
header
- $contract->get_account_in(), // the ingoing
account number
- $account_out, // the outgoing account number
- $contract->get_service_id(), // the service
identifier (internal)
- $contract->get_responsibility_id() // the
responsibility identifier (internal)
- );
- // ... and add party identifier, project number and the
old contract identifier
- $invoice->set_party_id($contract->get_payer_id());
- $invoice->set_project_id($contract->get_project_id());
-
$invoice->set_old_contract_id($contract->get_old_contract_id());
-
- 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)
{
@@ -400,7 +374,7 @@
'year' => date('Y',
$timestamp_invoice_start),
'month' => date('m',
$timestamp_invoice_start)
);
- }
+ }
//$contract_price_items =
$socontract_price_item->get($start_index, $num_of_objects, $sort_field,
$sort_ascending, $search_for, $search_type, $filters2);
$contract_price_items =
rental_socontract_price_item::get_instance()->get(0, 0, '', false, '', '',
$filters2);
@@ -412,6 +386,43 @@
'contract_id' => $contract->get_id()));
}
+ // Run through the contract price items
+ $_check_sum = 0;
+ foreach ($contract_price_items as $contract_price_item)
+ {
+ $_check_sum +=
$contract_price_item->get_total_price();
+ }
+ if( !abs($_check_sum) > 0 )
+ {
+ return null;
+ }
+ // Create invoice ...
+ $invoice = new rental_invoice(
+ -1, // no identifier
+ $billing_id, // the billing identifier
+ $contract_id, // the contract identifier
+ time(), // the creation time
+ $timestamp_invoice_start, // the invoice start
date
+ $timestamp_invoice_end, // the invoice end date
+ 0, // the total sum of invoice (not calculated
yet)
+ $contract->get_rented_area(), // the area
rented on the contract
+ $contract->get_invoice_header(), // the invoice
header
+ $contract->get_account_in(), // the ingoing
account number
+ $account_out, // the outgoing account number
+ $contract->get_service_id(), // the service
identifier (internal)
+ $contract->get_responsibility_id() // the
responsibility identifier (internal)
+ );
+
+ // ... and add party identifier, project number and the
old contract identifier
+ $invoice->set_party_id($contract->get_payer_id());
+ $invoice->set_project_id($contract->get_project_id());
+
$invoice->set_old_contract_id($contract->get_old_contract_id());
+
+ 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
+ }
+
$total_sum = 0; // Holding the total price of the
invoice
$contract_dates = $contract->get_contract_date();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16419] rental: avoid zero-billing,
sigurdne <=