Просмотр исходного кода

[Administration] Factures : intégration des numéros de BL

feature/rotating_product
Guillaume Bourgeois 7 месяцев назад
Родитель
Сommit
340e8135fa
4 измененных файлов: 34 добавлений и 13 удалений
  1. +8
    -13
      backend/controllers/DocumentController.php
  2. +10
    -0
      backend/views/document/download.php
  3. +15
    -0
      domain/Document/DeliveryNote/DeliveryNoteRepository.php
  4. +1
    -0
      domain/Document/Invoice/InvoiceSolver.php

+ 8
- 13
backend/controllers/DocumentController.php Просмотреть файл

@@ -416,7 +416,8 @@ class DocumentController extends BackendController
$documentModule = $this->getDocumentModule();
$orderModule = $this->getOrderModule();
$producerModule = $this->getProducerModule();
$producerCurrent = $this->getProducerCurrent();
$invoiceModule = $this->getInvoiceModule();
$deliveryNoteModule = $this->getDeliveryNoteModule();

\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

@@ -441,25 +442,19 @@ class DocumentController extends BackendController
];

if ($classDocument == 'Invoice') {
$options = [
'orderby' => 'distribution.date ASC',
'join_with' => ['user AS user_delivery_note', 'orders', 'producer']
];
$deliveryNotesCreateArray = DeliveryNote::searchAll([
'id_user' => $user->id,
'status' => Document::STATUS_VALID,
'ignore_when_invoicing' => null
], $options);
$deliveryNotesUpdateArray = DeliveryNote::searchAll([
'id_user' => $user->id,
'status' => Document::STATUS_VALID,
'order.id_invoice' => $idDocument,
'ignore_when_invoicing' => null
], $options);
], [
'orderby' => 'distribution.date ASC',
'join_with' => ['user AS user_delivery_note', 'orders', 'producer']
]);
$invoice = $idDocument ? $invoiceModule->getRepository()->findOneInvoiceById($idDocument) : null;
$deliveryNotesUpdateArray = $invoice ? $deliveryNoteModule->getRepository()->findDeliveryNotesByInvoice($invoice) : null;
$json['delivery_note_create_array'] = $this->initDeliveryNoteArray('create', $deliveryNotesCreateArray);
$json['delivery_note_update_array'] = $this->initDeliveryNoteArray('update', $deliveryNotesUpdateArray);


$json['orders_create_array'] = [];
$json['orders_update_array'] = [];
if(!$producerModule->getConfig('option_invoice_only_based_on_delivery_notes')) {

+ 10
- 0
backend/views/document/download.php Просмотреть файл

@@ -8,6 +8,7 @@ $producerModule = $this->getProducerModule();
$userModule = $this->getUserModule();
$documentModule = $this->getDocumentModule();
$orderModule = $this->getOrderModule();
$deliveryNoteModule = $this->getDeliveryNoteModule();

$isDocumentDeliveryNote = $documentModule->getSolver()->isDocumentDeliveryNote($document);
$displayPrices = !$isDocumentDeliveryNote || ($isDocumentDeliveryNote && $producerModule->getConfig('document_display_prices_delivery_note'));
@@ -68,6 +69,15 @@ $documentPriceDecimals = (int) $producerModule->getConfig('option_document_price
<strong>Libellé : </strong>
<?= $document->name; ?>
</div>
<?php if ($documentModule->getSolver()->isDocumentInvoice($document)): ?>
<?php $deliveryNotesUpdateArray = $deliveryNoteModule->getRepository()->findDeliveryNotesByInvoice($document); ?>
<?php if($deliveryNotesUpdateArray && count($deliveryNotesUpdateArray)): ?>
<strong>Bons de livraison : </strong>
<?php foreach($deliveryNotesUpdateArray as $key => $deliveryNote): ?>
<?= $deliveryNote->reference ?><?php if ($key !== array_key_last($deliveryNotesUpdateArray)): ?>, <?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
<?php if (strlen($document->comment)): ?>
<div class="comment">
<br>

+ 15
- 0
domain/Document/DeliveryNote/DeliveryNoteRepository.php Просмотреть файл

@@ -2,6 +2,8 @@

namespace domain\Document\DeliveryNote;

use domain\Document\Document\Document;
use domain\Document\Invoice\Invoice;
use domain\Order\Order\Order;
use domain\_\AbstractRepository;

@@ -55,4 +57,17 @@ class DeliveryNoteRepository extends AbstractRepository

return $deliveryNoteExist;
}

public function findDeliveryNotesByInvoice(Invoice $invoice): array
{
return DeliveryNote::searchAll([
'id_user' => $invoice->id_user,
'status' => Document::STATUS_VALID,
'order.id_invoice' => $invoice->id,
'ignore_when_invoicing' => null
], [
'orderby' => 'distribution.date ASC',
'join_with' => ['user AS user_delivery_note', 'orders', 'producer']
]);
}
}

+ 1
- 0
domain/Document/Invoice/InvoiceSolver.php Просмотреть файл

@@ -23,4 +23,5 @@ class InvoiceSolver extends DocumentSolver
{
return $this->getInvoiceAmountPaid($invoice) >= Price::numberTwoDecimals($this->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL));
}

}

Загрузка…
Отмена
Сохранить