[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16478] rental: fix reverting one_time_billing
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16478] rental: fix reverting one_time_billing |
Date: |
Fri, 24 Mar 2017 16:53:16 -0400 (EDT) |
Revision: 16478
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16478
Author: sigurdne
Date: 2017-03-24 16:53:16 -0400 (Fri, 24 Mar 2017)
Log Message:
-----------
rental: fix reverting one_time_billing
Modified Paths:
--------------
trunk/rental/inc/class.socontract_price_item.inc.php
trunk/rental/inc/class.uibilling.inc.php
trunk/rental/inc/model/class.contract_price_item.inc.php
trunk/rental/inc/model/class.invoice.inc.php
trunk/rental/setup/setup.inc.php
trunk/rental/setup/tables_current.inc.php
trunk/rental/setup/tables_update.inc.php
Modified: trunk/rental/inc/class.socontract_price_item.inc.php
===================================================================
--- trunk/rental/inc/class.socontract_price_item.inc.php 2017-03-24
15:42:52 UTC (rev 16477)
+++ trunk/rental/inc/class.socontract_price_item.inc.php 2017-03-24
20:53:16 UTC (rev 16478)
@@ -123,7 +123,8 @@
. "
rental_contract_price_item.contract_id, rental_contract_price_item.area,
rental_contract_price_item.count,"
. "
rental_contract_price_item.agresso_id, rental_contract_price_item.title,
rental_contract_price_item.is_area,"
. " rental_contract_price_item.price,
rental_contract_price_item.total_price, rental_contract_price_item.is_one_time,"
- . "
rental_contract_price_item.date_start,
rental_contract_price_item.date_end,rental_price_item.type";
+ . "
rental_contract_price_item.date_start,
rental_contract_price_item.date_end,rental_price_item.type,"
+ . "
rental_contract_price_item.billing_id";
}
else
{
@@ -162,6 +163,7 @@
$price_item->set_location_factor($this->unmarshal($this->db->f('location_factor'),
'float'));
$price_item->set_standard_factor($this->unmarshal($this->db->f('standard_factor'),
'float'));
$price_item->set_custom_factor($this->unmarshal($this->db->f('custom_factor'),
'float'));
+
$price_item->set_billing_id($this->unmarshal($this->db->f('billing_id'),
'int'));
}
return $price_item;
}
@@ -269,6 +271,12 @@
$cols[] = 'date_end';
}
+ if ($price_item->get_billing_id())
+ {
+ $values[] =
$this->marshal($price_item->get_billing_id(), 'int');
+ $cols[] = 'billing_id';
+ }
+
$q = "INSERT INTO rental_contract_price_item (" .
join(',', $cols) . ") VALUES (" . join(',', $values) . ")";
$result = $this->db->query($q);
@@ -366,7 +374,8 @@
"is_billed=" . ($price_item->is_billed() ?
"true" : "false"),
"location_factor = '{$location_factor}'",
"standard_factor = '{$standard_factor}'",
- "custom_factor = '{$custom_factor}'"
+ "custom_factor = '{$custom_factor}'",
+ "billing_id=" .
$this->marshal($price_item->get_billing_id(), 'int')
);
$this->db->query('UPDATE rental_contract_price_item SET
' . join(',', $values) . " WHERE id=$id", __LINE__, __FILE__);
Modified: trunk/rental/inc/class.uibilling.inc.php
===================================================================
--- trunk/rental/inc/class.uibilling.inc.php 2017-03-24 15:42:52 UTC (rev
16477)
+++ trunk/rental/inc/class.uibilling.inc.php 2017-03-24 20:53:16 UTC (rev
16478)
@@ -1398,6 +1398,7 @@
{
phpgw::no_access();
}
+ $billing_id = phpgw::get_var('id');
rental_sobilling::get_instance()->transaction_begin();
$billing_job =
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
$billing_job->set_deleted(true);
@@ -1422,7 +1423,8 @@
foreach ($price_items as $price_item)
{
//Check for credit or valid date
- if (($price_item->get_is_one_time() &&
$price_item->get_total_price() < 0) || ($price_item->get_date_start() >=
$invoice->get_timestamp_start() && $price_item->get_date_start() <=
$invoice->get_timestamp_end()))
+// if (($price_item->get_is_one_time() &&
$price_item->get_total_price() < 0) || ($price_item->get_date_start() >=
$invoice->get_timestamp_start() && $price_item->get_date_start() <=
$invoice->get_timestamp_end()))
+ if ($price_item->get_billing_id() ==
$billing_id)
{
$price_item->set_is_billed(false);
rental_socontract_price_item::get_instance()->store($price_item);
Modified: trunk/rental/inc/model/class.contract_price_item.inc.php
===================================================================
--- trunk/rental/inc/model/class.contract_price_item.inc.php 2017-03-24
15:42:52 UTC (rev 16477)
+++ trunk/rental/inc/model/class.contract_price_item.inc.php 2017-03-24
20:53:16 UTC (rev 16478)
@@ -22,6 +22,7 @@
protected $standard_factor;
protected $custom_factor;
protected $price_type_id;
+ protected $billing_id;
/**
* Constructor. Takes an optional ID. If a price item is
created from outside
@@ -45,6 +46,15 @@
*/
}
+ public function get_billing_id()
+ {
+ return $this->billing_id;
+ }
+
+ public function set_billing_id( $id )
+ {
+ $this->billing_id = $id;
+ }
public function get_price_item_id()
{
return $this->price_item_id;
@@ -241,6 +251,7 @@
'date_start' => $this->get_date_start() != NULL
? date($date_format, $this->get_date_start()) : '',
'date_end' => $this->get_date_end() != NULL ?
date($date_format, $this->get_date_end()) : '',
'price_type_title' =>
lang($this->get_price_type_title()),
+ 'billing_id' => $this->get_billing_id(),
);
}
Modified: trunk/rental/inc/model/class.invoice.inc.php
===================================================================
--- trunk/rental/inc/model/class.invoice.inc.php 2017-03-24 15:42:52 UTC
(rev 16477)
+++ trunk/rental/inc/model/class.invoice.inc.php 2017-03-24 20:53:16 UTC
(rev 16478)
@@ -534,12 +534,18 @@
if ($contract_price_item->is_one_time())
{
$invoice_price_item->set_is_one_time(true);
- if ($billing_term == 5 ||
($contract_price_item_start >= $timestamp_invoice_start &&
$contract_price_item_start <= $timestamp_invoice_end))
+
+
+ /**
+ * FIXME: Sigurd: 24. mars: sjekk
denne!!
+ */
+// if ($billing_term == 5 ||
($contract_price_item_start >= $timestamp_invoice_start &&
$contract_price_item_start <= $timestamp_invoice_end))
{
// ... set the total price of
the invoice price item to the total price of the contract price item
$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);
+
$contract_price_item->set_billing_id($billing_id);
if (!$dry_run)
{
rental_socontract_price_item::get_instance()->store($contract_price_item);
Modified: trunk/rental/setup/setup.inc.php
===================================================================
--- trunk/rental/setup/setup.inc.php 2017-03-24 15:42:52 UTC (rev 16477)
+++ trunk/rental/setup/setup.inc.php 2017-03-24 20:53:16 UTC (rev 16478)
@@ -1,6 +1,6 @@
<?php
$setup_info['rental']['name'] = 'rental'; // Module identifier
- $setup_info['rental']['version'] = '0.1.0.36'; // Current module version
+ $setup_info['rental']['version'] = '0.1.0.37'; // Current module version
$setup_info['rental']['app_order'] = 51; // (?)
$setup_info['rental']['tables'] = array(
'rental_party', // All contract participants, tenants etc.
Modified: trunk/rental/setup/tables_current.inc.php
===================================================================
--- trunk/rental/setup/tables_current.inc.php 2017-03-24 15:42:52 UTC (rev
16477)
+++ trunk/rental/setup/tables_current.inc.php 2017-03-24 20:53:16 UTC (rev
16478)
@@ -298,7 +298,8 @@
'date_start' => array('type' => 'int',
'precision' => '8', 'nullable' => true),
'date_end' => array('type' => 'int',
'precision' => '8', 'nullable' => true),
'is_billed' => array('type' => 'bool',
'nullable' => false, 'default' => 'false'),
- 'is_one_time' => array('type' => 'bool',
'nullable' => true, 'default' => 'false')
+ 'is_one_time' => array('type' => 'bool',
'nullable' => true, 'default' => 'false'),
+ 'billing_id' => array('type' => 'int',
'precision' => '4', 'nullable' => true),
),
'pk' => array('id'),
'fk' => array(
Modified: trunk/rental/setup/tables_update.inc.php
===================================================================
--- trunk/rental/setup/tables_update.inc.php 2017-03-24 15:42:52 UTC (rev
16477)
+++ trunk/rental/setup/tables_update.inc.php 2017-03-24 20:53:16 UTC (rev
16478)
@@ -959,3 +959,21 @@
return $GLOBALS['setup_info']['rental']['currentver'];
}
}
+
+ $test[] = '0.1.0.36';
+ function rental_upgrade0_1_0_36()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_contract_price_item',
'billing_id', array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => true
+ ));
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['rental']['currentver'] =
'0.1.0.37';
+ return $GLOBALS['setup_info']['rental']['currentver'];
+ }
+ }
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16478] rental: fix reverting one_time_billing,
sigurdne <=