Skip to content

Commit

Permalink
views p and q
Browse files Browse the repository at this point in the history
Psalm Level 1 Testing folders views p and q
  • Loading branch information
rossaddison committed Jul 13, 2024
1 parent 972edc1 commit 6f44f81
Show file tree
Hide file tree
Showing 111 changed files with 2,890 additions and 3,407 deletions.
2 changes: 2 additions & 0 deletions config/common/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Yiisoft\Yii\DataView\Column\DataColumn;
use Yiisoft\Yii\View\Renderer\CsrfViewInjection;
// yii3-i
use App\Invoice\Helpers\ClientHelper;
use App\Invoice\Helpers\DateHelper;
use App\Invoice\Helpers\NumberHelper;
use App\Invoice\Helpers\Peppol\Peppol_UNECERec20_11e;
Expand Down Expand Up @@ -161,6 +162,7 @@
's' => Reference::to(SettingRepository::class),
'button' => Reference::to(Button::class),
'session' => Reference::to(SessionInterface::class),
'clientHelper' => Reference::to(ClientHelper::class),
'datehelper' => Reference::to(DateHelper::class),
'dateHelper' => Reference::to(DateHelper::class),
'numberHelper' => Reference::to(NumberHelper::class),
Expand Down
9 changes: 5 additions & 4 deletions resources/views/invoice/info/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<p>Introducing India's PayTm payment gateway's QR code method of payment and comparing this with Stripe's method.</p>
<p>A General Sales Tax (GST) Tax System will have to be implemented first for this purpose.</p>
<p>Testing Credit Notes against Invoices with refunds (if payment made) linked to each of the payment gateways.</p>
<p><b>13th July 2024</b></p>
<p>2. Folders p and q completed.</p>
<p><b>5th July 2024</b></p>
<p>Apply backward compatibility for new yiisoft/yii-view-renderer:</p>
<p>1. config/common/params adjusted and namespace <code>use Yiisoft\Yii\View\ViewRenderer;</code> changed to <code>use Yiisoft\Yii\View\Renderer\ViewRenderer;</code></p>
Expand All @@ -55,17 +57,16 @@
<p>Psalm level 1 testing of all invoice/resources/views/invoice folder started.</p>
<p>1. Folders z to r completed.</p>
<p>Psalm Level 1 file future psalm.xml</p>
<p><code><plugins><pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/></plugins>
<p><xmp>
<plugins><pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/></plugins>
<projectFiles>
<directory name="config" />
<directory name="resources/views/invoice" />
<directory name="src" />
<file name="public/index.php"/>
<file name="yii"/>
<file name="autoload.php"/>
</projectFiles>
</code>
</p>
</projectFiles></xmp></p>
<p>What's next: Psalm Level 1 testing of views q to ...</p>
<p>What's after Psalm Testing: Integrating vjiks Telegram Api for hopefully client invoice payment notifications.</p>
<p><b>22nd June 2024</b></p>
Expand Down
77 changes: 0 additions & 77 deletions resources/views/invoice/invtaxrate/_form.php

This file was deleted.

43 changes: 0 additions & 43 deletions resources/views/invoice/invtaxrate/_view.php

This file was deleted.

101 changes: 68 additions & 33 deletions resources/views/invoice/payment/_form.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,50 @@
<?php
declare(strict_types=1);

use App\Invoice\Entity\CustomField;
declare(strict_types=1);

use Yiisoft\FormModel\Field;
use Yiisoft\Html\Html;
use Yiisoft\Html\Tag\Form;

/**
* @var \Yiisoft\View\View $this
* @var \Yiisoft\Router\UrlGeneratorInterface $urlGenerator
*
* @var App\Invoice\Client\ClientRepository $cR
* @var App\Invoice\Entity\InvAmount $invAmount
* @var App\Invoice\Helpers\ClientHelper $clientHelper
* @var App\Invoice\Helpers\CustomValuesHelper $cvH
* @var App\Invoice\Helpers\NumberHelper $numberHelper
* @var App\Invoice\InvAmount\InvAmountRepository $iaR
* @var App\Invoice\Payment\PaymentForm $form
* @var App\Invoice\PaymentCustom\PaymentCustomForm $paymentCustomForm
* @var App\Invoice\Setting\SettingRepository $s
* @var App\Widget\Button $button
* @var Yiisoft\Translator\TranslatorInterface $translator
* @var Yiisoft\Router\UrlGeneratorInterface $urlGenerator
* @var array $customFields
* @var array $customValues
* @var array $errorsCustom
* @var array $openInvs
* @var array $paymentCustomValues
* @var array $paymentMethods
* @var int $openInvsCount
* @var string $alert
* @var string $csrf
* @var string $action
* @var string $actionName
* @var string $title
* @psalm-var array<string, Stringable|null|scalar> $actionArguments
* @psalm-var array<string,list<string>> $errors
* @psalm-var array<string,list<string>> $errorsCustom
* @psalm-var array<array-key, array<array-key, string>|string> $optionsDataPaymentMethod
* @psalm-var array<array-key, array<array-key, string>|string> $optionsDataInvId
*
*/

// If there are no invoices to make payment against give a warning
echo $alert;
?>

