Browse Source

[Administration] Documents > Factures : génération sur base des commandes #1218

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
8ecd432622
4 changed files with 15 additions and 15 deletions
  1. +2
    -1
      backend/controllers/DocumentController.php
  2. +3
    -3
      backend/views/document/_form.php
  3. +2
    -11
      common/logic/Order/Order/Service/OrderBuilder.php
  4. +8
    -0
      common/logic/Order/Order/Service/OrderSolver.php

+ 2
- 1
backend/controllers/DocumentController.php View File

$ordersReturnArray[] = [ $ordersReturnArray[] = [
'id' => $order->id, 'id' => $order->id,
'date' => $order->distribution->date, 'date' => $order->distribution->date,
'amount_with_tax' => $order->invoice_amount_with_tax
'name' => date('d/m/Y', strtotime($order->distribution->date)),
'amount_with_tax' => $orderManager->getOrderAmountWithTax($order, Order::INVOICE_AMOUNT_TOTAL)
]; ];
} }



+ 3
- 3
backend/views/document/_form.php View File

<table v-if="ordersUpdateArray && ordersUpdateArray.length > 0" class="table table-bordered"> <table v-if="ordersUpdateArray && ordersUpdateArray.length > 0" class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th>Libellé</th>
<th>Date</th>
<th v-if="taxRateProducer != 0">Montant (TTC)</th> <th v-if="taxRateProducer != 0">Montant (TTC)</th>
<th v-else>Montant</th> <th v-else>Montant</th>
<th v-if="document.status == 'draft'"></th> <th v-if="document.status == 'draft'"></th>
</thead> </thead>
<tbody> <tbody>
<tr v-for="order in ordersUpdateArray"> <tr v-for="order in ordersUpdateArray">
<td>{{ order.date }}</td>
<td>{{ order.name }}</td>
<td>{{ formatPrice(order.amount_with_tax) }}</td> <td>{{ formatPrice(order.amount_with_tax) }}</td>
<td v-if="document.status == 'draft'"> <td v-if="document.status == 'draft'">
<a class="btn btn-default" href="javascript:void(0);" @click="deleteOrderFromInvoice" :data-id="order.id"> <a class="btn btn-default" href="javascript:void(0);" @click="deleteOrderFromInvoice" :data-id="order.id">
<select class="form-control" v-model="orderAddId"> <select class="form-control" v-model="orderAddId">
<option value="0" selected="selected">--</option> <option value="0" selected="selected">--</option>
<option v-for="order in ordersCreateArray" :value="order.id"> <option v-for="order in ordersCreateArray" :value="order.id">
{{ order.date }}
{{ order.name }}
</option> </option>
</select> </select>
</div> </div>

+ 2
- 11
common/logic/Order/Order/Service/OrderBuilder.php View File

/** /**
* Initialise le montant total, le montant déjà payé et le poids de la commande. * Initialise le montant total, le montant déjà payé et le poids de la commande.
*/ */
public function initOrder(Order $order, string $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT): void
public function initOrder(Order $order): void
{ {
// @TODO : récupérer le bon taxCalculationMethod
//$taxCalculationMethod = Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS;

$taxCalculationMethod = $this->getProducerContext()->option_tax_calculation_method;
$this->initOrderAmount($order, $taxCalculationMethod); $this->initOrderAmount($order, $taxCalculationMethod);
$this->initOrderPaidAmount($order); $this->initOrderPaidAmount($order);

// @TODO : faire le bon calcul pour la TVA
/*$totalVat = 0;
foreach($order->invoice_amount_vat as $vat) {
$totalVat += $vat;
}
$order->invoice_amount_with_tax = Price::round($order->invoice_amount + $totalVat);*/
} }


/** /**

+ 8
- 0
common/logic/Order/Order/Service/OrderSolver.php View File



use common\helpers\Price; use common\helpers\Price;
use common\logic\AbstractService; use common\logic\AbstractService;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Document\Service\DocumentSolver; use common\logic\Document\Document\Service\DocumentSolver;
use common\logic\Order\Order\Model\Order; use common\logic\Order\Order\Model\Order;
use common\logic\Producer\Producer\Model\Producer; use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\Product\Product\Model\Product; use common\logic\Product\Product\Model\Product;
use common\logic\SolverInterface; use common\logic\SolverInterface;
use common\logic\User\CreditHistory\Model\CreditHistory; use common\logic\User\CreditHistory\Model\CreditHistory;
protected UserSolver $userSolver; protected UserSolver $userSolver;
protected DocumentSolver $documentSolver; protected DocumentSolver $documentSolver;
protected CreditHistorySolver $creditHistorySolver; protected CreditHistorySolver $creditHistorySolver;
protected ProducerSolver $producerSolver;


public function loadDependencies(): void public function loadDependencies(): void
{ {
$this->documentSolver = $this->loadService(DocumentSolver::class); $this->documentSolver = $this->loadService(DocumentSolver::class);
$this->userSolver = $this->loadService(UserSolver::class); $this->userSolver = $this->loadService(UserSolver::class);
$this->creditHistorySolver = $this->loadService(CreditHistorySolver::class); $this->creditHistorySolver = $this->loadService(CreditHistorySolver::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
} }


public function getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = ''): string public function getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = ''): string
$totalVat += $vat; $totalVat += $vat;
} }


if($this->getProducerContext()->option_tax_calculation_method == Document::TAX_CALCULATION_METHOD_ROUNDING_OF_THE_SUM) {
$totalVat = Price::round($totalVat);
}

return $totalVat; return $totalVat;
} }



Loading…
Cancel
Save