$reductionCatalogRepo = $this->em->getRepository(ReductionCatalogInterface::class); | $reductionCatalogRepo = $this->em->getRepository(ReductionCatalogInterface::class); | ||||
$reductionCatalogClass = $this->em->getClassMetadata(ReductionCatalogInterface::class); | $reductionCatalogClass = $this->em->getClassMetadata(ReductionCatalogInterface::class); | ||||
$reductionCatalog = $reductionCatalogRepo->findOneByProductFamily($entity); | |||||
$reductionCatalog = $reductionCatalogRepo->findOneBy(array('status'=>false, 'productFamily'=>$entity)); | |||||
if($reductionCatalog == null)$reductionCatalog = new $reductionCatalogClass->name; | if($reductionCatalog == null)$reductionCatalog = new $reductionCatalogClass->name; | ||||
$formBuilder->add('reductionCatalog', ReductionCatalogType::class,array( | $formBuilder->add('reductionCatalog', ReductionCatalogType::class,array( | ||||
'mapped'=>false, | 'mapped'=>false, |
'required' => false, | 'required' => false, | ||||
)); | )); | ||||
$builder->add('propertyExpirationDate', DateType::class, array( | |||||
'required' => false, | |||||
'widget'=> 'single_text' | |||||
$builder->add('propertyExpirationDate', TextType::class, array( | |||||
'required' => false | |||||
)); | )); | ||||
$builder->add('position', HiddenType::class); | $builder->add('position', HiddenType::class); |
return $this; | return $this; | ||||
} | } | ||||
public function getPropertyExpirationDate(): ?\DateTimeInterface | |||||
public function getPropertyExpirationDate(): ?string | |||||
{ | { | ||||
return $this->propertyExpirationDate; | return $this->propertyExpirationDate; | ||||
} | } | ||||
public function setPropertyExpirationDate(?\DateTimeInterface $propertyExpirationDate): self | |||||
public function setPropertyExpirationDate(?string $propertyExpirationDate): self | |||||
{ | { | ||||
$this->propertyExpirationDate = $propertyExpirationDate; | $this->propertyExpirationDate = $propertyExpirationDate; | ||||
}, | }, | ||||
computed: { | computed: { | ||||
taxRateValue: function () { | |||||
if (this.taxRate) { | |||||
return this.taxRatesList[this.taxRate]['value']; | |||||
} else if (this.taxRate == null || this.taxRate == "undefined") { | |||||
return this.taxRatesList['default']['value']; | |||||
} else { | |||||
log('ERREUR : pas de taxRate') | |||||
/*priceWithTaxAndReduction:function () { | |||||
if(this.productFamily.reductionActive){ | |||||
log(this.productFamily.value); | |||||
} | } | ||||
}, | |||||
supplierTaxRateValue: function () { | |||||
if (this.supplierTaxRate) { | |||||
return this.taxRatesList[this.supplierTaxRate]['value']; | |||||
} else if (this.supplierTaxRate == null || this.supplierTaxRate == "undefined") { | |||||
return this.taxRateValue; | |||||
} else { | |||||
log('ERREUR : pas de supplier taxRate') | |||||
} | |||||
}, | |||||
}*/ | |||||
}, | }, | ||||
mounted: function () { | mounted: function () { | ||||
}, | }, | ||||
methods: { | methods: { | ||||
init: function () { | init: function () { | ||||
priceWithTaxUpdated: function () { | priceWithTaxUpdated: function () { | ||||
this.priceWithTax = formatNumber(this.priceWithTax, 2); | this.priceWithTax = formatNumber(this.priceWithTax, 2); | ||||
log(this.priceWithTax); | |||||
this.setPriceFromPriceWithTax(); | this.setPriceFromPriceWithTax(); | ||||
this.priceUpdated(); | this.priceUpdated(); | ||||
}, | }, | ||||
let mixinReduction = { | let mixinReduction = { | ||||
data() { | data() { | ||||
log(window.mixinReductionValues); | |||||
return Object.assign({ | return Object.assign({ | ||||
reductionActive: true, | reductionActive: true, | ||||
reductionUnit:null, | |||||
reductionBehaviorTaxRate:null, | |||||
reductionValue:null, | |||||
reductionPermanent: true, | reductionPermanent: true, | ||||
reductionUsersActive: false, | reductionUsersActive: false, | ||||
reductionGroupUsersActive: false, | reductionGroupUsersActive: false, |
}, | }, | ||||
behaviorPriceValue:function(){ | behaviorPriceValue:function(){ | ||||
return this.behaviorPrice; | return this.behaviorPrice; | ||||
} | |||||
}, | |||||
taxRateValue: function () { | |||||
if (this.taxRate) { | |||||
return this.taxRatesList[this.taxRate]['value']; | |||||
} else if (this.taxRate == null || this.taxRate == "undefined") { | |||||
return this.taxRatesList['default']['value']; | |||||
} else { | |||||
log('ERREUR : pas de taxRate') | |||||
} | |||||
}, | |||||
supplierTaxRateValue: function () { | |||||
if (this.supplierTaxRate) { | |||||
return this.taxRatesList[this.supplierTaxRate]['value']; | |||||
} else if (this.supplierTaxRate == null || this.supplierTaxRate == "undefined") { | |||||
return this.taxRateValue; | |||||
} else { | |||||
log('ERREUR : pas de supplier taxRate') | |||||
} | |||||
}, | |||||
}, | }, | ||||
mounted: function () { | mounted: function () { | ||||
this.setPriceWithTax(); | this.setPriceWithTax(); | ||||
this.setPriceByRefUnitWithTax(); | this.setPriceByRefUnitWithTax(); | ||||
this.setMultiplyingFactor(); | this.setMultiplyingFactor(); | ||||
this.$parent.updateChild(); | |||||
}, | }, | ||||
supplierTaxRate: function () { | supplierTaxRate: function () { | ||||
this.setBuyingPriceWithTax(); | this.setBuyingPriceWithTax(); | ||||
mixins: [mixinUnit, mixinPrice, mixinTemplate], | mixins: [mixinUnit, mixinPrice, mixinTemplate], | ||||
props: ['template', 'keyForm', 'productFamily'], | props: ['template', 'keyForm', 'productFamily'], | ||||
computed: { | computed: { | ||||
taxRate: function () { | |||||
return this.productFamily.taxRate; | |||||
taxRateValue: function () { | |||||
return this.productFamily.taxRateValue; | |||||
}, | }, | ||||
supplierTaxRate: function () { | |||||
return this.productFamily.supplierTaxRate; | |||||
supplierTaxRateValue: function () { | |||||
return this.productFamily.supplierTaxRateValue; | |||||
}, | }, | ||||
buyingPriceValue: function () { | buyingPriceValue: function () { | ||||
if (this.buyingPrice) return this.buyingPrice; | if (this.buyingPrice) return this.buyingPrice; | ||||
if (this.unit) return this.unit; | if (this.unit) return this.unit; | ||||
else return this.productFamily.unit; | else return this.productFamily.unit; | ||||
}, | }, | ||||
propertyExpirationDateFormated: function () { | |||||
if (this.propertyExpirationDate) return getDateFormatted(this.propertyExpirationDate, '-') | |||||
else return getDateFormatted(this.productFamily.propertyExpirationDate, '-') | |||||
propertyExpirationDateValue: function () { | |||||
if (this.propertyExpirationDate) return this.propertyExpirationDate; | |||||
else return this.productFamily.propertyExpirationDate; | |||||
}, | }, | ||||
behaviorPriceValue:function(){ | behaviorPriceValue:function(){ | ||||
return this.productFamily.behaviorPrice; | return this.productFamily.behaviorPrice; | ||||
'buyingPriceByRefUnitWithTax': this.$refs.productUnitPrice.buyingPriceByRefUnitWithTax, | 'buyingPriceByRefUnitWithTax': this.$refs.productUnitPrice.buyingPriceByRefUnitWithTax, | ||||
'priceByRefUnit': this.$refs.productUnitPrice.priceByRefUnit, | 'priceByRefUnit': this.$refs.productUnitPrice.priceByRefUnit, | ||||
'priceByRefUnitWithTax': this.$refs.productUnitPrice.priceByRefUnitWithTax, | 'priceByRefUnitWithTax': this.$refs.productUnitPrice.priceByRefUnitWithTax, | ||||
'taxRate': this.$refs.productUnitPrice.taxRate, | |||||
'taxRateValue': this.$refs.productUnitPrice.taxRateValue, | |||||
'supplierTaxRateValue': this.$refs.productUnitPrice.supplierTaxRateValue, | |||||
/*'taxRate': this.$refs.productUnitPrice.taxRate, | |||||
'supplierTaxRate': this.$refs.productUnitPrice.supplierTaxRate, | 'supplierTaxRate': this.$refs.productUnitPrice.supplierTaxRate, | ||||
*/ | |||||
'multiplyingFactor': this.$refs.productUnitPrice.multiplyingFactor, | 'multiplyingFactor': this.$refs.productUnitPrice.multiplyingFactor, | ||||
'taxRateValue': this.$refs.productUnitPrice.taxRateValue, | |||||
'propertyExpirationDate': this.propertyExpirationDate, | 'propertyExpirationDate': this.propertyExpirationDate, | ||||
'behaviorExpirationDate': this.behaviorExpirationDate | |||||
'behaviorExpirationDate': this.behaviorExpirationDate, | |||||
'reductionActive': this.reductionActive, | |||||
'reductionUnit': this.reductionUnit, | |||||
'reductionValue': this.reductionValue, | |||||
'reductionBehaviorTaxRate': this.reductionBehaviorTaxRate | |||||
}; | }; | ||||
}else{ | }else{ | ||||
return { | return { |
</div> | </div> | ||||
#} | #} | ||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.behaviorTaxRate, {"attr" : {":required": "reductionActive"}}) }} | |||||
{{ form_row(form.behaviorTaxRate, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionBehaviorTaxRate'}}) }} | |||||
</div> | </div> | ||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.unit, {"attr" : {":required": "reductionActive"}}) }} | |||||
{{ form_row(form.unit, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionUnit'}}) }} | |||||
</div> | </div> | ||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.value, {"attr" : {":required": "reductionActive"}}) }} | |||||
{{ form_row(form.value, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionValue'}}) }} | |||||
</div> | </div> | ||||
window.mixinReductionValues = { | window.mixinReductionValues = { | ||||
{% if formValues.status == false and isProductFamilyForm %}reductionActive: false,{% endif %} | {% if formValues.status == false and isProductFamilyForm %}reductionActive: false,{% endif %} | ||||
{% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %} | {% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %} | ||||
{% if formValues.behaviorTaxRate %}reductionBehaviorTaxRate: '{{ formValues.behaviorTaxRate }}',{% endif %} | |||||
{% if formValues.value %}reductionValue: parseFloat({{ formValues.value }}),{% endif %} | |||||
{% if formValues.unit %}reductionUnit: "{{ formValues.unit }}",{% endif %} | |||||
{% if formValues.users is not empty %}reductionUsersActive: true,{% endif %} | {% if formValues.users is not empty %}reductionUsersActive: true,{% endif %} | ||||
{% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %} | {% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %} | ||||
{% if formValues.productFamilies is not empty %}reductionProductFamiliesActive: true,{% endif %} | {% if formValues.productFamilies is not empty %}reductionProductFamiliesActive: true,{% endif %} |
{% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %} | {% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %} | ||||
{% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %} | {% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %} | ||||
{% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %} | {% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %} | ||||
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate|date('d/m/Y') }}",{% endif %} | |||||
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate }}",{% endif %} | |||||
{% if formValues.activeProducts %}activeProducts: "{{ formValues.activeProducts }}",{% endif %} | {% if formValues.activeProducts %}activeProducts: "{{ formValues.activeProducts }}",{% endif %} | ||||
}; | }; |
<td colspan="2" v-show="productFamily.behaviorPrice == 'by-reference-unit'"> | <td colspan="2" v-show="productFamily.behaviorPrice == 'by-reference-unit'"> | ||||
{% verbatim %}{{ finalPriceWithTax }}{% endverbatim %}€ | {% verbatim %}{{ finalPriceWithTax }}{% endverbatim %}€ | ||||
</td> | </td> | ||||
{{ macros.productField(2, product.price, 'price', false, '€', 'v-show="productFamily.behaviorPrice == \'by-piece\'"') }} | {{ macros.productField(2, product.price, 'price', false, '€', 'v-show="productFamily.behaviorPrice == \'by-piece\'"') }} | ||||
{{ macros.productField(2, product.priceWithTax, 'priceWithTax', false, '€', 'v-show="productFamily.behaviorPrice == \'by-piece\'"') }} | {{ macros.productField(2, product.priceWithTax, 'priceWithTax', false, '€', 'v-show="productFamily.behaviorPrice == \'by-piece\'"') }} | ||||
{{ macros.productField(2, product.availableQuantity, 'availableQuantity',false, '', 'v-show="productFamily.behaviorCountStock== \'by-product\'"') }} | {{ macros.productField(2, product.availableQuantity, 'availableQuantity',false, '', 'v-show="productFamily.behaviorCountStock== \'by-product\'"') }} | ||||
{{ macros.productField(2, product.availableQuantityDefault, 'availableQuantityDefault',false, '', 'v-show="productFamily.behaviorCountStock== \'by-product\'"') }} | {{ macros.productField(2, product.availableQuantityDefault, 'availableQuantityDefault',false, '', 'v-show="productFamily.behaviorCountStock== \'by-product\'"') }} | ||||
{{ macros.productField(2, product.propertyExpirationDate, 'propertyExpirationDate','propertyExpirationDateFormated', '', 'v-show="productFamily.behaviorExpirationDate== \'by-product\'"') }} | |||||
{{ macros.productField(2, product.propertyExpirationDate, 'propertyExpirationDate','propertyExpirationDateValue', '', 'v-show="productFamily.behaviorExpirationDate== \'by-product\'"') }} | |||||
<td> | <td> | ||||
<button type="button" class="btn-remove-product btn btn-default" @click="deleteProductForm()"> | <button type="button" class="btn-remove-product btn btn-default" @click="deleteProductForm()"> | ||||
PV TTC | PV TTC | ||||
</th> | </th> | ||||
<th v-show="behaviorCountStock== 'by-product'"> | <th v-show="behaviorCountStock== 'by-product'"> | ||||
Stock | Stock | ||||
</th> | </th> | ||||
Stock par défaut | Stock par défaut | ||||
</th> | </th> | ||||
<th colspan="2" class="" v-show="behaviorExpirationDate== 'by-product'"> | <th colspan="2" class="" v-show="behaviorExpirationDate== 'by-product'"> | ||||
${typeExpirationDate} | |||||
${propertyExpirationDate} | |||||
</th> | </th> | ||||
<th class=""> | <th class=""> | ||||
{% if product.vars.value.priceByRefUnit %}priceByRefUnit: parseFloat({{ product.vars.value.priceByRefUnit }}).toFixed(3),{% endif %} | {% if product.vars.value.priceByRefUnit %}priceByRefUnit: parseFloat({{ product.vars.value.priceByRefUnit }}).toFixed(3),{% endif %} | ||||
{% if product.vars.value.availableQuantity %}availableQuantity: parseInt({{ product.vars.value.availableQuantity }}),{% endif %} | {% if product.vars.value.availableQuantity %}availableQuantity: parseInt({{ product.vars.value.availableQuantity }}),{% endif %} | ||||
{% if product.vars.value.availableQuantityDefault %}availableQuantityDefault: parseInt({{ product.vars.value.availableQuantityDefault }}),{% endif %} | {% if product.vars.value.availableQuantityDefault %}availableQuantityDefault: parseInt({{ product.vars.value.availableQuantityDefault }}),{% endif %} | ||||
{% if product.vars.value.propertyExpirationDate %}propertyExpirationDate: "{{ product.vars.value.propertyExpirationDate }}",{% endif %} | |||||
{#{% if product.vars.value.expirationDate %}expirationDate: "{{ product.vars.value.expirationDate|date('d/m/Y') }}"{% endif %}#} | {#{% if product.vars.value.expirationDate %}expirationDate: "{{ product.vars.value.expirationDate|date('d/m/Y') }}"{% endif %}#} | ||||
}; | }; | ||||
window.formProductTemplate[{{ keyForm }}] = '{{ formMacros.printProductRow(product)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}'; | window.formProductTemplate[{{ keyForm }}] = '{{ formMacros.printProductRow(product)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}'; |