Browse Source

Form produits intégration prix par unité de référence

feature/export_comptable
Fab 4 years ago
parent
commit
0e78232fec
6 changed files with 36 additions and 33 deletions
  1. +15
    -19
      ShopBundle/Controller/Admin/ProductFamilyController.php
  2. +1
    -1
      ShopBundle/Model/PriceTrait.php
  3. +1
    -1
      ShopBundle/Resources/public/css/backend/custom.css
  4. +4
    -2
      ShopBundle/Resources/public/js/backend/script/default/vuejs-mixins.js
  5. +10
    -5
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js
  6. +5
    -5
      ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig

+ 15
- 19
ShopBundle/Controller/Admin/ProductFamilyController.php View File

)); ));


$formBuilder->add('behaviorAddToCart', ChoiceType::class, array( $formBuilder->add('behaviorAddToCart', ChoiceType::class, array(
'empty_data' => 'by-product-family',
'data' => $entity->getBehaviorAddToCart() ? $entity->getBehaviorAddToCart() : 'simple',
'choices' => array( 'choices' => array(
'field.ProductFamily.behaviorAddToCartOptions.simple' => 'simple', 'field.ProductFamily.behaviorAddToCartOptions.simple' => 'simple',
'field.ProductFamily.behaviorAddToCartOptions.multiple' => 'multiple' 'field.ProductFamily.behaviorAddToCartOptions.multiple' => 'multiple'
), ),
'translation_domain' => 'lcshop', 'translation_domain' => 'lcshop',
'multiple' => false, 'multiple' => false,
'required'=>false,
'expanded' => true 'expanded' => true
)); ));


'expanded' => true 'expanded' => true
)); ));


dump(floatval( $this->merchantUtils->getMerchantConfig('multiplying-factor')));
$formBuilder->add('multiplyingFactor', NumberType::class, array( $formBuilder->add('multiplyingFactor', NumberType::class, array(
'mapped'=> false, 'mapped'=> false,
'data'=> floatval($this->merchantUtils->getMerchantConfig('multiplying-factor')), 'data'=> floatval($this->merchantUtils->getMerchantConfig('multiplying-factor')),
{ {
$productFamilyRequest = $this->request->request->get('productfamily'); $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) { if ($unitId > 0) {
$repo = $this->em->getRepository(UnitInterface::class); $repo = $this->em->getRepository(UnitInterface::class);
$entity->setUnit($repo->find($unitId)); $entity->setUnit($repo->find($unitId));
}
}*/


//$reductionCatalogInfo = $productFamilyRequest['reductionCatalog']; //$reductionCatalogInfo = $productFamilyRequest['reductionCatalog'];





$this->processCategories($entity); $this->processCategories($entity);
$this->processProducts($entity); $this->processProducts($entity);
$this->processPrice($entity);
/* dump($reductionCatalog); /* dump($reductionCatalog);
dump($productFamilyRequest);*/ dump($productFamilyRequest);*/


parent::persistEntity($entity); 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) 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 //si il existe un et un seul produit pour ce product family n'ajoute rien supprime rien
if (count($entity->getProducts()) == 0) { if (count($entity->getProducts()) == 0) {
$product = new Product(); $product = new Product();
$product->setProductFamily($entity); $product->setProductFamily($entity);
$this->em->persist($product); $this->em->persist($product);

$entity->addProduct($product); $entity->addProduct($product);
} else { } else {

foreach ($entity->getProducts() as $i=>$product) { foreach ($entity->getProducts() as $i=>$product) {

$product->setProductFamily($entity); $product->setProductFamily($entity);
$this->em->persist($product); $this->em->persist($product);
$entity->addProduct($product); $entity->addProduct($product);

// die('ncici');
} }
} }


$sortableProductsField[$product->getPosition()] = $k; $sortableProductsField[$product->getPosition()] = $k;
} }
ksort($sortableProductsField); ksort($sortableProductsField);

$editForm->handleRequest($this->request); $editForm->handleRequest($this->request);
if ($editForm->isSubmitted() && $editForm->isValid()) { if ($editForm->isSubmitted() && $editForm->isValid()) {



+ 1
- 1
ShopBundle/Model/PriceTrait.php View File

} }
} }


