@@ -72,14 +72,13 @@ class ProductFamilyController extends AdminController | |||
)); | |||
$formBuilder->add('behaviorAddToCart', ChoiceType::class, array( | |||
'empty_data' => 'by-product-family', | |||
'data' => $entity->getBehaviorAddToCart() ? $entity->getBehaviorAddToCart() : 'simple', | |||
'choices' => array( | |||
'field.ProductFamily.behaviorAddToCartOptions.simple' => 'simple', | |||
'field.ProductFamily.behaviorAddToCartOptions.multiple' => 'multiple' | |||
), | |||
'translation_domain' => 'lcshop', | |||
'multiple' => false, | |||
'required'=>false, | |||
'expanded' => true | |||
)); | |||
@@ -94,7 +93,6 @@ class ProductFamilyController extends AdminController | |||
'expanded' => true | |||
)); | |||
dump(floatval( $this->merchantUtils->getMerchantConfig('multiplying-factor'))); | |||
$formBuilder->add('multiplyingFactor', NumberType::class, array( | |||
'mapped'=> false, | |||
'data'=> floatval($this->merchantUtils->getMerchantConfig('multiplying-factor')), | |||
@@ -153,26 +151,19 @@ class ProductFamilyController extends AdminController | |||
{ | |||
$productFamilyRequest = $this->request->request->get('productfamily'); | |||
if(isset($productFamilyRequest['taxRate'])) { | |||
$taxRateId = intval($productFamilyRequest['taxRate']); | |||
if ($taxRateId > 0) { | |||
$repo = $this->em->getRepository(TaxRateInterface::class); | |||
$entity->setTaxRate($repo->find($taxRateId)); | |||
} | |||
} | |||
$unitId = intval($productFamilyRequest['unit']); | |||
/*$unitId = intval($productFamilyRequest['unit']); | |||
if ($unitId > 0) { | |||
$repo = $this->em->getRepository(UnitInterface::class); | |||
$entity->setUnit($repo->find($unitId)); | |||
} | |||
}*/ | |||
//$reductionCatalogInfo = $productFamilyRequest['reductionCatalog']; | |||
$this->processCategories($entity); | |||
$this->processProducts($entity); | |||
$this->processPrice($entity); | |||
/* dump($reductionCatalog); | |||
dump($productFamilyRequest);*/ | |||
@@ -188,25 +179,29 @@ class ProductFamilyController extends AdminController | |||
parent::persistEntity($entity); | |||
} | |||
protected function processPrice($entity){ | |||
if($entity->getBehaviorPrice()=='by-piece'){ | |||
$entity->setPriceByRefUnit(null); | |||
$entity->setBuyingPriceByRefUnit(null); | |||
}else if($entity->getBehaviorPrice()=='by-reference-unit') { | |||
$entity->setPrice(null); | |||
$entity->setBuyingPrice(null); | |||
} | |||
} | |||
protected function processProducts($entity) | |||
{ | |||
$repo = $this->em->getRepository(UnitInterface::class); | |||
//si il existe un et un seul produit pour ce product family n'ajoute rien supprime rien | |||
if (count($entity->getProducts()) == 0) { | |||
$product = new Product(); | |||
$product->setProductFamily($entity); | |||
$this->em->persist($product); | |||
$entity->addProduct($product); | |||
} else { | |||
foreach ($entity->getProducts() as $i=>$product) { | |||
$product->setProductFamily($entity); | |||
$this->em->persist($product); | |||
$entity->addProduct($product); | |||
// die('ncici'); | |||
} | |||
} | |||
@@ -266,6 +261,7 @@ class ProductFamilyController extends AdminController | |||
$sortableProductsField[$product->getPosition()] = $k; | |||
} | |||
ksort($sortableProductsField); | |||
$editForm->handleRequest($this->request); | |||
if ($editForm->isSubmitted() && $editForm->isValid()) { | |||
@@ -120,7 +120,7 @@ trait PriceTrait | |||
} | |||
} | |||
public function setPrice(float $price): self | |||
public function setPrice(?float $price): self | |||
{ | |||
$this->price = $price; | |||
@@ -186,7 +186,7 @@ table th .select2-container--default .select2-selection--single{padding:0.3rem 0 | |||
.products-collection-table .btn-empty-field{position: absolute; right: 3px; font-size: 0.7rem; top: 5px; padding: 0px;} | |||
#lc-product-family-edit .products-collection-table {table-layout:fixed;} | |||
#lc-product-family-edit .products-collection-table tr{border-bottom: 1px solid #dee2e6;} | |||
#lc-product-family-edit .products-collection-table th{font-size:13px; border-left: 1px solid #dee2e6; border-top: 1px solid #dee2e6; text-align: center; min-width: } | |||
#lc-product-family-edit .products-collection-table th{font-size:13px; border-left: 1px solid #dee2e6; border-top: 1px solid #dee2e6; text-align: center;} | |||
#lc-product-family-edit .products-collection-table th span {white-space: initial;} | |||
#lc-product-family-edit .products-collection-table th:last-child{border-right: 1px solid #dee2e6;} | |||
#lc-product-family-edit .products-collection-table td{border-left: 1px solid #dee2e6; text-align: center; font-size: 13px;} |
@@ -158,6 +158,8 @@ let mixinPrice = { | |||
} | |||
}, | |||
multiplyingFactorUpdated: function () { | |||
this.multiplyingFactor = formatNumber(this.multiplyingFactor, 3) | |||
if (this.behaviorPriceValue == 'by-piece') { | |||
this.setPriceFromMultiplyingFactor(); | |||
this.setPriceWithTax(); | |||
@@ -215,11 +217,11 @@ let mixinPrice = { | |||
setMultiplyingFactor: function () { | |||
if (this.behaviorPriceValue == 'by-piece') { | |||
if (this.priceWithTax || this.buyingPrice) { | |||
this.multiplyingFactor = parseFloat(this.priceWithTaxValue / this.buyingPriceValue).toFixed(4); | |||
this.multiplyingFactor = parseFloat(this.priceWithTaxValue / this.buyingPriceValue).toFixed(3); | |||
} | |||
} else if (this.behaviorPriceValue == 'by-reference-unit') { | |||
if (this.priceByRefUnitWithTax || this.buyingPriceByRefUnit) { | |||
this.multiplyingFactor = parseFloat(this.priceByRefUnitWithTaxValue / this.buyingPriceByRefUnitValue).toFixed(4); | |||
this.multiplyingFactor = parseFloat(this.priceByRefUnitWithTaxValue / this.buyingPriceByRefUnitValue).toFixed(3); | |||
} | |||
} | |||
}, |
@@ -56,13 +56,18 @@ Vue.component('product-unit-price', { | |||
}, | |||
watch: { | |||
taxRate: function () { | |||
//this.setBuyingPriceWithTax(); | |||
//this.setPriceWithTax(); | |||
//this.setMultiplyingFactor(); | |||
//this.setPriceByUnitRefWithTax(); | |||
this.setBuyingPriceWithTax(); | |||
this.setBuyingPriceByRefUnitWithTax(); | |||
this.setPriceWithTax(); | |||
this.setPriceByRefUnitWithTax(); | |||
this.setMultiplyingFactor(); | |||
}, | |||
supplierTaxRate: function () { | |||
//this.setBuyingPriceWithTax(); | |||
this.setBuyingPriceWithTax(); | |||
this.setBuyingPriceByRefUnitWithTax(); | |||
}, | |||
differentSupplierTaxRate:function(){ | |||
this.supplierTaxRate = null; | |||
}, | |||
activeProducts:function () { | |||
this.$parent.updateActiveProducts(); |
@@ -150,13 +150,13 @@ | |||
${productFamily.quantity} | |||
</th> | |||
<th colspan="2" class="quantity"> | |||
${productFamily.unit} | |||
${productFamily.unitWording} | |||
</th> | |||
<th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="buyingPriceByRefUnit"> | |||
${productFamily.buyingPriceByUnitRef} | |||
${productFamily.buyingPriceByRefUnit} | |||
</th> | |||
<th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="priceByRefUnit"> | |||
${productFamily.buyingPriceByUnitRefWithTax} | |||
${productFamily.buyingPriceByRefUnitWithTax} | |||
</th> | |||
<th colspan="2" class="price" v-show="getBehaviorPrice() =='by-piece'"> | |||
@@ -171,10 +171,10 @@ | |||
<th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class=""> | |||
${productFamily.priceByUnitRef} | |||
${productFamily.priceByRefUnit} | |||
</th> | |||
<th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="price"> | |||
${productFamily.priceByUnitRefWithTax} | |||
${productFamily.priceByRefUnitWithTax} | |||
</th> | |||
<th colspan="2" class="price" v-show="getBehaviorPrice() =='by-piece'"> |