Переглянути джерело

Correctif backoffice

master
Fab 4 роки тому
джерело
коміт
3059250973
18 змінених файлів з 161 додано та 251 видалено
  1. +1
    -1
      ShopBundle/Controller/Backend/OrderController.php
  2. +1
    -1
      ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js
  3. +0
    -37
      ShopBundle/Resources/public/js/backend/script/supplier/vuejs-supplier.js
  4. +1
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +3
    -0
      ShopBundle/Resources/views/backend/default/block/embed_box.twig
  6. +1
    -1
      ShopBundle/Resources/views/backend/default/layout/layout.html.twig
  7. +117
    -79
      ShopBundle/Resources/views/backend/order/macros.html.twig
  8. +2
    -2
      ShopBundle/Resources/views/backend/order/show-cart.html.twig
  9. +2
    -2
      ShopBundle/Resources/views/backend/order/show-order.html.twig
  10. +2
    -3
      ShopBundle/Resources/views/backend/order/show.html.twig
  11. +0
    -13
      ShopBundle/Resources/views/backend/supplier/edit.html.twig
  12. +0
    -42
      ShopBundle/Resources/views/backend/supplier/form.html.twig
  13. +0
    -17
      ShopBundle/Resources/views/backend/supplier/panel_address.html.twig
  14. +0
    -23
      ShopBundle/Resources/views/backend/supplier/panel_general.html.twig
  15. +0
    -14
      ShopBundle/Resources/views/backend/supplier/panel_seo.html.twig
  16. +23
    -13
      ShopBundle/Services/Price/OrderProductPriceUtils.php
  17. +7
    -2
      ShopBundle/Services/Price/PriceUtilsTrait.php
  18. +1
    -1
      ShopBundle/Services/UserUtils.php

+ 1
- 1
ShopBundle/Controller/Backend/OrderController.php Переглянути файл

@@ -418,7 +418,7 @@ class OrderController extends AdminController
],
]);

$this->utils->addFlash('success', 'success.order.removeReductionCredit');
$this->utils->addFlash('success', 'success.order.sendPaymentLink');
} else {
$this->utils->addFlash('error', $formOrderSendPaymentLink->getErrors());
}

+ 1
- 1
ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js Переглянути файл

