Browse Source

DB change quantity field from int to float TG-47

SiM 3 years ago
parent
commit
f66f0f9790

+ 9 - 9
config/schema.yml

@@ -219,10 +219,10 @@ propel:
     product_price_euro:     { type: float, required: true }
     product_margin:         { type: float }
     product_tva_rate:       { type: float, default: 0 }
-    quantity:               { type: integer, required: true, default: 1 }
-    quantity_adjusted:      { type: integer, default: 0 }
+    quantity:               { type: float, required: true, default: 1 }
+    quantity_adjusted:      { type: float, default: 0 }
     has_been_adjusted:      { type: integer, size: 1, default: 0 }
-    quantity_delivered:     { type: integer, default: 0 }
+    quantity_delivered:     { type: float, default: 0 }
     katao_order_product_id: { type: integer, foreignTable: katao_order_product, foreignReference: id, onDelete: setnull }
     created_at:
     updated_at:
@@ -256,9 +256,9 @@ propel:
     product_price_euro:  { type: float, required: true }
     product_margin:      { type: float }
     product_tva_rate:    { type: float, default: 0 }
-    quantity:            { type: integer, required: true, default: 1 }
-    quantity_received:   { type: integer, default: 0 }
-    quantity_delivered:  { type: integer, default: 0 }
+    quantity:            { type: float, required: true, default: 1 }
+    quantity_received:   { type: float, default: 0 }
+    quantity_delivered:  { type: float, default: 0 }
     has_been_received:   { type: integer, size: 1, default: 0 }
     has_been_delivered:  { type: integer, size: 1, default: 0 }
     created_at:
@@ -296,8 +296,8 @@ propel:
     product_price_euro:     { type: float, required: true }
     product_margin:         { type: float }
     product_tva_rate:       { type: float, default: 0 }
-    quantity:               { type: integer, required: true, default: 1 }
-    quantity_delivered:     { type: integer, default: 0 }
+    quantity:               { type: float, required: true, default: 1 }
+    quantity_delivered:     { type: float, default: 0 }
     sol_amount:             { type: integer, default: 0 }
     created_at:
     updated_at:
@@ -374,7 +374,7 @@ propel:
     product_price_euro:        { type: float, required: true }
     product_margin:            { type: float }
     product_tva_rate:          { type: float, default: 0 }
-    quantity:                  { type: integer, required: true, default: 1 }
+    quantity:                  { type: float, required: true, default: 1 }
     product_price_total:       { type: float, default: 0 }
     created_at:
     updated_at:

+ 9 - 9
data/sql/lib.model.schema.sql

@@ -592,10 +592,10 @@ CREATE TABLE `katao_cart_product`
 	`product_price_euro` FLOAT  NOT NULL,
 	`product_margin` FLOAT,
 	`product_tva_rate` FLOAT default 0,
-	`quantity` INTEGER default 1 NOT NULL,
-	`quantity_adjusted` INTEGER default 0,
+	`quantity` FLOAT default 1 NOT NULL,
+	`quantity_adjusted` FLOAT default 0,
 	`has_been_adjusted` INTEGER(1) default 0,
-	`quantity_delivered` INTEGER default 0,
+	`quantity_delivered` FLOAT default 0,
 	`katao_order_product_id` INTEGER,
 	`created_at` DATETIME,
 	`updated_at` DATETIME,
@@ -681,9 +681,9 @@ CREATE TABLE `katao_order_product`
 	`product_price_euro` FLOAT  NOT NULL,
 	`product_margin` FLOAT,
 	`product_tva_rate` FLOAT default 0,
-	`quantity` INTEGER default 1 NOT NULL,
-	`quantity_received` INTEGER default 0,
-	`quantity_delivered` INTEGER default 0,
+	`quantity` FLOAT default 1 NOT NULL,
+	`quantity_received` FLOAT default 0,
+	`quantity_delivered` FLOAT default 0,
 	`has_been_received` INTEGER(1) default 0,
 	`has_been_delivered` INTEGER(1) default 0,
 	`created_at` DATETIME,