public function setPrice(float $price): self
public function setPrice(?float $price): self
{ {
$this->price = $price; $this->price = $price;



+ 1
- 1
ShopBundle/Resources/public/css/backend/custom.css View File

.products-collection-table .btn-empty-field{position: absolute; right: 3px; font-size: 0.7rem; top: 5px; padding: 0px;} .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 {table-layout:fixed;}
#lc-product-family-edit .products-collection-table tr{border-bottom: 1px solid #dee2e6;} #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 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 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;} #lc-product-family-edit .products-collection-table td{border-left: 1px solid #dee2e6; text-align: center; font-size: 13px;}

+ 4
- 2
ShopBundle/Resources/public/js/backend/script/default/vuejs-mixins.js View File

} }
}, },
multiplyingFactorUpdated: function () { multiplyingFactorUpdated: function () {
this.multiplyingFactor = formatNumber(this.multiplyingFactor, 3)

if (this.behaviorPriceValue == 'by-piece') { if (this.behaviorPriceValue == 'by-piece') {
this.setPriceFromMultiplyingFactor(); this.setPriceFromMultiplyingFactor();
this.setPriceWithTax(); this.setPriceWithTax();
setMultiplyingFactor: function () { setMultiplyingFactor: function () {
if (this.behaviorPriceValue == 'by-piece') { if (this.behaviorPriceValue == 'by-piece') {
if (this.priceWithTax || this.buyingPrice) { 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') { } else if (this.behaviorPriceValue == 'by-reference-unit') {
if (this.priceByRefUnitWithTax || this.buyingPriceByRefUnit) { if (this.priceByRefUnitWithTax || this.buyingPriceByRefUnit) {
this.multiplyingFactor = parseFloat(this.priceByRefUnitWithTaxValue / this.buyingPriceByRefUnitValue).toFixed(4);
this.multiplyingFactor = parseFloat(this.priceByRefUnitWithTaxValue / this.buyingPriceByRefUnitValue).toFixed(3);
} }
} }
}, },

+ 10
- 5
ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js View File

}, },
watch: { watch: {
taxRate: function () { taxRate: function () {
//this.setBuyingPriceWithTax();
//this.setPriceWithTax();
//this.setMultiplyingFactor();
//this.setPriceByUnitRefWithTax();
this.setBuyingPriceWithTax();
this.setBuyingPriceByRefUnitWithTax();
this.setPriceWithTax();
this.setPriceByRefUnitWithTax();
this.setMultiplyingFactor();
}, },
supplierTaxRate: function () { supplierTaxRate: function () {
//this.setBuyingPriceWithTax();
this.setBuyingPriceWithTax();
this.setBuyingPriceByRefUnitWithTax();
},
differentSupplierTaxRate:function(){
this.supplierTaxRate = null;
}, },
activeProducts:function () { activeProducts:function () {
this.$parent.updateActiveProducts(); this.$parent.updateActiveProducts();

+ 5
- 5
ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig View File

${productFamily.quantity} ${productFamily.quantity}
</th> </th>
<th colspan="2" class="quantity"> <th colspan="2" class="quantity">
${productFamily.unit}
${productFamily.unitWording}
</th> </th>
<th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="buyingPriceByRefUnit"> <th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="buyingPriceByRefUnit">
${productFamily.buyingPriceByUnitRef}
${productFamily.buyingPriceByRefUnit}
</th> </th>
<th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="priceByRefUnit"> <th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="priceByRefUnit">
${productFamily.buyingPriceByUnitRefWithTax}
${productFamily.buyingPriceByRefUnitWithTax}
</th> </th>


<th colspan="2" class="price" v-show="getBehaviorPrice() =='by-piece'"> <th colspan="2" class="price" v-show="getBehaviorPrice() =='by-piece'">




<th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class=""> <th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="">
${productFamily.priceByUnitRef}
${productFamily.priceByRefUnit}
</th> </th>
<th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="price"> <th v-show="getBehaviorPrice() == 'by-reference-unit'" colspan="2" class="price">
${productFamily.priceByUnitRefWithTax}
${productFamily.priceByRefUnitWithTax}
</th> </th>


<th colspan="2" class="price" v-show="getBehaviorPrice() =='by-piece'"> <th colspan="2" class="price" v-show="getBehaviorPrice() =='by-piece'">

Loading…
Cancel
Save