@@ -8,7 +8,7 @@ Vue.component('order-product', {
computed: {},
mounted: function () {
this.setFields()
log(this);
},
methods: {
setFields: function () {

+ 0
- 37
ShopBundle/Resources/public/js/backend/script/supplier/vuejs-supplier.js Переглянути файл

@@ -1,37 +0,0 @@
// Reference array sent to dynamic staticRenderFns
var staticRenderFns = [];

appOrder = new Vue({
el: '#lc-supplier-edit',
delimiters: ['${', '}'],
data() {
return Object.assign(
{
addressType: null,
currentSection:'general',
sectionsArray: [
{
name: 'general',
nameDisplay: 'Général'
},
{
name: 'address',
nameDisplay: 'Adresse'
},
{
name: 'seo',
nameDisplay: 'SEO'
}
]
}, window.addressValues);
},
mounted: function () {},
methods: {
changeSection: function (section) {
this.currentSection = section.name;
},
},
watch: {}
});



+ 1
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml Переглянути файл

@@ -99,6 +99,7 @@ success:
addReductionCredit: L'avoir a bien été généré
removeReductionCredit: L'avoir a bien été généré
removeReductionCart: La réduction a bien été supprimé
sendPaymentLink: Le lien de paiement a bien été envoyé
credit:
debited: Le compte prépayé a bien été débité
added: Le compte a bien été crédité

+ 3
- 0
ShopBundle/Resources/views/backend/default/block/embed_box.twig Переглянути файл

@@ -4,9 +4,12 @@
<i class="fa fa-{% block icon %}bg-info{% endblock %}"></i></span>

<div class="info-box-content">
{% block infoBox %}
<span class="info-box-text">{% block label %}{% endblock %}</span>
<strong>{% block value %}{% endblock %}</strong>
{% endblock %}
<div class="float-right"> {% block button %}{% endblock %}

</div>
</div>
</div>

+ 1
- 1
ShopBundle/Resources/views/backend/default/layout/layout.html.twig Переглянути файл

@@ -80,7 +80,7 @@
<ul class="navbar-nav ml-auto lc-navbar">


{% set _user_name = easyadmin_read_property(app.user, easyadmin_config('user.name_property_path'))|default('user.unnamed'|trans(domain = 'EasyAdminBundle')) %}
{% set _user_name = app.user.name %}
{% set _logout_path = easyadmin_logout_path() %}
<li class="content-top navbar-custom-menu">
{% block header_custom_menu %}

+ 117
- 79
ShopBundle/Resources/views/backend/order/macros.html.twig Переглянути файл

@@ -11,13 +11,18 @@
<th colspan="2">
<span>Produits / Producteurs</span>
</th>
<th v-if="order.countComplementaryOrderShops > 0">Compléments</th>
<th>
<span v-if="order.countComplementaryOrderShops > 0">Compléments</span>
</th>

<th>
<span>Prix HT à l'unité</span>
<span>Prix achat HT </span>
</th>
<th>
<span>Prix HT</span>
</th>
<th>
<span>Prix TTC à l'unité </span>
<span>Prix TTC </span>
</th>
<th>
<span>Marge </span>
@@ -53,33 +58,36 @@
{% macro productsTemplate(form_order_products=null) %}
<tr :class=" orderProduct.isRedelivery ? 'redelivery order-product-item' : 'order-product-item'">
<td :class="editionMode ? '' : 'hidden'">
<input type="checkbox" :value="orderProduct.id" class="order-product-checkbox" />
<input type="checkbox" :value="orderProduct.id" class="order-product-checkbox"/>
</td>
<td colspan="2">
<a :href="orderProduct.editLink" target="_blank">
<img :src="orderProduct.image" :alt="orderProduct.title" />
{% verbatim %}{{orderProduct.title}}{% endverbatim %}
<span v-show="orderProduct.hasRedelivery">
- <i class="fa fa-undo" data-toggle="tooltip" :title="orderProduct.redeliveryOrderShop" ></i>
<img :src="orderProduct.image" :alt="orderProduct.title"/>
{% verbatim %}{{orderProduct.title}}{% endverbatim %}
<span v-show="orderProduct.hasRedelivery">
- <i class="fa fa-undo" data-toggle="tooltip" :title="orderProduct.redeliveryOrderShop"></i>
</span>

<span v-show="orderProduct.isRedelivery">
- <i class="fa fa-undo" data-toggle="tooltip" title="Ce produit est une relivraison" ></i>
<span v-show="orderProduct.isRedelivery">
- <i class="fa fa-undo" data-toggle="tooltip" title="Ce produit est une relivraison"></i>
</span>
</a>
</td>
<td>
<span v-if="orderProduct.complementaryReference"> {% verbatim %}{{orderProduct.complementaryReference}}{% endverbatim %}</span>
<span v-if="orderProduct.complementaryReference"> {% verbatim %}{{orderProduct.complementaryReference}}{% endverbatim %}</span>
</td>
<td>
{% verbatim %}{{orderProduct.buyingPrice}}{% endverbatim %} €
</td>
<td>
{% verbatim %}{{orderProduct.price}}{% endverbatim %}€
</td>
<td>
{% verbatim %}{{orderProduct.priceWithTax}}{% endverbatim %}€
{% verbatim %}{{orderProduct.priceWithTax}}{% endverbatim %}
</td>
<td>
{% verbatim %}{{orderProduct.totalMargin}}{% endverbatim %}€ /
{% verbatim %}{{orderProduct.marginPercent}}{% endverbatim %}%
{% verbatim %}{{orderProduct.totalMargin}}{% endverbatim %} € /
{% verbatim %}{{orderProduct.marginPercent}}{% endverbatim %} %
</td>
<td>
{% verbatim %}{{orderProduct.availableQuantity}}{% endverbatim %}
@@ -102,19 +110,22 @@
{% endif %}
</td>
<td>
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}
</td>
<td :class="editionMode ? '' : 'hidden'">
<div class="dropdown" :class="editionMode ? '' : 'hidden'">
<button class="btn-sm btn-info dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-expanded="false">
<div class="dropdown" :class="editionMode ? '' : 'hidden'">
<button class="btn-sm btn-info dropdown-toggle" type="button" id="dropdownMenu"
data-toggle="dropdown" aria-expanded="false">
Actions
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu">
<button v-show="modalExist('#modal-add-redelivery-order-product') && orderProduct.hasRedelivery == false" type="button" class="dropdown-item" @click="modalAddRedeliveryOrderProduct">
<button v-show="modalExist('#modal-add-redelivery-order-product') && orderProduct.hasRedelivery == false"
type="button" class="dropdown-item" @click="modalAddRedeliveryOrderProduct">
Générer une relivraison
</button>

<button v-show="modalExist('#modal-add-reduction-credit')" type="button" class="dropdown-item" @click="modalAddReductionCredit" >
<button v-show="modalExist('#modal-add-reduction-credit')" type="button" class="dropdown-item"
@click="modalAddReductionCredit">
Générer un avoir
</button>
</div>
@@ -149,7 +160,7 @@
<tbody>
<tr>
<th>Total produits TTC</th>
<td>${order.totalOrderProductsWithTax}€</td>
<td>${order.totalOrderProductsWithTax} €</td>
</tr>
<template v-for="(orderReductionCart, key) in order.orderReductionCarts">
<tr>
@@ -161,7 +172,7 @@
<i class="fa fa-trash"></i>
</button>
</th>
<td>${orderReductionCart.amount}€</td>
<td>${orderReductionCart.amount} €</td>
</tr>
</template>
<template v-for="(orderReductionCredit, key) in order.orderReductionCredits">
@@ -174,25 +185,25 @@
<i class="fa fa-trash"></i>
</button>
</th>
<td>${orderReductionCredit.amount}€</td>
<td>${orderReductionCredit.amount} €</td>
</tr>
</template>
<tr>
<th>Total produits après réductions TTC</th>
<td>${order.totalOrderProductsWithTaxAndReductions}€</td>
<td>${order.totalOrderProductsWithTaxAndReductions} €</td>
</tr>
<tr>
<th>Total marge produits</th>
<td>${order.totalMargin}€ <br /> ${order.totalMarginPercent}%</td>
<td>${order.totalMargin} € <br/> ${order.totalMarginPercent} %</td>
</tr>

<tr>
<th>Frais de livraisons TTC</th>
<td>${order.deliveryPriceWithTaxAndReduction}€</td>
<td>${order.deliveryPriceWithTaxAndReduction} €</td>
</tr>
<tr>
<th>Total TTC</th>
<td>${order.totalWithTax}€</td>
<td>${order.totalWithTax} €</td>
</tr>

</tbody>
@@ -217,11 +228,22 @@


{% macro box_user_info() %}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
{% set value = ' <a v-if="order.user" :href="order.userLink" target="_blank" v-html="order.user"></a>
<span v-else v-html="order.visitor"></span>' %}
{{ macros.box_info('bg-info', 'user',"field.default.user"|trans({}, 'lcshop'), value) }}

{% embed '@LcShop/backend/default/block/embed_box.twig' %}
{% import '@LcShop/backend/order/macros.html.twig' as order_macros %}
{% trans_default_domain 'lcshop' %}
{% block class %}bg-info{% endblock %}
{% block icon %}credit-card{% endblock %}
{% block label %}{{ "field.OrderShop.reference"|trans({}, 'lcshop') }}{% endblock %}
{% block value %}
<span v-if="order.user" v-html="order.user"></span>
<span v-else v-html="order.visitor"></span>
{% endblock %}
{% block button %}
<a class="btn btn-sm btn-secondary" target="_blank" :href="order.userLink">
Voir la fiche
</a>
{% endblock %}
{% endembed %}
{% endmacro box_user_info %}


@@ -233,16 +255,13 @@
{% trans_default_domain 'lcshop' %}
{% block class %}bg-info{% endblock %}
{% block icon %}credit-card{% endblock %}
{% block label %}{{ "field.OrderShop.reference"|trans({}, 'lcshop')}}{% endblock %}
{% block label %}{{ "field.OrderShop.reference"|trans({}, 'lcshop') }}{% endblock %}
{% block value %}
${order.reference}<br />
${order.reference}<br/>
<span v-if="order.countComplementaryOrderShops > 0">
${order.countComplementaryOrderShops} commande(s) complémentaire(s)
</span>
{% endblock %}
{% block button %}
{{ order_macros.order_modal_button('#modal-order-delivery-address') }}
{% endblock %}
{% endembed %}
{% endmacro %}

@@ -257,9 +276,26 @@


{% macro box_total_order() %}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
{% embed '@LcShop/backend/default/block/embed_box.twig' %}
{% import '@LcShop/backend/order/macros.html.twig' as order_macros %}
{% trans_default_domain 'lcshop' %}
{% block class %}bg-danger{% endblock %}
{% block icon %}euro-sign{% endblock %}
{% block infoBox %}
Total produits après réduc TTC :
<strong class="float-right"> ${order.totalOrderProductsWithTaxAndReductions} €</strong><br/>

Total marge produits :
<strong class="float-right">${order.totalMargin} € / ${order.totalMarginPercent} %</strong><br/>

Frais de livraisons TTC :
<strong class="float-right">${order.deliveryPriceWithTaxAndReduction} €</strong><br/>

{{ macros.box_info('bg-danger', 'euro-sign',"field.OrderShop.total"|trans({}, 'lcshop'), ' ${order.totalWithTax} €') }}
Total commandes :
<strong class="float-right"> ${order.totalWithTax} €</strong><br/>

{% endblock %}
{% endembed %}

{% endmacro %}

@@ -290,7 +326,7 @@
{% trans_default_domain 'lcshop' %}
{% block class %}bg-success{% endblock %}
{% block icon %}map-marked-alt{% endblock %}
{% block label %}{{ "field.default.deliveryAddress"|trans({}, 'lcshop')}}{% endblock %}
{% block label %}{{ "field.default.deliveryAddress"|trans({}, 'lcshop') }}{% endblock %}
{% block value %}
<div v-if="order.deliveryAddress">
<address v-html="order.deliveryAddress">
@@ -352,48 +388,49 @@
</div>' %}

{{ macros.card_start("OrderShop.payment", 'danger card-outline', false, tools) }}
<table class="table table-striped" style="margin-bottom: 15px">
<tbody>
<thead>
<table class="table table-striped" style="margin-bottom: 15px">
<tbody>
<thead>
<tr>
<th v-if="order.countComplementaryOrderShops > 0">Référence</th>
<th>Mode de règlement</th>
<th>Date</th>
<th>Montant</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<template v-for="(orderPayment, i) in order.orderPayments">
<tr>
<th v-if="order.countComplementaryOrderShops > 0">Référence</th>
<th>Mode de règlement</th>
<th>Date</th>
<th>Montant</th>
<th>Actions</th>
<td v-if="order.countComplementaryOrderShops > 0">
${orderPayment.orderReference}
</td>
<td>${orderPayment.meanPaymentText}</td>
<td>${orderPayment.paidAtText}</td>
<td>${orderPayment.amount}</td>

<td>
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')"
class="btn-sm btn-info" type="button" @click="editOrderPayment(orderPayment.id)">
<i class="fa fa-pen"></i>
</button>
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')"
type="button" class="btn-sm btn-danger"
@click="modalDeleteOrderPayment(orderPayment.id)">
<i class="fa fa-trash"></i>
</button>
</td>
</tr>
</thead>
<tbody>
<template v-for="(orderPayment, i) in order.orderPayments">
<tr>
<td v-if="order.countComplementaryOrderShops > 0">
${orderPayment.orderReference}
</td>
<td>${orderPayment.meanPaymentText}</td>
<td>${orderPayment.paidAtText}</td>
<td>${orderPayment.amount}</td>

<td>
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')" class="btn-sm btn-info" type="button" @click="editOrderPayment(orderPayment.id)">
<i class="fa fa-pen"></i>
</button>
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')"
type="button" class="btn-sm btn-danger"
@click="modalDeleteOrderPayment(orderPayment.id)">
<i class="fa fa-trash"></i>
</button>
</td>
</tr>
</template>
</tbody>
</table>
<div class="col-11">
{{ _self.order_modal_button('#modal-order-payment', 'btn-info', "action.order.addOrderPayment") }}
</template>
</tbody>
</table>
<div class="col-11">
{{ _self.order_modal_button('#modal-order-payment', 'btn-info', "action.order.addOrderPayment") }}

<strong class="float-right">Total règlement : ${order.totalOrderPaid} €</strong>
<strong class="float-right">Total règlement : ${order.totalOrderPaid} €</strong>

{#TODO: afficher si la commande est règlé et afficher une alerte si le montant des paiments est supérieur au montant total de la commande#}
</div>
{#TODO: afficher si la commande est règlé et afficher une alerte si le montant des paiments est supérieur au montant total de la commande#}
</div>
{{ macros.card_end() }}
{% endmacro %}

@@ -424,7 +461,8 @@
<td>Facture</td>
<td>${orderDocument.reference}</td>
<td>
<a :href="'./?entity=Document&action=downloadInvoice&id='+orderDocument.id" class="btn-sm btn-default">Télécharger</a>
<a :href="'./?entity=Document&action=downloadInvoice&id='+orderDocument.id"
class="btn-sm btn-default">Télécharger</a>
</td>
</tr>
</template>
@@ -508,7 +546,7 @@
{% trans_default_domain 'lcshop' %}
{% block class %}bg-success{% endblock %}
{% block icon %}info{% endblock %}
{% block label %}{{ "field.OrderShop.status"|trans({}, 'lcshop')}}{% endblock %}
{% block label %}{{ "field.OrderShop.status"|trans({}, 'lcshop') }}{% endblock %}
{% block value %}
<strong> ${order.orderStatus}</strong>
{% endblock %}

+ 2
- 2
ShopBundle/Resources/views/backend/order/show-cart.html.twig Переглянути файл

@@ -11,10 +11,10 @@
{{ order_macros.box_user_info() }}
</div>
<div class="col-3">
{{ order_macros.box_validation_date() }}
{{ order_macros.box_total_order() }}
</div>
<div class="col-3">
{{ order_macros.box_total_order() }}
{{ order_macros.box_validation_date() }}
</div>

<div class="col-3">

+ 2
- 2
ShopBundle/Resources/views/backend/order/show-order.html.twig Переглянути файл

@@ -11,10 +11,10 @@
{{ order_macros.box_user_info() }}
</div>
<div class="col-3">
{{ order_macros.box_validation_date() }}
{{ order_macros.box_total_order() }}
</div>
<div class="col-3">
{{ order_macros.box_total_order() }}
{{ order_macros.box_validation_date() }}
</div>

<div class="col-3">

+ 2
- 3
ShopBundle/Resources/views/backend/order/show.html.twig Переглянути файл

@@ -14,12 +14,11 @@
{{ order_macros.box_user_info() }}
</div>
<div class="col-3">
{{ order_macros.box_validation_date() }}
{{ order_macros.box_total_order() }}
</div>
<div class="col-3">
{{ order_macros.box_total_order() }}
{{ order_macros.box_validation_date() }}
</div>

<div class="col-3">
{{ order_macros.box_status() }}
</div>

+ 0
- 13
ShopBundle/Resources/views/backend/supplier/edit.html.twig Переглянути файл

@@ -1,13 +0,0 @@
{% extends app.request.query.get('action') == 'edit' ? '@LcShop/backend/default/edit.html.twig' : '@LcShop/backend/default/new.html.twig' %}

{% block entity_form %}
{% include '@LcShop/backend/supplier/form.html.twig' %}
{% endblock entity_form %}


{% block script_javascript %}
{{ parent() }}
{% include '@LcShop/backend/default/block/script-vuejs.html.twig' %}
<script src="{{ asset('bundles/lcshop/js/backend/script/supplier/vuejs-supplier.js') }}"></script>

{% endblock %}

+ 0
- 42
ShopBundle/Resources/views/backend/supplier/form.html.twig Переглянути файл

@@ -1,42 +0,0 @@
{{ form_start(form) }}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}

{% set formValues = form.vars.value %}

<div id="lc-supplier-edit">
<div class="card card-light">
<div class="lc-vue-js-container card-header p-0 border-bottom-0">
<ul class="nav nav-tabs" id="nav-params">
<li class="nav-item" v-for="section in sectionsArray">
<button type="button"
:class="'btn '+((currentSection == section.name) ? 'btn btn-primary' : 'btn ')"
@click="changeSection(section)">
${ section.nameDisplay }
<span class="glyphicon glyphicon-triangle-bottom"></span>
<i class="fa fa-exclamation-circle invalid-form"></i>
</button>

</li>
</ul>
</div>
</div>
<div class="form ">

<div v-show="currentSection == 'general'" class="panel panel-default">
{% include '@LcShop/backend/supplier/panel_general.html.twig' %}
</div>
<div v-show="currentSection == 'address'" class="panel panel-default">
{% include '@LcShop/backend/supplier/panel_address.html.twig' %}
</div>
<div v-show="currentSection == 'seo'" class="panel panel-default">
{% include '@LcShop/backend/supplier/panel_seo.html.twig' %}
</div>

</div>

</div>
{{ form_end(form) }}





+ 0
- 17
ShopBundle/Resources/views/backend/supplier/panel_address.html.twig Переглянути файл

@@ -1,17 +0,0 @@
{% trans_default_domain 'lcshop' %}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}

<div class="row">
<div class="col-8">
{{ macros.card_start('Merchant.address','light') }}
{% do form.address.civility.setRendered %}
{% do form.address.firstname.setRendered %}
{% do form.address.lastname.setRendered %}
{% do form.address.phone.setRendered %}
{% do form.address.latitude.setRendered %}
{% do form.address.longitude.setRendered %}
{% do form.address.deliveryInfos.setRendered %}
{% include '@LcShop/backend/default/block/form_address.html.twig' with {'form' : form.address}%}
{{ macros.card_end() }}
</div>
</div>

+ 0
- 23
ShopBundle/Resources/views/backend/supplier/panel_general.html.twig Переглянути файл

@@ -1,23 +0,0 @@
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}

<div class="row">
<div class="col-8">
{{ macros.card_start('Merchant.main','light') }}
<div class="col-12">
{{ form_row(form.title) }}
</div>
<div class="col-12">
{{ form_row(form.subtitle) }}
</div>
<div class="col-12">
{{ form_row(form.kmsHub) }}
</div>
<div class="col-12">
{{ form_row(form.imageFile) }}
</div>
<div class="col-12">
{{ form_row(form.description) }}
</div>
{{ macros.card_end() }}
</div>
</div>

+ 0
- 14
ShopBundle/Resources/views/backend/supplier/panel_seo.html.twig Переглянути файл

@@ -1,14 +0,0 @@
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}

<div class="row">
<div class="col-8">
{{ macros.card_start('Merchant.seo','light') }}
<div class="col-12">
{{ form_row(form.metaTitle) }}
</div>
<div class="col-12">
{{ form_row(form.metaDescription) }}
</div>
{{ macros.card_end() }}
</div>
</div>

+ 23
- 13
ShopBundle/Services/Price/OrderProductPriceUtils.php Переглянути файл

@@ -13,23 +13,31 @@ use Lc\ShopBundle\Context\ReductionCatalogInterface;

class OrderProductPriceUtils
{
use PriceUtilsTrait ;
use PriceUtilsTrait;

protected $productPriceUtils ;
protected $productPriceUtils;

public function __construct(ProductPriceUtils $productPriceUtils)
{
$this->productPriceUtils = $productPriceUtils ;
$this->productPriceUtils = $productPriceUtils;
}

public function getPrice(OrderProductInterface $orderProduct)
public function getPrice(OrderProductInterface $orderProduct, $round = false)
{
return $orderProduct->getPrice();
if ($round) {
return $this->round($orderProduct->getPrice());
} else {
return $orderProduct->getPrice();
}
}

public function getBuyingPrice(OrderProductInterface $orderProduct)
public function getBuyingPrice(OrderProductInterface $orderProduct, $round = false)
{
return $orderProduct->getBuyingPrice();
if ($round) {
return $this->round($orderProduct->getBuyingPrice());
} else {
return $orderProduct->getBuyingPrice();
}
}

public function getPriceWithTax(OrderProductInterface $orderProduct)
@@ -50,7 +58,7 @@ class OrderProductPriceUtils

}

public function getPriceWithReduction(OrderProductInterface $orderProduct)
public function getPriceWithReduction(OrderProductInterface $orderProduct, $round = true)
{
return $this->applyReductionCatalog(
$orderProduct,
@@ -58,7 +66,8 @@ class OrderProductPriceUtils
$this->getPriceWithTax($orderProduct),
1,
null,
false
false,
$round
);

}
@@ -75,14 +84,14 @@ class OrderProductPriceUtils

public function getMargin(OrderProductInterface $orderProduct)
{
return $this->getPriceWithReduction($orderProduct) - $this->getBuyingPrice($orderProduct);
return $this->round($this->getPriceWithReduction($orderProduct, false) - $this->getBuyingPrice($orderProduct));
}

public function getMarginPercent(OrderProductInterface $orderProduct)
{
if($this->getBuyingPrice($orderProduct)) {
if ($this->getBuyingPrice($orderProduct)) {
return $this->round(($this->getMargin($orderProduct) / $this->getPriceWithReduction($orderProduct)) * 100);
}else{
} else {
return 0;
}
}
@@ -132,7 +141,8 @@ class OrderProductPriceUtils
}

//inclus toujours les réductions catalogues
public function getTotalTaxes(OrderProductInterface $orderProduct){
public function getTotalTaxes(OrderProductInterface $orderProduct)
{
return $this->getTotalWithTaxAndReduction($orderProduct) - $this->getTotalWithReduction($orderProduct);
}
}

+ 7
- 2
ShopBundle/Services/Price/PriceUtilsTrait.php Переглянути файл

@@ -42,7 +42,7 @@ trait PriceUtilsTrait
return round((($price * $percent)) / 100, 2);
}

public function applyReductionCatalog($entity, $price, $priceWithTax, $quantity = 1, $reductionCatalog = null, $withTax = true): ?float
public function applyReductionCatalog($entity, $price, $priceWithTax, $quantity = 1, $reductionCatalog = null, $withTax = true, $round = true): ?float
{

if ($reductionCatalog) {
@@ -99,8 +99,13 @@ trait PriceUtilsTrait
} else {
$priceReturn = $this->applyPercentNegative($priceWithTax, $entity->getTaxRateInherited()->getValue());
}
if($round){
return $this->round($priceReturn);
}else{
return $priceReturn;
}


return $this->round($priceReturn);
}



+ 1
- 1
ShopBundle/Services/UserUtils.php Переглянути файл

@@ -105,4 +105,4 @@ class UserUtils
$this->em->flush() ;
}

}
}

Завантаження…
Відмінити
Зберегти