@@ -335,11 +335,12 @@ class DocumentController extends BackendController | |||
return [ | |||
'return' => 'success', | |||
'tax_rate_producer' => GlobalParam::getCurrentProducer()->taxRate->value, | |||
'document' => array_merge($document->getAttributes(), [ | |||
'html_label' => $document->getHtmlLabel(), | |||
'class' => $document->getClass() | |||
]), | |||
'idUser' => $document->user->id, | |||
'id_user' => $document->user->id, | |||
'products' => ArrayHelper::map($productsArray, 'id', function ($product) { | |||
return array_merge($product->getAttributes(), [ | |||
'price_with_tax' => $product->price_with_tax, | |||
@@ -396,8 +397,7 @@ class DocumentController extends BackendController | |||
$productOrder->price = (float)$price; | |||
$productOrder->unit = $product->unit; | |||
$productOrder->step = $product->step; | |||
$productOrder->id_tax_rate = $productOrder->id_tax_rate ? | |||
$product->taxRate->id : GlobalParam::getCurrentProducer()->taxRate->id; | |||
$productOrder->id_tax_rate = $product->taxRate->id ; | |||
$productOrder->save(); | |||
return [ |
@@ -106,7 +106,8 @@ use common\models\Producer; | |||
<tr> | |||
<?php if($action == 'create'): ?><th></th><?php endif; ?> | |||
<th>Libellé</th> | |||
<th>Montant (TTC)</th> | |||
<th v-if="taxRateProducer != 0">Montant (TTC)</th> | |||
<th v-else>Montant</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
@@ -146,7 +147,7 @@ use common\models\Producer; | |||
<div id="" class="info-box"> | |||
<span class="info-box-icon bg-yellow"><i class="fa fa-euro"></i></span> | |||
<div class="info-box-content"> | |||
<span class="info-box-text">Total (TTC)</span> | |||
<span class="info-box-text">Total<span v-if="taxRateProducer != 0"> (TTC)</span></span> | |||
<span class="info-box-number">{{ formatPrice(total_with_tax) }}</span> | |||
</div> | |||
</div> | |||
@@ -191,7 +192,7 @@ use common\models\Producer; | |||
<input type="text" class="form-control input-price" | |||
v-model="productAddPrice" @change="formatProductAddPrice"/> | |||
<span class="input-group-addon"><span | |||
class="glyphicon glyphicon-euro"></span> TTC</span> | |||
class="glyphicon glyphicon-euro"></span> <span v-if="taxRateProducer != 0">TTC</span></span> | |||
</div> | |||
</div> | |||
<div class="col-md-3"> | |||
@@ -217,7 +218,7 @@ use common\models\Producer; | |||
<input type="text" class="form-control input-price" readonly | |||
:value="formatPrice(productAddPrice * productAddQuantity)"/> | |||
<span class="input-group-addon"><span | |||
class="glyphicon glyphicon-euro"></span> TTC</span> | |||
class="glyphicon glyphicon-euro"></span> <span v-if="taxRateProducer != 0">TTC</span></span> | |||
</div> | |||
<button class="btn btn-primary" value="Ajouter" | |||
@click="submitProductAdd">Ajouter | |||
@@ -240,8 +241,9 @@ use common\models\Producer; | |||
<th>Nom</th> | |||
<th>Prix (unité)</th> | |||
<th>Quantité</th> | |||
<th>TVA</th> | |||
<th>Total TTC</th> | |||
<th v-if="taxRateProducer != 0">TVA</th> | |||
<th v-if="taxRateProducer != 0">Total TTC</th> | |||
<th v-else>Total</th> | |||
<th>Supprimer</th> | |||
</tr> | |||
</thead> | |||
@@ -258,7 +260,7 @@ use common\models\Producer; | |||
</td> | |||
<td class="col-md-2">{{ formatPrice(productOrder.price) }}</td> | |||
<td class="col-md-2">{{ productOrder.quantity }}</td> | |||
<td class="col-md-1"> | |||
<td class="col-md-1" v-if="taxRateProducer != 0"> | |||
{{ productsArray[productOrder.id_product].tax_rate * 100 }} % | |||
</td> | |||
<td class="col-md-2"> | |||
@@ -271,21 +273,31 @@ use common\models\Producer; | |||
</td> | |||
</tr> | |||
</template> | |||
<tr> | |||
<td colspan="4"><strong>Total HT</strong></td> | |||
<td><strong>{{ formatPrice(total) }} HT</strong></td> | |||
<td></td> | |||
</tr> | |||
<tr> | |||
<td colspan="4"><strong>Montant TVA</strong></td> | |||
<td><strong>{{ formatPrice(total_with_tax - total) }}</strong></td> | |||
<td></td> | |||
</tr> | |||
<tr> | |||
<td colspan="4"><strong>Total TTC</strong></td> | |||
<td><strong>{{ formatPrice(total_with_tax) }} TTC</strong></td> | |||
<td></td> | |||
</tr> | |||
<template v-if="taxRateProducer != 0"> | |||
<tr> | |||
<td colspan="4"><strong>Total HT</strong></td> | |||
<td><strong>{{ formatPrice(total) }} HT</strong></td> | |||
<td></td> | |||
</tr> | |||
<tr> | |||
<td colspan="4"><strong>Montant TVA</strong></td> | |||
<td><strong>{{ formatPrice(total_with_tax - total) }}</strong></td> | |||
<td></td> | |||
</tr> | |||
<tr> | |||
<td colspan="4"><strong>Total TTC</strong></td> | |||
<td><strong>{{ formatPrice(total_with_tax) }} TTC</strong></td> | |||
<td></td> | |||
</tr> | |||
</template> | |||
<template v-else> | |||
<tr> | |||
<td colspan="3"><strong>Total</strong></td> | |||
<td><strong>{{ formatPrice(total) }}</strong></td> | |||
<td></td> | |||
</tr> | |||
</template> | |||
</tbody> | |||
</table> | |||
<div v-else class="alert alert-info"> |
@@ -38,11 +38,20 @@ | |||
<thead> | |||
<tr> | |||
<th class="align-left">Produit</th> | |||
<th>Prix unitaire HT</th> | |||
<?php if(GlobalParam::getCurrentProducer()->taxRate->value == 0): ?> | |||
<th>Prix unitaire</th> | |||
<?php else: ?> | |||
<th>Prix unitaire HT</th> | |||
<?php endif; ?> | |||
<th>Quantité</th> | |||
<th>Unité</th> | |||
<th>TVA</th> | |||
<th>Prix HT</th> | |||
<?php if(GlobalParam::getCurrentProducer()->taxRate->value == 0): ?> | |||
<th>Prix</th> | |||
<?php else: ?> | |||
<th>TVA</th> | |||
<th>Prix HT</th> | |||
<?php endif; ?> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
@@ -53,11 +62,15 @@ | |||
<td class="align-center"><?= Price::format($productOrder->getPrice()) ?></td> | |||
<td class="align-center"><?= $productOrder->quantity ?></td> | |||
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td> | |||
<td class="align-center"><?= $productOrder->product->taxRate->value * 100 ?> %</td> | |||
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?> | |||
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td> | |||
<?php endif; ?> | |||
<td class="align-center"><?= Price::format($productOrder->getPrice() * $productOrder->quantity) ?></td> | |||
</tr> | |||
<?php endforeach; ?> | |||
<?php endforeach; ?> | |||
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?> | |||
<tr> | |||
<td class="align-right" colspan="5"><strong>Total HT</strong></td> | |||
<td class="align-center"><?= Price::format($document->getAmount()) ?></td> | |||
@@ -70,6 +83,15 @@ | |||
<td class="align-right" colspan="5"><strong>Total TTC</strong></td> | |||
<td class="align-center"><?= Price::format($document->getAmountWithTax()) ?></td> | |||
</tr> | |||
<?php else: ?> | |||
<tr> | |||
<td class="align-right" colspan="4"> | |||
<strong>Total</strong><br /> | |||
TVA non applicable | |||
</td> | |||
<td class="align-center"><?= Price::format($document->getAmount()) ?></td> | |||
</tr> | |||
<?php endif; ?> | |||
</tbody> | |||
</table> | |||
<?php else : ?> |
@@ -86,7 +86,9 @@ use common\helpers\GlobalParam; | |||
?> | |||
<?= $form->field($model, 'id_tax_rate')->dropDownList($taxRateNamesArray, ['options' => $taxRateValuesArrayFormatted])->label('Taxe'); ?> | |||
<?php if($taxRateDefault->value != 0): ?> | |||
<?= $form->field($model, 'id_tax_rate')->dropDownList($taxRateNamesArray, ['options' => $taxRateValuesArrayFormatted])->label('Taxe'); ?> | |||
<?php endif; ?> | |||
<?= $form->field($model, 'price', [ | |||
'template' => ' |
@@ -84,7 +84,9 @@ function opendistrib_products() { | |||
function opendistrib_products_event_price_with_tax() { | |||
taxRateSelected = $('#product-id_tax_rate').find('option:selected').data('tax-rate-value'); | |||
if(typeof taxRateSelected == 'undefined') { | |||
taxRateSelected = 0 ; | |||
} | |||
$('#product-price-with-tax').val(getPriceWithTax($('#product-price').val(), taxRateSelected)); | |||
//formattage des prix | |||
$('#product-price').val(parseFloat($('#product-price').val()).toFixed(2)); |
@@ -38,6 +38,7 @@ termes. | |||
var app = new Vue({ | |||
el: '#app-document-form', | |||
data: { | |||
taxRateProducer: null, | |||
document: [], | |||
deliveryNotes: [], | |||
idDocument: 0, | |||
@@ -67,7 +68,8 @@ var app = new Vue({ | |||
.then(function(response) { | |||
if(response.data.return == 'success') { | |||
app.document = response.data.document ; | |||
app.idUser = response.data.idUser ; | |||
app.taxRateProducer = response.data.tax_rate_producer ; | |||
app.idUser = response.data.id_user ; | |||
app.productsArray = response.data.products ; | |||
app.ordersArray = response.data.orders ; | |||
app.total = response.data.total ; |
@@ -334,5 +334,15 @@ class Product extends ActiveRecordCommon | |||
return Price::getPriceWithTax($this->price, $this->taxRate->value); | |||
} | |||
public function getTheTaxRate() | |||
{ | |||
if($this->id_tax_rate) { | |||
return $this->id_tax_rate ; | |||
} | |||
else { | |||
return GlobalParam::getCurrentProducer()->taxRate->id; | |||
} | |||
} | |||
} |