[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15564] Rental: price adjustments
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [15564] Rental: price adjustments |
Date: |
Fri, 2 Sep 2016 08:09:20 +0000 (UTC) |
Revision: 15564
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15564
Author: sigurdne
Date: 2016-09-02 08:09:20 +0000 (Fri, 02 Sep 2016)
Log Message:
-----------
Rental: price adjustments
Modified Paths:
--------------
trunk/property/inc/class.bogeneric.inc.php
trunk/rental/inc/class.socontract_price_item.inc.php
trunk/rental/inc/class.soprice_item.inc.php
trunk/rental/inc/class.uicontract.inc.php
trunk/rental/inc/model/class.contract_price_item.inc.php
trunk/rental/setup/phpgw_no.lang
trunk/rental/setup/setup.inc.php
trunk/rental/setup/tables_update.inc.php
Modified: trunk/property/inc/class.bogeneric.inc.php
===================================================================
--- trunk/property/inc/class.bogeneric.inc.php 2016-09-02 00:33:59 UTC (rev
15563)
+++ trunk/property/inc/class.bogeneric.inc.php 2016-09-02 08:09:20 UTC (rev
15564)
@@ -138,6 +138,11 @@
public function read( $data = array() )
{
+ if (isset($data['location_info']) &&
$data['location_info']['type'])
+ {
+
$this->get_location_info($data['location_info']['type'],
(int)$data['location_info']['type_id']);
+ unset($data['location_info']);
+ }
$values = $this->so->read($data);
foreach ($values as &$entry)
@@ -174,7 +179,7 @@
{
if (isset($data['location_info']) &&
$data['location_info']['type'])
{
-
$this->get_location_info($data['location_info']['type'],
(int)$data['location_info']['type']);
+
$this->get_location_info($data['location_info']['type'],
(int)$data['location_info']['type_id']);
unset($data['location_info']);
}
$custom_fields = false;
Modified: trunk/rental/inc/class.socontract_price_item.inc.php
===================================================================
--- trunk/rental/inc/class.socontract_price_item.inc.php 2016-09-02
00:33:59 UTC (rev 15563)
+++ trunk/rental/inc/class.socontract_price_item.inc.php 2016-09-02
08:09:20 UTC (rev 15564)
@@ -118,7 +118,8 @@
}
else if (isset($filters['export']))
{
- $cols = "rental_contract_price_item.id,
rental_contract_price_item.price_item_id,"
+ $cols =
"rental_contract_price_item.id,rental_contract_price_item.location_factor,rental_contract_price_item.standard_factor,"
+ . "
rental_contract_price_item.custom_factor,
rental_contract_price_item.price_item_id,"
. "
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,"
@@ -158,6 +159,9 @@
$price_type_id = (int)$this->db->f('type');
$price_item->set_price_type_id($price_type_id);
$price_item->set_price_type_title($price_type_id);
+
$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'));
}
return $price_item;
}
@@ -285,6 +289,40 @@
{
$id = intval($price_item->get_id());
+ /*
+ * Start correction by factors
+ */
+
+ phpgw::import_class('rental.socomposite');
+ $contract =
rental_socontract::get_instance()->get_single($price_item->get_contract_id());
+ $composites = $contract->get_composites();
+ foreach ($composites as $composite_id => $composite)
+ {
+ $composite_obj =
rental_socomposite::get_instance()->get_single($composite_id);
+ break;
+ }
+
+ $custom_factor =
$composite_obj->get_custom_prize_factor();
+ $custom_factor = $custom_factor ? (float)$custom_factor
: 1;
+
+ $location_info = ExecMethod('property.bogeneric.read',
array(
+ 'location_info'=> array('type' =>
'location_factor'),
+ 'custom_filter' => array('part_of_town_id = ' .
(int)$composite_obj->get_part_of_town_id())
+ )
+ );
+ $location_factor =
(float)abs($location_info[0]['factor']) > 0 ?
(float)$location_info[0]['factor'] : 1;
+
+ $standard_info =
ExecMethod('property.bogeneric.read_single', array('type' =>
'composite_standard', 'id' => $composite_obj->get_standard_id()));
+ $standard_factor = (float)abs($standard_info['factor'])
> 0 ? (float)$standard_info['factor'] : 1;
+
+ $factor = $location_factor * $standard_factor *
$custom_factor;
+ $factor = $factor ? (float)$factor : 1;
+
+
+ /*
+ * End correction by factors
+ */
+
$price = $price_item->get_price() ?
$price_item->get_price() : 0;
//$total_price = $price_item->get_total_price() ?
$price_item->get_total_price() : 0;
//if($total_price == 0){
@@ -292,11 +330,14 @@
if ($price_item->is_area())
{
- $total_price = $price_item->get_area() *
$price_item->get_price();
+ $total_price = $price_item->get_area() *
$price_item->get_price() * $factor;
}
else
{
$total_price = $price_item->get_count() *
$price_item->get_price();
+ $location_factor = 1;
+ $standard_factor = 1;
+ $custom_factor = 1;
}
// Build a db-friendly array of the composite object
@@ -313,7 +354,10 @@
"date_start=" .
$this->marshal($price_item->get_date_start(), 'int'),
"date_end=" .
$this->marshal($price_item->get_date_end(), 'int'),
"is_one_time=" .
($price_item->get_is_one_time() == "true" ? "true" : "false"),
- "is_billed=" . ($price_item->is_billed() ?
"true" : "false")
+ "is_billed=" . ($price_item->is_billed() ?
"true" : "false"),
+ "location_factor = '{$location_factor}'",
+ "standard_factor = '{$standard_factor}'",
+ "custom_factor = '{$custom_factor}'"
);
$this->db->query('UPDATE rental_contract_price_item SET
' . join(',', $values) . " WHERE id=$id", __LINE__, __FILE__);
Modified: trunk/rental/inc/class.soprice_item.inc.php
===================================================================
--- trunk/rental/inc/class.soprice_item.inc.php 2016-09-02 00:33:59 UTC (rev
15563)
+++ trunk/rental/inc/class.soprice_item.inc.php 2016-09-02 08:09:20 UTC (rev
15564)
@@ -363,11 +363,32 @@
* @param $price_item the price item to add
* @return true if successful, false otherwise
*/
- function add_price_item( $contract_id, $price_item_id, $factor )
+ function add_price_item( $contract_id, $price_item_id )
{
+ $contract =
rental_socontract::get_instance()->get_single($contract_id);
+ $composites = $contract->get_composites();
+ foreach ($composites as $composite_id => $composite)
+ {
+ $composite_obj =
rental_socomposite::get_instance()->get_single($composite_id);
+ break;
+ }
+
+ $custom_factor =
$composite_obj->get_custom_prize_factor();
+ $custom_factor = $custom_factor ? (float)$custom_factor
: 1;
+
+ $location_info = ExecMethod('property.bogeneric.read',
array(
+ 'location_info'=> array('type' =>
'location_factor'),
+ 'custom_filter' => array('part_of_town_id = ' .
(int)$composite_obj->get_part_of_town_id())
+ )
+ );
+ $location_factor =
(float)abs($location_info[0]['factor']) > 0 ?
(float)$location_info[0]['factor'] : 1;
+
+ $standard_info =
ExecMethod('property.bogeneric.read_single', array('type' =>
'composite_standard', 'id' => $composite_obj->get_standard_id()));
+ $standard_factor = (float)abs($standard_info['factor'])
> 0 ? (float)$standard_info['factor'] : 1;
+
+ $factor = $location_factor * $standard_factor *
$custom_factor;
$factor = $factor ? (float)$factor : 1;
$price_item = $this->get_single($price_item_id);
- $contract =
rental_socontract::get_instance()->get_single($contract_id);
$rented_area = 0;
$total_price = 0;
if ($price_item->is_area())
@@ -380,6 +401,12 @@
$total_price = ($rented_area *
$price_item->get_price() * $factor);
//var_dump($total_price, $rented_area,
$price_item->get_price());
}
+ else
+ {
+ $location_factor = 1;
+ $standard_factor = 1;
+ $custom_factor = 1;
+ }
if ($price_item)
{
$values = array(
@@ -389,8 +416,11 @@
str_replace(',', '.', $rented_area),
"'" . $price_item->get_agresso_id() .
"'",
$price_item->is_area() ? 'true' :
'false',
- (str_replace(',', '.',
$price_item->get_price()) * $factor),
- str_replace(',', '.', $total_price)
+ (str_replace(',', '.',
$price_item->get_price())),
+ str_replace(',', '.', $total_price),
+ $location_factor,
+ $standard_factor,
+ $custom_factor
);
$start_date_field = '';
$end_date_field = '';
@@ -406,7 +436,7 @@
$end_date_field = ", date_end";
}
- $q = "INSERT INTO rental_contract_price_item
(price_item_id, contract_id, title, area, agresso_id, is_area, price,
total_price {$start_date_field} {$end_date_field}) VALUES (" . join(',',
$values) . ")";
+ $q = "INSERT INTO rental_contract_price_item
(price_item_id, contract_id, title, area, agresso_id, is_area, price,
total_price, location_factor, standard_factor, custom_factor
{$start_date_field} {$end_date_field}) VALUES (" . join(',', $values) . ")";
//var_dump($q);
$result = $this->db->query($q);
if ($result)
Modified: trunk/rental/inc/class.uicontract.inc.php
===================================================================
--- trunk/rental/inc/class.uicontract.inc.php 2016-09-02 00:33:59 UTC (rev
15563)
+++ trunk/rental/inc/class.uicontract.inc.php 2016-09-02 08:09:20 UTC (rev
15564)
@@ -447,30 +447,69 @@
private function _get_tableDef_price( $mode, $contract_id )
{
- $columns_def = array(
- array('key' => 'agresso_id', 'label' =>
lang('agresso_id'), 'className' => '',
- 'sortable' => true, 'hidden' => false),
- array('key' => 'title', 'label' =>
lang('name'), 'className' => '', 'sortable' => true,
- 'hidden' => false, 'editor' => $mode ==
'edit' ? true : false),
- array('key' => 'is_area', 'label' =>
lang('title'), 'className' => '', 'sortable' => true,
- 'hidden' => false),
- array('key' => 'price', 'label' =>
lang('price'), 'sortable' => false, 'hidden' => false,
- 'formatter' => 'formatterPrice',
'className' => 'right', 'editor' => $mode == 'edit' ? true : false),
- array("key" => "area", "label" => lang('area'),
"formatter" => "formatterArea",
- 'className' => 'right'),
- array("key" => "count", "label" =>
lang('count'), 'editor' => $mode == 'edit' ? true : false),
- array("key" => "total_price", "label" =>
lang('total_price'), 'formatter' => 'formatterPrice',
- 'className' => 'right'),
- array("key" => "date_start", "label" =>
lang('date_start'), 'formatter' => $mode == 'edit' ?
'formatterDateStart_price_item' : "",
- 'className' => 'center'),
- array("key" => "date_end", "label" =>
lang('date_end'), 'formatter' => $mode == 'edit' ?
'formatterDateEnd_price_item' : "",
- 'className' => 'center'),
- array("key" => "is_one_time", "label" =>
lang('is_one_time'), 'formatter' => $mode == 'edit' ? 'formatterIs_one_time' :
"",
- 'className' => 'center'),
- array("key" => "price_type_title", "label" =>
lang('type'), 'sortable' => false,
- 'className' => 'center')
- );
+ if
(empty($this->config->config_data['contract_furnished_status']))
+ {
+ $columns_def = array(
+ array('key' => 'agresso_id', 'label' =>
lang('agresso_id'), 'className' => '',
+ 'sortable' => true, 'hidden' =>
false),
+ array('key' => 'title', 'label' =>
lang('name'), 'className' => '', 'sortable' => true,
+ 'hidden' => false, 'editor' =>
$mode == 'edit' ? true : false),
+ array('key' => 'is_area', 'label' =>
lang('title'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array('key' => 'price', 'label' =>
lang('price'), 'sortable' => false, 'hidden' => false,
+ 'formatter' =>
'formatterPrice', 'className' => 'right', 'editor' => $mode == 'edit' ? true :
false),
+ array("key" => "area", "label" =>
lang('area'), "formatter" => "formatterArea",
+ 'className' => 'right'),
+ array("key" => "count", "label" =>
lang('count'), 'editor' => $mode == 'edit' ? true : false),
+ array("key" => "total_price", "label"
=> lang('total_price'), 'formatter' => 'formatterPrice',
+ 'className' => 'right'),
+ array("key" => "date_start", "label" =>
lang('date_start'), 'formatter' => $mode == 'edit' ?
'formatterDateStart_price_item' : "",
+ 'className' => 'center'),
+ array("key" => "date_end", "label" =>
lang('date_end'), 'formatter' => $mode == 'edit' ?
'formatterDateEnd_price_item' : "",
+ 'className' => 'center'),
+ array("key" => "is_one_time", "label"
=> lang('is_one_time'), 'formatter' => $mode == 'edit' ? 'formatterIs_one_time'
: "",
+ 'className' => 'center'),
+ array("key" => "price_type_title",
"label" => lang('type'), 'sortable' => false,
+ 'className' => 'center')
+ );
+ }
+ else
+ {
+ $columns_def = array(
+ array('key' => 'agresso_id', 'label' =>
lang('agresso_id'), 'className' => '',
+ 'sortable' => true, 'hidden' =>
false),
+ array('key' => 'title', 'label' =>
lang('name'), 'className' => '', 'sortable' => true,
+ 'hidden' => false, 'editor' =>
$mode == 'edit' ? true : false),
+ array('key' => 'is_area', 'label' =>
lang('title'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array('key' => 'price', 'label' =>
lang('price'), 'sortable' => false, 'hidden' => false,
+ 'formatter' =>
'formatterPrice', 'className' => 'right', 'editor' => $mode == 'edit' ? true :
false),
+ array('key' => 'location_factor',
'label' => lang('location'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array('key' => 'standard_factor',
'label' => lang('standard'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array('key' => 'custom_factor', 'label'
=> lang('custom prize factor'), 'className' => '', 'sortable' => true,
+ 'hidden' => false),
+ array("key" => "area", "label" =>
lang('area'), "formatter" => "formatterArea",
+ 'className' => 'right'),
+ array("key" => "count", "label" =>
lang('count'), 'editor' => $mode == 'edit' ? true : false),
+ array("key" => "total_price", "label"
=> lang('total_price'), 'formatter' => 'formatterPrice',
+ 'className' => 'right'),
+ array("key" => "date_start", "label" =>
lang('date_start'), 'formatter' => $mode == 'edit' ?
'formatterDateStart_price_item' : "",
+ 'className' => 'center'),
+ array("key" => "date_end", "label" =>
lang('date_end'), 'formatter' => $mode == 'edit' ?
'formatterDateEnd_price_item' : "",
+ 'className' => 'center'),
+ array("key" => "is_one_time", "label"
=> lang('is_one_time'), 'formatter' => $mode == 'edit' ? 'formatterIs_one_time'
: "",
+ 'className' => 'center'),
+ array("key" => "price_type_title",
"label" => lang('type'), 'sortable' => false,
+ 'className' => 'center')
+ );
+
+ }
+
+
+
if ($mode == 'edit')
{
$tabletools_price1[] = array
@@ -536,7 +575,7 @@
addPrice(oArgs, parameters);
"
);
-
+/*
$sogeneric = CreateObject('property.sogeneric',
'composite_standard');
$composite_standards =
$sogeneric->read(array('allrows' => true));
foreach ($composite_standards as
$composite_standard)
@@ -559,14 +598,29 @@
"
);
}
+*/
+ if
(empty($this->config->config_data['contract_furnished_status']))
+ {
+ unset($columns_def[4]);
+ unset($columns_def[5]);
+ unset($columns_def[6]);
+ unset($columns_def[7]);
+ unset($columns_def[8]);
+ unset($columns_def[9]);
+ }
+ else
+ {
+ unset($columns_def[4]);
+ unset($columns_def[5]);
+ unset($columns_def[6]);
+ unset($columns_def[7]);
+ unset($columns_def[8]);
+ unset($columns_def[9]);
+ unset($columns_def[10]);
+ unset($columns_def[11]);
+ unset($columns_def[12]);
+ }
- unset($columns_def[4]);
- unset($columns_def[5]);
- unset($columns_def[6]);
- unset($columns_def[7]);
- unset($columns_def[8]);
- unset($columns_def[9]);
-
$datatable_def[] = array
(
'container' => 'datatable-container_6',
@@ -1293,14 +1347,14 @@
// Redirect with error message if
responsibility area is eksternleie and contract type not set
if
(!is_numeric(phpgw::get_var('contract_type')) && (strcmp($responsibility_area,
"contract_type_eksternleie") == 0))
{
-
//$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' => $message,
'error' => $error));
+
//$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' => $message,
'error' => $error));
phpgwapi_cache::message_set(lang('billing_removed_external_contract'), 'error');
$this->edit();
}
}
else
{
- // Gets responsibility area from db (ex:
eksternleie, internleie)
+ // Gets responsibility area from db (ex:
eksternleie, internleie)
$responsibility_area =
rental_socontract::get_instance()->get_responsibility_title($location_id);
// Redirect with error message if
responsibility area is eksternleie and contract type not set
@@ -2514,7 +2568,6 @@
{
$contract_id = (int)phpgw::get_var('contract_id');
$list_price_item_id = phpgw::get_var('price_item_id');
- $factor = phpgw::get_var('factor', 'float');
$so_contract = rental_socontract::get_instance();
$contract = $so_contract->get_single($contract_id);
@@ -2524,7 +2577,7 @@
//return
rental_soprice_item::get_instance()->add_price_item($contract_id,
$price_item_id, $factor);
foreach ($list_price_item_id as $price_item_id)
{
- $result =
rental_soprice_item::get_instance()->add_price_item($contract_id,
$price_item_id, $factor);
+ $result =
rental_soprice_item::get_instance()->add_price_item($contract_id,
$price_item_id);
if ($result)
{
$message['message'][] =
array('msg' => 'price_item ' . $price_item_id . ' ' . lang('has been added'));
@@ -2678,8 +2731,8 @@
}
/**
- *
- * Public function scans the contract template directory for
pdf contract templates
+ *
+ * Public function scans the contract template directory for
pdf contract templates
*/
public function get_pdf_templates()
{
Modified: trunk/rental/inc/model/class.contract_price_item.inc.php
===================================================================
--- trunk/rental/inc/model/class.contract_price_item.inc.php 2016-09-02
00:33:59 UTC (rev 15563)
+++ trunk/rental/inc/model/class.contract_price_item.inc.php 2016-09-02
08:09:20 UTC (rev 15564)
@@ -18,6 +18,9 @@
protected $date_end;
protected $is_one_time;
protected $is_billed;
+ protected $location_factor;
+ protected $standard_factor;
+ protected $custom_factor;
/**
* Constructor. Takes an optional ID. If a price item is
created from outside
@@ -119,6 +122,33 @@
$this->date_end = $date_end;
}
+ public function get_location_factor()
+ {
+ return $this->location_factor;
+ }
+
+ public function set_location_factor( $location_factor )
+ {
+ $this->location_factor = $location_factor;
+ }
+ public function get_standard_factor()
+ {
+ return $this->standard_factor;
+ }
+
+ public function set_standard_factor( $standard_factor )
+ {
+ $this->standard_factor = $standard_factor;
+ }
+ public function get_custom_factor()
+ {
+ return $this->custom_factor;
+ }
+
+ public function set_custom_factor( $custom_factor )
+ {
+ $this->custom_factor = $custom_factor;
+ }
/**
* Returns true if the price item is active at the given date,
false otherwise
*
@@ -199,6 +229,9 @@
//'total_price' => $currency_prefix.'
'.$this->get_total_price(),
'total_price' => $this->get_total_price(),
'is_one_time' => $this->is_one_time(),
+ 'location_factor' =>
$this->get_location_factor(),
+ 'standard_factor' =>
$this->get_standard_factor(),
+ 'custom_factor' => $this->get_custom_factor(),
// We set a format fitting for the
DateCellEditor here because
// this table has inline editing enabled. The
DateCellEditor is not
// happy about empty values if a custom parser
is set, so we use the
Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang 2016-09-02 00:33:59 UTC (rev 15563)
+++ trunk/rental/setup/phpgw_no.lang 2016-09-02 08:09:20 UTC (rev 15564)
@@ -634,4 +634,5 @@
rejected rental no Avvist
approved rental no Godkjent
location rental no Lokalisering
-custom prize factor rental no Prisfaktor
\ No newline at end of file
+custom prize factor rental no Prisfaktor
+standard rental no Standard
\ No newline at end of file
Modified: trunk/rental/setup/setup.inc.php
===================================================================
--- trunk/rental/setup/setup.inc.php 2016-09-02 00:33:59 UTC (rev 15563)
+++ trunk/rental/setup/setup.inc.php 2016-09-02 08:09:20 UTC (rev 15564)
@@ -1,6 +1,6 @@
<?php
$setup_info['rental']['name'] = 'rental'; // Module identifier
- $setup_info['rental']['version'] = '0.1.0.26'; // Current module version
+ $setup_info['rental']['version'] = '0.1.0.27'; // 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_update.inc.php
===================================================================
--- trunk/rental/setup/tables_update.inc.php 2016-09-02 00:33:59 UTC (rev
15563)
+++ trunk/rental/setup/tables_update.inc.php 2016-09-02 08:09:20 UTC (rev
15564)
@@ -596,3 +596,38 @@
}
}
+ $test[] = '0.1.0.26';
+ function rental_upgrade0_1_0_26()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_contract_price_item',
'location_factor', array(
+ 'type' => 'decimal',
+ 'precision' => '20',
+ 'scale' => '2',
+ 'nullable' => true,
+ 'default' => '1.00'
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_contract_price_item',
'standard_factor', array(
+ 'type' => 'decimal',
+ 'precision' => '20',
+ 'scale' => '2',
+ 'nullable' => true,
+ 'default' => '1.00'
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_contract_price_item',
'custom_factor', array(
+ 'type' => 'decimal',
+ 'precision' => '20',
+ 'scale' => '2',
+ 'nullable' => true,
+ 'default' => '1.00'
+ ));
+
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['rental']['currentver'] =
'0.1.0.27';
+ return $GLOBALS['setup_info']['rental']['currentver'];
+ }
+ }
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15564] Rental: price adjustments,
sigurdne <=