Fix sql field can't be named 'offset' (reserved word).
This commit is contained in:
parent
8058712d47
commit
d1e7577eed
@ -274,7 +274,15 @@ class DoliDBPgsql extends DoliDB
|
|||||||
$line.= "ALTER TABLE ".$reg[1]." ADD PRIMARY KEY (".$reg[3];
|
$line.= "ALTER TABLE ".$reg[1]." ADD PRIMARY KEY (".$reg[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate order to drop foreign keys
|
// Translate order to drop primary keys
|
||||||
|
// ALTER TABLE llx_dolibarr_modules DROP PRIMARY KEY pk_xxx
|
||||||
|
if (preg_match('/ALTER\s+TABLE\s*(.*)\s*DROP\s+PRIMARY\s+KEY\s*([^;]+)$/i',$line,$reg))
|
||||||
|
{
|
||||||
|
$line = "-- ".$line." replaced by --\n";
|
||||||
|
$line.= "ALTER TABLE ".$reg[1]." DROP CONSTRAINT ".$reg[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate order to drop foreign keys
|
||||||
// ALTER TABLE llx_dolibarr_modules DROP FOREIGN KEY fk_xxx
|
// ALTER TABLE llx_dolibarr_modules DROP FOREIGN KEY fk_xxx
|
||||||
if (preg_match('/ALTER\s+TABLE\s*(.*)\s*DROP\s+FOREIGN\s+KEY\s*(.*)$/i',$line,$reg))
|
if (preg_match('/ALTER\s+TABLE\s*(.*)\s*DROP\s+FOREIGN\s+KEY\s*(.*)$/i',$line,$reg))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -68,8 +68,8 @@ else
|
|||||||
if (empty($range)) echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'range' => $range));
|
if (empty($range)) echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'range' => $range));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$offset = price($range->offset, 0, $langs, 1, -1, -1, $conf->currency);
|
$ikoffset = price($range->ikoffset, 0, $langs, 1, -1, -1, $conf->currency);
|
||||||
echo json_encode(array('up' => $range->coef, 'offset' => $range->offset, 'title' => $langs->transnoentitiesnoconv('ExpenseRangeOffset', $offset), 'comment' => 'offset should be apply on addline or updateline'));
|
echo json_encode(array('up' => $range->coef, 'ikoffset' => $range->ikoffset, 'title' => $langs->transnoentitiesnoconv('ExpenseRangeOffset', $offset), 'comment' => 'offset should be apply on addline or updateline'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1833,13 +1833,13 @@ class ExpenseReport extends CommonObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_EXPENSE_APPLY_ENTIRE_OFFSET)) $offset = $range->offset;
|
if (!empty($conf->global->MAIN_EXPENSE_APPLY_ENTIRE_OFFSET)) $ikoffset = $range->ikoffset;
|
||||||
else $offset = $range->offset / 12; // The amount of offset is a global value for the year
|
else $ikoffset = $range->ikoffset / 12; // The amount of offset is a global value for the year
|
||||||
|
|
||||||
// Test if offset has been applied for the current month
|
// Test if ikoffset has been applied for the current month
|
||||||
if (!$this->offsetAlreadyGiven())
|
if (!$this->offsetAlreadyGiven())
|
||||||
{
|
{
|
||||||
$new_up = $range->coef + ($offset / $this->line->qty);
|
$new_up = $range->coef + ($ikoffset / $this->line->qty);
|
||||||
$tmp = calcul_price_total($this->line->qty, $new_up, 0, $this->line->vatrate, 0, 0, 0, 'TTC', 0, $type, $seller);
|
$tmp = calcul_price_total($this->line->qty, $new_up, 0, $this->line->vatrate, 0, 0, 0, 'TTC', 0, $type, $seller);
|
||||||
|
|
||||||
$this->line->value_unit = $tmp[5];
|
$this->line->value_unit = $tmp[5];
|
||||||
@ -1854,7 +1854,7 @@ class ExpenseReport extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the sql find any rows then the offset is already given (offset is applied at the first expense report line)
|
* If the sql find any rows then the ikoffset is already given (ikoffset is applied at the first expense report line)
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -55,7 +55,7 @@ class ExpenseReportIk extends CoreObject
|
|||||||
* Offset
|
* Offset
|
||||||
* @var double
|
* @var double
|
||||||
*/
|
*/
|
||||||
public $offset;
|
public $ikoffset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute object linked with database
|
* Attribute object linked with database
|
||||||
@ -66,7 +66,7 @@ class ExpenseReportIk extends CoreObject
|
|||||||
,'fk_c_exp_tax_cat'=>array('type'=>'integer','index'=>true)
|
,'fk_c_exp_tax_cat'=>array('type'=>'integer','index'=>true)
|
||||||
,'fk_range'=>array('type'=>'integer','index'=>true)
|
,'fk_range'=>array('type'=>'integer','index'=>true)
|
||||||
,'coef'=>array('type'=>'double')
|
,'coef'=>array('type'=>'double')
|
||||||
,'offset'=>array('type'=>'double')
|
,'ikoffset'=>array('type'=>'double')
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -218,7 +218,8 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik (
|
|||||||
fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL,
|
fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL,
|
||||||
fk_range integer DEFAULT 0 NOT NULL,
|
fk_range integer DEFAULT 0 NOT NULL,
|
||||||
coef double DEFAULT 0 NOT NULL,
|
coef double DEFAULT 0 NOT NULL,
|
||||||
offset double DEFAULT 0 NOT NULL
|
ikoffset double DEFAULT 0 NOT NULL,
|
||||||
|
active integer DEFAULT 1
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS llx_c_exp_tax_cat (
|
CREATE TABLE IF NOT EXISTS llx_c_exp_tax_cat (
|
||||||
@ -260,21 +261,21 @@ INSERT INTO llx_c_type_fees (code, label, active, accountancy_code) VALUES
|
|||||||
('EX_PAR_VP', 'ExpLabelParkingPV', 0, '625160'),
|
('EX_PAR_VP', 'ExpLabelParkingPV', 0, '625160'),
|
||||||
('EX_CAM_VP', 'ExpLabelMaintenanceRepairPV', 0, '615300');
|
('EX_CAM_VP', 'ExpLabelMaintenanceRepairPV', 0, '615300');
|
||||||
|
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (1,4, 1, 0.41, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (1,4, 1, 0.41, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (2,4, 2, 0.244, 824);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (2,4, 2, 0.244, 824);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (3,4, 3, 0.286, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (3,4, 3, 0.286, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (4,5, 4, 0.493, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (4,5, 4, 0.493, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (5,5, 5, 0.277, 1082);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (5,5, 5, 0.277, 1082);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (6,5, 6, 0.332, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (6,5, 6, 0.332, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (7,6, 7, 0.543, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (7,6, 7, 0.543, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (8,6, 8, 0.305, 1180);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (8,6, 8, 0.305, 1180);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (9,6, 9, 0.364, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (9,6, 9, 0.364, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (10,7, 10, 0.568, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (10,7, 10, 0.568, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (11,7, 11, 0.32, 1244);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (11,7, 11, 0.32, 1244);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (12,7, 12, 0.382, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (12,7, 12, 0.382, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (13,8, 13, 0.595, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (13,8, 13, 0.595, 0);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (14,8, 14, 0.337, 1288);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (14,8, 14, 0.337, 1288);
|
||||||
INSERT INTO llx_expensereport_ik (rowid,fk_c_exp_tax_cat, fk_range, coef, offset) values (15,8, 15, 0.401, 0);
|
INSERT INTO llx_expensereport_ik (rowid, fk_c_exp_tax_cat, fk_range, coef, ikoffset) values (15,8, 15, 0.401, 0);
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO llx_c_exp_tax_cat (rowid, label, entity, active) values (1,'ExpAutoCat', 1, 1);
|
INSERT INTO llx_c_exp_tax_cat (rowid, label, entity, active) values (1,'ExpAutoCat', 1, 1);
|
||||||
@ -415,12 +416,12 @@ DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_DEVISE')__;
|
|||||||
DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_PIECE')__;
|
DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_PIECE')__;
|
||||||
DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPENSEREPORT_JOURNAL')__;
|
DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPENSEREPORT_JOURNAL')__;
|
||||||
|
|
||||||
ALTER TABLE llx_c_paiement DROP PRIMARY KEY;
|
-- VMYSQL4.1 ALTER TABLE llx_c_paiement DROP PRIMARY KEY;
|
||||||
ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id;
|
ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id;
|
||||||
ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement;
|
ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement;
|
||||||
ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(id, entity, code);
|
ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(id, entity, code);
|
||||||
|
|
||||||
ALTER TABLE llx_c_payment_term DROP PRIMARY KEY;
|
-- VMYSQL4.1 ALTER TABLE llx_c_payment_term DROP PRIMARY KEY;
|
||||||
ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
|
ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
|
||||||
ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(rowid, entity, code);
|
ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(rowid, entity, code);
|
||||||
|
|
||||||
|
|||||||
@ -25,5 +25,6 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik (
|
|||||||
fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL,
|
fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL,
|
||||||
fk_range integer DEFAULT 0 NOT NULL,
|
fk_range integer DEFAULT 0 NOT NULL,
|
||||||
coef double DEFAULT 0 NOT NULL,
|
coef double DEFAULT 0 NOT NULL,
|
||||||
offset double DEFAULT 0 NOT NULL
|
ikoffset double DEFAULT 0 NOT NULL,
|
||||||
|
active integer DEFAULT 1
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
Loading…
Reference in New Issue
Block a user