Pārlūkot izejas kodu

[Administration] Utilisateurs > historique crédit : colonne commentaire #1279

feature/souke
Guillaume Bourgeois pirms 1 gada
vecāks
revīzija
9547378ec3
9 mainītis faili ar 71 papildinājumiem un 16 dzēšanām
  1. +1
    -0
      backend/controllers/DocumentController.php
  2. +1
    -1
      backend/controllers/UserController.php
  3. +1
    -1
      backend/models/CreditForm.php
  4. +7
    -0
      backend/views/user/credit.php
  5. +1
    -0
      common/logic/Order/Order/Service/OrderBuilder.php
  6. +14
    -1
      common/logic/Payment/Model/Payment.php
  7. +6
    -6
      common/logic/Payment/Service/PaymentBuilder.php
  8. +14
    -7
      common/logic/Payment/Service/PaymentUtils.php
  9. +26
    -0
      console/migrations/m231002_142915_add_column_payment_summary.php

+ 1
- 0
backend/controllers/DocumentController.php Parādīt failu

@@ -185,6 +185,7 @@ class DocumentController extends BackendController
null,
MeanPayment::TRANSFER,
null,
null,
$document
);
$payment->amount = number_format($payment->amount, 2);

+ 1
- 1
backend/controllers/UserController.php Parādīt failu

@@ -402,7 +402,7 @@ class UserController extends BackendController
if ($creditForm->load(\Yii::$app->request->post()) && $creditForm->validate()) {

$paymentContainer->getUtils()
->creditOrDebitUser($creditForm->type, $user, $creditForm->amount, $creditForm->mean_payment, $this->getUserCurrent());
->creditOrDebitUser($creditForm->type, $user, $creditForm->amount, $creditForm->mean_payment, $this->getUserCurrent(), $creditForm->comment);

if($creditForm->send_mail) {
$paymentContainer->getNotifier()

+ 1
- 1
backend/models/CreditForm.php Parādīt failu

@@ -103,7 +103,7 @@ class CreditForm extends Model

if ($this->validate()) {
$user = $userManager->findOneUserById($this->id_user);
$paymentManager->creditOrDebitUser($this->type, $user, $this->amount, $this->mean_payment, $userManager->getCurrent());
$paymentManager->creditOrDebitUser($this->type, $user, $this->amount, $this->mean_payment, $userManager->getCurrent(), $this->comment);
// on prévient l'utilisateur que son compte vient d'être crédité
if($this->send_mail) {

+ 7
- 0
backend/views/user/credit.php Parādīt failu

@@ -163,6 +163,13 @@ $this->addBreadcrumb('Créditer') ;
return '';
}
],
[
'label' => 'Commentaire',
'format' => 'raw',
'value' => function ($model) {
return nl2br($model->comment);
}
],
],
]); ?>
</div>

+ 1
- 0
common/logic/Order/Order/Service/OrderBuilder.php Parādīt failu

@@ -451,6 +451,7 @@ class OrderBuilder extends AbstractBuilder
$order->user,
$this->userSolver->getCurrent(),
MeanPayment::CREDIT,
null,
$order
);
}

+ 14
- 1
common/logic/Payment/Model/Payment.php Parādīt failu

@@ -73,7 +73,7 @@ class Payment extends ActiveRecordCommon
[['amount'], 'double'],
[['date_transaction'], 'date', 'format' => 'php:Y-m-d'],
[['type', 'mean_payment'], 'string', 'max' => 255],
[['comment'], 'string', 'max' => 2048],
[['comment', 'summary'], 'string', 'max' => 2048],
];
}

@@ -94,6 +94,7 @@ class Payment extends ActiveRecordCommon
'id_producer' => 'Producteur',
'mean_payment' => 'Moyen de paiement',
'comment' => 'Commentaire',
'summary' => 'Résumé',
'date_transaction' => 'Date transaction'
];
}
@@ -288,4 +289,16 @@ class Payment extends ActiveRecordCommon

return $this;
}

public function getSummary(): ?string
{
return $this->summary;
}

public function setSummary(?string $summary): self
{
$this->summary = $summary;

return $this;
}
}

+ 6
- 6
common/logic/Payment/Service/PaymentBuilder.php Parādīt failu