<?= Form::tag()
->post($urlGenerator->generate(...$action))
->post($urlGenerator->generate($actionName, $actionArguments))
->enctypeMultipartFormData()
->csrf($csrf)
->id('PaymentForm')
Expand All @@ -46,31 +70,44 @@
->onlyCommonErrors()
?>
<?= Field::errorSummary($form)
->errors($errors_custom)
->errors($errorsCustom)
->header($translator->translate('invoice.error.summary'))
->onlyCommonErrors()
?>
<?php
$optionsDataPaymentMethod = [];
foreach ($paymentMethods as $paymentMethod) {
$optionsDataPaymentMethod[(int)$paymentMethod->getId()] = $paymentMethod->getName();
/**
* @var App\Invoice\Entity\PaymentMethod $paymentMethod
*/
foreach ($paymentMethods as $paymentMethod) {
$paymentMethodId = $paymentMethod->getId();
$paymentMethodName = $paymentMethod->getName();
if ((strlen($paymentMethodId) > 0)
&& (strlen(($paymentMethodName ?? '')) > 0) && (null!==$paymentMethodName)) {
$optionsDataPaymentMethod[$paymentMethodId] = $paymentMethodName;
}
}
echo Field::select($form, 'payment_method_id')
->label($translator->translate('i.payment_method'),['control-label'])
->label($translator->translate('i.payment_method'))
->optionsData($optionsDataPaymentMethod)
->hint($translator->translate('invoice.hint.this.field.is.required'));
?>
<?php
$optionsDataInvId = [];
if ($open_invs_count > 0) {
foreach ($open_invs as $inv) {
$inv_amount = $iaR->repoInvquery((int)$inv->getId());
$optionsDataInvId[(int)$inv->getId()] =
$inv->getNumber() .
' - ' .
$clienthelper->format_client($cR->repoClientquery($inv->getClient_id())) .
' - ' .
$numberhelper->format_currency($inv_amount->getBalance());
if ($openInvsCount > 0) {
/**
* @var App\Invoice\Entity\Inv $inv
*/
foreach ($openInvs as $inv) {
$invAmount = $iaR->repoInvquery((int)$inv->getId());
if (null!==$invAmount) {
$optionsDataInvId[(int)$inv->getId()] =
($inv->getNumber() ?? $translator->translate('invoice.invoice.number.no')) .
' - ' .
($clientHelper->format_client($cR->repoClientquery($inv->getClient_id()))) .
' - ' .
($numberHelper->format_currency($invAmount->getBalance()));
}
}
} else {
$optionsDataInvId[0] = $translator->translate('i.none');
Expand All @@ -79,22 +116,22 @@
<?= Html::openTag('div', ['class' => 'mb-3 form-group']); ?>
<?=
Field::select($form, 'inv_id')
->label($translator->translate('invoice.invoice'),['control-label'])
->label($translator->translate('invoice.invoice'))
->optionsData($optionsDataInvId)
->hint($translator->translate('invoice.hint.this.field.is.required'))
?>
<?= Html::closeTag('div'); ?>
<?= Html::openTag('div', ['class' => 'mb-3 form-group']); ?>
<?= Field::date($form, 'payment_date')
->label($translator->translate('i.date'), ['class' => 'form-label'])
->label($translator->translate('i.date'))
->required(true)
->value($form->getPayment_date() ? ($form->getPayment_date())->format('Y-m-d') : '')
->value($form->getPayment_date() instanceof DateTimeImmutable ? $form->getPayment_date()->format('Y-m-d') : '')
->hint($translator->translate('invoice.hint.this.field.is.required'));
?>
<?= Html::closeTag('div'); ?>
<?= Html::openTag('div', ['class' => 'mb-3 form-group']); ?>
<?= Field::textarea($form, 'note')
->label($translator->translate('i.note'), ['form-label'])
->label($translator->translate('i.note'))
->addInputAttributes([
'placeholder' => $translator->translate('i.note'),
'value' => Html::encode($form->getNote() ?? ''),
Expand All @@ -106,18 +143,20 @@
<?= Html::closeTag('div'); ?>
<?= Html::openTag('div', ['class' => 'mb-3 form-group']); ?>
<?= Field::text($form, 'amount')
->label($translator->translate('i.amount'), ['form-label'])
->label($translator->translate('i.amount'))
->placeholder($translator->translate('i.amount'))
->value(Html::encode($form->getAmount() ?? ''))
->hint($translator->translate('invoice.hint.this.field.is.required'));
?>
<?= Html::closeTag('div'); ?>
<?= Html::closeTag('div'); ?>
<?= Html::openTag('div'); ?>
<?php foreach ($custom_fields as $custom_field): ?>
<?php if ($custom_field instanceof CustomField) { ?>
<?= $cvH->print_field_for_form($custom_field, $paymentCustomForm, $translator, $payment_custom_values, $custom_values); ?>
<?php } ?>
<?php
/**
* @var App\Invoice\Entity\CustomField $customField
*/
foreach ($customFields as $customField): ?>
<?php $cvH->print_field_for_form($customField, $paymentCustomForm, $translator, $paymentCustomValues, $customValues); ?>
<?php endforeach; ?>
<?= Html::closeTag('div'); ?>
<?= Html::closeTag('div'); ?>
Expand All @@ -126,8 +165,4 @@
<?= Html::closeTag('div'); ?>
<?= Html::closeTag('div'); ?>
<?= Html::closeTag('div'); ?>
<?= Form::tag()->close() ?>
<?php foreach ($errors_custom as $error_custom) {
echo \Yiisoft\VarDumper\VarDumper::dump($errors_custom);
}
?>
<?= Form::tag()->close() ?>
Loading

0 comments on commit 6f44f81

Please sign in to comment.