Procházet zdrojové kódy

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

feature/export_comptable
Fab před 4 roky
rodič
revize
0e78232fec
6 změnil soubory, kde provedl 36 přidání a 33 odebrání
  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 Zobrazit soubor

@@ -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()) {


+ 1
- 1
ShopBundle/Model/PriceTrait.php Zobrazit soubor

@@ -120,7 +120,7 @@ trait PriceTrait
}
}

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


+ 1
- 1
ShopBundle/Resources/public/css/backend/custom.css Zobrazit soubor

@@ -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;}

+ 4
- 2
ShopBundle/Resources/public/js/backend/script/default/vuejs-mixins.js Zobrazit soubor

@@ -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);
}
}
},

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

@@ -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();

+ 5
- 5
ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig Zobrazit soubor

@@ -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'">

Načítá se…
Zrušit
Uložit