@@ -28,6 +28,7 @@ class PaymentBuilder extends AbstractBuilder
User $user = null,
User $userAction = null,
string $meanPayment = null,
string $comment = null,
Order $order = null,
Invoice $invoice = null
): Payment
@@ -37,6 +38,8 @@ class PaymentBuilder extends AbstractBuilder
$payment->type = $type;
$payment->amount = round($amount, 2);
$payment->populateProducer($producer);
$payment->setMeanPayment($meanPayment);
$payment->setComment($comment);

if($user) {
$payment->populateUser($user);
@@ -54,10 +57,6 @@ class PaymentBuilder extends AbstractBuilder
$payment->populateInvoice($invoice);
}

if($meanPayment) {
$payment->mean_payment = $meanPayment;
}

return $payment;
}

@@ -68,6 +67,7 @@ class PaymentBuilder extends AbstractBuilder
User $user = null,
User $userAction = null,
string $meanPayment = null,
string $comment = null,
Order $order = null,
Invoice $invoice = null
): ?Payment
@@ -76,8 +76,8 @@ class PaymentBuilder extends AbstractBuilder
return null;
}

$payment = $this->instanciatePayment($type, $amount, $producer, $user, $userAction, $meanPayment, $order, $invoice);
$payment->setComment($payment->getComment() . $this->orderSolver->getPaymentComment($payment));
$payment = $this->instanciatePayment($type, $amount, $producer, $user, $userAction, $meanPayment, $comment, $order, $invoice);
$payment->setSummary($this->orderSolver->getPaymentComment($payment));
$this->create($payment);

return $payment;

+ 14
- 7
common/logic/Payment/Service/PaymentUtils.php Parādīt failu

@@ -28,7 +28,7 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$this->producerSolver = $this->loadService(ProducerSolver::class);
}

public function creditUser(User $user, float $amount, string $meanPayment, User $userAction): void
public function creditUser(User $user, float $amount, string $meanPayment, User $userAction, string $comment): void
{
$this->paymentBuilder->createPayment(
Payment::TYPE_CREDIT,
@@ -36,11 +36,12 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$this->getProducerContext(),
$user,
$userAction,
$meanPayment
$meanPayment,
$comment
);
}

public function debitUser(User $user, float $amount, string $meanPayment, User $userAction): void
public function debitUser(User $user, float $amount, string $meanPayment, User $userAction, string $comment): void
{
$this->paymentBuilder->createPayment(
Payment::TYPE_DEBIT,
@@ -48,17 +49,18 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$this->getProducerContext(),
$user,
$userAction,
$meanPayment
$meanPayment,
$comment
);
}

public function creditOrDebitUser(string $type, User $user, float $amount, string $meanPayment, User $userAction): void
public function creditOrDebitUser(string $type, User $user, float $amount, string $meanPayment, User $userAction, string $comment): void
{
if($type == Payment::TYPE_CREDIT) {
$this->creditUser($user, $amount, $meanPayment, $userAction);
$this->creditUser($user, $amount, $meanPayment, $userAction, $comment);
}
elseif($type == Payment::TYPE_DEBIT) {
$this->debitUser($user, $amount, $meanPayment, $userAction);
$this->debitUser($user, $amount, $meanPayment, $userAction, $comment);
}
else {
throw new ErrorException('$type a une valeur incorrect');
@@ -78,6 +80,7 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$order->user,
$userAction,
$meanPayment,
null,
$order
);
}
@@ -107,6 +110,7 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$order->user,
$userAction,
MeanPayment::CREDIT,
null,
$order
);
}
@@ -124,6 +128,7 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$order->user,
$userAction,
$meanPayment,
null,
$order
);
}
@@ -140,6 +145,7 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$order->user,
$userAction,
MeanPayment::CREDIT,
null,
$order
);
}
@@ -158,6 +164,7 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$order->user,
$userAction,
MeanPayment::CREDIT,
null,
$order
);
}

+ 26
- 0
console/migrations/m231002_142915_add_column_payment_summary.php Parādīt failu

@@ -0,0 +1,26 @@
<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m231002_142915_add_column_payment_summary
*/
class m231002_142915_add_column_payment_summary extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('payment', 'summary', Schema::TYPE_TEXT);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('payment', 'summary');
}
}

Notiek ielāde…
Atcelt
Saglabāt