@@ -773,8 +773,8 @@ CREATE TABLE `katao_invoice_product`
 	`product_price_euro` FLOAT  NOT NULL,
 	`product_margin` FLOAT,
 	`product_tva_rate` FLOAT default 0,
-	`quantity` INTEGER default 1 NOT NULL,
-	`quantity_delivered` INTEGER default 0,
+	`quantity` FLOAT default 1 NOT NULL,
+	`quantity_delivered` FLOAT default 0,
 	`sol_amount` INTEGER default 0,
 	`created_at` DATETIME,
 	`updated_at` DATETIME,
@@ -940,7 +940,7 @@ CREATE TABLE `katao_supplier_invoice_product`
 	`product_price_euro` FLOAT  NOT NULL,
 	`product_margin` FLOAT,
 	`product_tva_rate` FLOAT default 0,
-	`quantity` INTEGER default 1 NOT NULL,
+	`quantity` FLOAT default 1 NOT NULL,
 	`product_price_total` FLOAT default 0,
 	`created_at` DATETIME,
 	`updated_at` DATETIME,

+ 13 - 0
data/sql/patch_2018-11-14_gestion-decimales.sql

@@ -3,4 +3,17 @@ START TRANSACTION;
 
 ALTER TABLE `katao_product` ADD `authorize_decimal` INTEGER(1) default 0 AFTER `unit_price_euro`;
 
+ALTER TABLE `katao_cart_product` MODIFY `quantity` FLOAT;
+ALTER TABLE `katao_cart_product` MODIFY `quantity_delivered` FLOAT;
+ALTER TABLE `katao_cart_product` MODIFY `quantity_adjusted` FLOAT;
+
+ALTER TABLE `katao_order_product` MODIFY `quantity` FLOAT;
+ALTER TABLE `katao_order_product` MODIFY `quantity_received` FLOAT;
+ALTER TABLE `katao_order_product` MODIFY `quantity_delivered` FLOAT;
+
+ALTER TABLE `katao_invoice_product` MODIFY `quantity` FLOAT;
+ALTER TABLE `katao_invoice_product` MODIFY `quantity_delivered` FLOAT;
+
+ALTER TABLE `katao_supplier_invoice_product` MODIFY `quantity` FLOAT;
+
 COMMIT;

+ 3 - 3
lib/model/map/KataoCartProductMapBuilder.php

