From 25e0f95089cff9e817f38ec101d1b9688a05c64d Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Sat, 21 Oct 2017 10:04:35 +0100 Subject: [PATCH] Add database changes to support > 2 decimal places in calculations --- CRM/Member/DAO/MembershipType.php | 6 +++--- CRM/Price/DAO/PriceFieldValue.php | 12 +++++++----- CRM/Upgrade/Incremental/sql/4.7.28.mysql.tpl | 4 ++++ xml/schema/Member/MembershipType.xml | 1 + xml/schema/Price/PriceFieldValue.xml | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CRM/Member/DAO/MembershipType.php b/CRM/Member/DAO/MembershipType.php index b0e32cc43b..3077ceba0f 100644 --- a/CRM/Member/DAO/MembershipType.php +++ b/CRM/Member/DAO/MembershipType.php @@ -30,7 +30,7 @@ * * Generated from xml/schema/CRM/Member/MembershipType.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:22af2c3f87df3ad7cf2002c145f53cc6) + * (GenCodeChecksum:c86019d4817d79e1dd59d69eaa2a3eb6) */ require_once 'CRM/Core/DAO.php'; require_once 'CRM/Utils/Type.php'; @@ -299,8 +299,8 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO { 'title' => ts('membership Type Minimum Fee') , 'description' => 'Minimum fee for this membership (0 for free/complimentary memberships).', 'precision' => array( - 20, - 2 + 18, + 9 ) , 'table_name' => 'civicrm_membership_type', 'entity' => 'MembershipType', diff --git a/CRM/Price/DAO/PriceFieldValue.php b/CRM/Price/DAO/PriceFieldValue.php index f9de529cfa..fb0465b855 100644 --- a/CRM/Price/DAO/PriceFieldValue.php +++ b/CRM/Price/DAO/PriceFieldValue.php @@ -30,7 +30,7 @@ * * Generated from xml/schema/CRM/Price/PriceFieldValue.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:d5b9853fb1321ad9872ce5b11a582d81) + * (GenCodeChecksum:fed218269d1baab495490130b4e2442a) */ require_once 'CRM/Core/DAO.php'; require_once 'CRM/Utils/Type.php'; @@ -95,7 +95,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO { /** * Price field option amount * - * @var string + * @var float */ public $amount; /** @@ -292,12 +292,14 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO { ) , 'amount' => array( 'name' => 'amount', - 'type' => CRM_Utils_Type::T_STRING, + 'type' => CRM_Utils_Type::T_MONEY, 'title' => ts('Amount') , 'description' => 'Price field option amount', 'required' => true, - 'maxlength' => 512, - 'size' => 8, + 'precision' => array( + 18, + 9 + ) , 'table_name' => 'civicrm_price_field_value', 'entity' => 'PriceFieldValue', 'bao' => 'CRM_Price_BAO_PriceFieldValue', diff --git a/CRM/Upgrade/Incremental/sql/4.7.28.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.28.mysql.tpl index 432a1628be..f4024bcb75 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.28.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.28.mysql.tpl @@ -49,3 +49,7 @@ UPDATE `civicrm_state_province` SET `name` = 'Sălaj' WHERE `name` = 'Sa laj' AN UPDATE `civicrm_state_province` SET `name` = 'Timiș' WHERE `name` = 'Timis' AND `country_id` = 1176; UPDATE `civicrm_state_province` SET `name` = 'Vâlcea' WHERE `name` = 'Valcea' AND `country_id` = 1176; UPDATE `civicrm_state_province` SET `name` = 'Pazardzhik' WHERE `name` = 'Pazardzik' AND `country_id` = 1033; + +-- CRM-20772 Price set calculation precision when sales tax enabled +ALTER TABLE `civicrm_membership_type` CHANGE `minimum_fee` `minimum_fee` DECIMAL(18,9) NULL DEFAULT '0.00' COMMENT 'Minimum fee for this membership (0 for free/complimentary memberships).'; +ALTER TABLE `civicrm_price_field_value` CHANGE `amount` `amount` DECIMAL(18,9) NOT NULL COMMENT 'Price field option amount'; diff --git a/xml/schema/Member/MembershipType.xml b/xml/schema/Member/MembershipType.xml index e1cca9d096..6b6f926822 100644 --- a/xml/schema/Member/MembershipType.xml +++ b/xml/schema/Member/MembershipType.xml @@ -116,6 +116,7 @@ minimum_fee membership Type Minimum Fee decimal + 18,9 Minimum fee for this membership (0 for free/complimentary memberships). 0 1.5 diff --git a/xml/schema/Price/PriceFieldValue.xml b/xml/schema/Price/PriceFieldValue.xml index b68992a1b4..03cc83453d 100644 --- a/xml/schema/Price/PriceFieldValue.xml +++ b/xml/schema/Price/PriceFieldValue.xml @@ -95,9 +95,9 @@ amount - varchar + decimal Amount - 512 + 18,9 Text 8 -- 2.25.1