@@ -77,13 +77,13 @@ class KataoCartProductMapBuilder {
 
 		$tMap->addColumn('PRODUCT_TVA_RATE', 'ProductTvaRate', 'double', CreoleTypes::FLOAT, false, null);
 
-		$tMap->addColumn('QUANTITY', 'Quantity', 'int', CreoleTypes::INTEGER, true, null);
+		$tMap->addColumn('QUANTITY', 'Quantity', 'double', CreoleTypes::FLOAT, true, null);
 
-		$tMap->addColumn('QUANTITY_ADJUSTED', 'QuantityAdjusted', 'int', CreoleTypes::INTEGER, false, null);
+		$tMap->addColumn('QUANTITY_ADJUSTED', 'QuantityAdjusted', 'double', CreoleTypes::FLOAT, false, null);
 
 		$tMap->addColumn('HAS_BEEN_ADJUSTED', 'HasBeenAdjusted', 'int', CreoleTypes::INTEGER, false, 1);
 
-		$tMap->addColumn('QUANTITY_DELIVERED', 'QuantityDelivered', 'int', CreoleTypes::INTEGER, false, null);
+		$tMap->addColumn('QUANTITY_DELIVERED', 'QuantityDelivered', 'double', CreoleTypes::FLOAT, false, null);
 
 		$tMap->addForeignKey('KATAO_ORDER_PRODUCT_ID', 'KataoOrderProductId', 'int', CreoleTypes::INTEGER, 'katao_order_product', 'ID', false, null);
 

+ 2 - 2
lib/model/map/KataoInvoiceProductMapBuilder.php

@@ -81,9 +81,9 @@ class KataoInvoiceProductMapBuilder {
 
 		$tMap->addColumn('PRODUCT_TVA_RATE', 'ProductTvaRate', 'double', CreoleTypes::FLOAT, false, null);
 
-		$tMap->addColumn('QUANTITY', 'Quantity', 'int', CreoleTypes::INTEGER, true, null);
+		$tMap->addColumn('QUANTITY', 'Quantity', 'double', CreoleTypes::FLOAT, true, null);
 
-		$tMap->addColumn('QUANTITY_DELIVERED', 'QuantityDelivered', 'int', CreoleTypes::INTEGER, false, null);
+		$tMap->addColumn('QUANTITY_DELIVERED', 'QuantityDelivered', 'double', CreoleTypes::FLOAT, false, null);
 
 		$tMap->addColumn('SOL_AMOUNT', 'SolAmount', 'int', CreoleTypes::INTEGER, false, null);
 

+ 3 - 3
lib/model/map/KataoOrderProductMapBuilder.php

@@ -77,11 +77,11 @@ class KataoOrderProductMapBuilder {
 
 		$tMap->addColumn('PRODUCT_TVA_RATE', 'ProductTvaRate', 'double', CreoleTypes::FLOAT, false, null);
 
-		$tMap->addColumn('QUANTITY', 'Quantity', 'int', CreoleTypes::INTEGER, true, null);
+		$tMap->addColumn('QUANTITY', 'Quantity', 'double', CreoleTypes::FLOAT, true, null);
 
-		$tMap->addColumn('QUANTITY_RECEIVED', 'QuantityReceived', 'int', CreoleTypes::INTEGER, false, null);
+		$tMap->addColumn('QUANTITY_RECEIVED', 'QuantityReceived', 'double', CreoleTypes::FLOAT, false, null);
 
-		$tMap->addColumn('QUANTITY_DELIVERED', 'QuantityDelivered', 'int', CreoleTypes::INTEGER, false, null);
+		$tMap->addColumn('QUANTITY_DELIVERED', 'QuantityDelivered', 'double', CreoleTypes::FLOAT, false, null);
 
 		$tMap->addColumn('HAS_BEEN_RECEIVED', 'HasBeenReceived', 'int', CreoleTypes::INTEGER, false, 1);
 

+ 1 - 1
lib/model/map/KataoSupplierInvoiceProductMapBuilder.php

@@ -77,7 +77,7 @@ class KataoSupplierInvoiceProductMapBuilder {
 
 		$tMap->addColumn('PRODUCT_TVA_RATE', 'ProductTvaRate', 'double', CreoleTypes::FLOAT, false, null);
 
-		$tMap->addColumn('QUANTITY', 'Quantity', 'int', CreoleTypes::INTEGER, true, null);
+		$tMap->addColumn('QUANTITY', 'Quantity', 'double', CreoleTypes::FLOAT, true, null);
 
 		$tMap->addColumn('PRODUCT_PRICE_TOTAL', 'ProductPriceTotal', 'double', CreoleTypes::FLOAT, false, null);
 

+ 12 - 30
lib/model/om/BaseKataoCartProduct.php

@@ -77,14 +77,14 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 
 	/**
 	 * The value for the quantity field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity = 1;
 
 
 	/**
 	 * The value for the quantity_adjusted field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity_adjusted = 0;
 
@@ -98,7 +98,7 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 
 	/**
 	 * The value for the quantity_delivered field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity_delivered = 0;
 
@@ -255,7 +255,7 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 	/**
 	 * Get the [quantity] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantity()
 	{
@@ -266,7 +266,7 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 	/**
 	 * Get the [quantity_adjusted] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantityAdjusted()
 	{
@@ -288,7 +288,7 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 	/**
 	 * Get the [quantity_delivered] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantityDelivered()
 	{
@@ -538,18 +538,12 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 	/**
 	 * Set the value of [quantity] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantity($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity !== $v || $v === 1) {
 			$this->quantity = $v;
 			$this->modifiedColumns[] = KataoCartProductPeer::QUANTITY;
@@ -560,18 +554,12 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 	/**
 	 * Set the value of [quantity_adjusted] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantityAdjusted($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity_adjusted !== $v || $v === 0) {
 			$this->quantity_adjusted = $v;
 			$this->modifiedColumns[] = KataoCartProductPeer::QUANTITY_ADJUSTED;
@@ -604,18 +592,12 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 	/**
 	 * Set the value of [quantity_delivered] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantityDelivered($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity_delivered !== $v || $v === 0) {
 			$this->quantity_delivered = $v;
 			$this->modifiedColumns[] = KataoCartProductPeer::QUANTITY_DELIVERED;
@@ -730,13 +712,13 @@ abstract class BaseKataoCartProduct extends BaseObject  implements Persistent {
 
 			$this->product_tva_rate = $rs->getFloat($startcol + 7);
 
-			$this->quantity = $rs->getInt($startcol + 8);
+			$this->quantity = $rs->getFloat($startcol + 8);
 
-			$this->quantity_adjusted = $rs->getInt($startcol + 9);
+			$this->quantity_adjusted = $rs->getFloat($startcol + 9);
 
 			$this->has_been_adjusted = $rs->getInt($startcol + 10);
 
-			$this->quantity_delivered = $rs->getInt($startcol + 11);
+			$this->quantity_delivered = $rs->getFloat($startcol + 11);
 
 			$this->katao_order_product_id = $rs->getInt($startcol + 12);
 

+ 8 - 20
lib/model/om/BaseKataoInvoiceProduct.php

@@ -91,14 +91,14 @@ abstract class BaseKataoInvoiceProduct extends BaseObject  implements Persistent
 
 	/**
 	 * The value for the quantity field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity = 1;
 
 
 	/**
 	 * The value for the quantity_delivered field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity_delivered = 0;
 
@@ -270,7 +270,7 @@ abstract class BaseKataoInvoiceProduct extends BaseObject  implements Persistent
 	/**
 	 * Get the [quantity] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantity()
 	{
@@ -281,7 +281,7 @@ abstract class BaseKataoInvoiceProduct extends BaseObject  implements Persistent
 	/**
 	 * Get the [quantity_delivered] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantityDelivered()
 	{
@@ -583,18 +583,12 @@ abstract class BaseKataoInvoiceProduct extends BaseObject  implements Persistent
 	/**
 	 * Set the value of [quantity] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantity($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity !== $v || $v === 1) {
 			$this->quantity = $v;
 			$this->modifiedColumns[] = KataoInvoiceProductPeer::QUANTITY;
@@ -605,18 +599,12 @@ abstract class BaseKataoInvoiceProduct extends BaseObject  implements Persistent
 	/**
 	 * Set the value of [quantity_delivered] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantityDelivered($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity_delivered !== $v || $v === 0) {
 			$this->quantity_delivered = $v;
 			$this->modifiedColumns[] = KataoInvoiceProductPeer::QUANTITY_DELIVERED;
@@ -731,9 +719,9 @@ abstract class BaseKataoInvoiceProduct extends BaseObject  implements Persistent
 
 			$this->product_tva_rate = $rs->getFloat($startcol + 9);
 
-			$this->quantity = $rs->getInt($startcol + 10);
+			$this->quantity = $rs->getFloat($startcol + 10);
 
-			$this->quantity_delivered = $rs->getInt($startcol + 11);
+			$this->quantity_delivered = $rs->getFloat($startcol + 11);
 
 			$this->sol_amount = $rs->getInt($startcol + 12);
 

+ 12 - 30
lib/model/om/BaseKataoOrderProduct.php

@@ -77,21 +77,21 @@ abstract class BaseKataoOrderProduct extends BaseObject  implements Persistent {
 
 	/**
 	 * The value for the quantity field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity = 1;
 
 
 	/**
 	 * The value for the quantity_received field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity_received = 0;
 
 
 	/**
 	 * The value for the quantity_delivered field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity_delivered = 0;
 
@@ -262,7 +262,7 @@ abstract class BaseKataoOrderProduct extends BaseObject  implements Persistent {
 	/**
 	 * Get the [quantity] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantity()
 	{
@@ -273,7 +273,7 @@ abstract class BaseKataoOrderProduct extends BaseObject  implements Persistent {
 	/**
 	 * Get the [quantity_received] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantityReceived()
 	{
@@ -284,7 +284,7 @@ abstract class BaseKataoOrderProduct extends BaseObject  implements Persistent {
 	/**
 	 * Get the [quantity_delivered] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantityDelivered()
 	{
@@ -545,18 +545,12 @@ abstract class BaseKataoOrderProduct extends BaseObject  implements Persistent {
 	/**
 	 * Set the value of [quantity] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantity($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity !== $v || $v === 1) {
 			$this->quantity = $v;
 			$this->modifiedColumns[] = KataoOrderProductPeer::QUANTITY;
@@ -567,18 +561,12 @@ abstract class BaseKataoOrderProduct extends BaseObject  implements Persistent {
 	/**
 	 * Set the value of [quantity_received] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantityReceived($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity_received !== $v || $v === 0) {
 			$this->quantity_received = $v;
 			$this->modifiedColumns[] = KataoOrderProductPeer::QUANTITY_RECEIVED;
@@ -589,18 +577,12 @@ abstract class BaseKataoOrderProduct extends BaseObject  implements Persistent {
 	/**
 	 * Set the value of [quantity_delivered] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantityDelivered($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity_delivered !== $v || $v === 0) {
 			$this->quantity_delivered = $v;
 			$this->modifiedColumns[] = KataoOrderProductPeer::QUANTITY_DELIVERED;
@@ -733,11 +715,11 @@ abstract class BaseKataoOrderProduct extends BaseObject  implements Persistent {
 
 			$this->product_tva_rate = $rs->getFloat($startcol + 7);
 
-			$this->quantity = $rs->getInt($startcol + 8);
+			$this->quantity = $rs->getFloat($startcol + 8);
 
-			$this->quantity_received = $rs->getInt($startcol + 9);
+			$this->quantity_received = $rs->getFloat($startcol + 9);
 
-			$this->quantity_delivered = $rs->getInt($startcol + 10);
+			$this->quantity_delivered = $rs->getFloat($startcol + 10);
 
 			$this->has_been_received = $rs->getInt($startcol + 11);
 

+ 4 - 10
lib/model/om/BaseKataoSupplierInvoiceProduct.php

@@ -77,7 +77,7 @@ abstract class BaseKataoSupplierInvoiceProduct extends BaseObject  implements Pe
 
 	/**
 	 * The value for the quantity field.
-	 * @var        int
+	 * @var        double
 	 */
 	protected $quantity = 1;
 
@@ -217,7 +217,7 @@ abstract class BaseKataoSupplierInvoiceProduct extends BaseObject  implements Pe
 	/**
 	 * Get the [quantity] column value.
 	 * 
-	 * @return     int
+	 * @return     double
 	 */
 	public function getQuantity()
 	{
@@ -467,18 +467,12 @@ abstract class BaseKataoSupplierInvoiceProduct extends BaseObject  implements Pe
 	/**
 	 * Set the value of [quantity] column.
 	 * 
-	 * @param      int $v new value
+	 * @param      double $v new value
 	 * @return     void
 	 */
 	public function setQuantity($v)
 	{
 
-		// Since the native PHP type for this column is integer,
-		// we will cast the input value to an int (if it is not).
-		if ($v !== null && !is_int($v) && is_numeric($v)) {
-			$v = (int) $v;
-		}
-
 		if ($this->quantity !== $v || $v === 1) {
 			$this->quantity = $v;
 			$this->modifiedColumns[] = KataoSupplierInvoiceProductPeer::QUANTITY;
@@ -583,7 +577,7 @@ abstract class BaseKataoSupplierInvoiceProduct extends BaseObject  implements Pe
 
 			$this->product_tva_rate = $rs->getFloat($startcol + 7);
 
-			$this->quantity = $rs->getInt($startcol + 8);
+			$this->quantity = $rs->getFloat($startcol + 8);
 
 			$this->product_price_total = $rs->getFloat($startcol + 9);