Almost finished first dirty version.
This commit is contained in:
parent
b49d840391
commit
a5603b7724
|
@ -20,6 +20,7 @@
|
|||
"mpdf/mpdf": "^8.0",
|
||||
"symfony/yaml": "^5.0",
|
||||
"twig/html-extra": "^3.0",
|
||||
"twig/intl-extra": "^3.0",
|
||||
"twig/twig": "^3.0"
|
||||
},
|
||||
"config": {
|
||||
|
|
188
composer.lock
generated
188
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c214995f6d2d08b81315006f8b75ff8f",
|
||||
"content-hash": "08be0128a2de0c32973a187511fbb665",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asika/simple-console",
|
||||
|
@ -358,6 +358,81 @@
|
|||
],
|
||||
"time": "2019-01-30T14:11:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/intl",
|
||||
"version": "v5.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/intl.git",
|
||||
"reference": "519bcb27ea53835c1e8e7f7c8a799c867d570156"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/intl/zipball/519bcb27ea53835c1e8e7f7c8a799c867d570156",
|
||||
"reference": "519bcb27ea53835c1e8e7f7c8a799c867d570156",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"symfony/polyfill-intl-icu": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/filesystem": "^4.4|^5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "to use the component with locales other than \"en\""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Intl\\": ""
|
||||
},
|
||||
"classmap": [
|
||||
"Resources/stubs"
|
||||
],
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "bschussek@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Eriksen Costa",
|
||||
"email": "eriksen.costa@infranology.com.br"
|
||||
},
|
||||
{
|
||||
"name": "Igor Wiedler",
|
||||
"email": "igor@wiedler.ch"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "A PHP replacement layer for the C intl extension that includes additional data from the ICU library.",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"i18n",
|
||||
"icu",
|
||||
"internationalization",
|
||||
"intl",
|
||||
"l10n",
|
||||
"localization"
|
||||
],
|
||||
"time": "2020-01-31T09:13:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/mime",
|
||||
"version": "v5.0.3",
|
||||
|
@ -478,6 +553,64 @@
|
|||
],
|
||||
"time": "2019-11-27T13:56:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-intl-icu",
|
||||
"version": "v1.13.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-intl-icu.git",
|
||||
"reference": "b3dffd68afa61ca70f2327f2dd9bbeb6aa53d70b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/b3dffd68afa61ca70f2327f2dd9bbeb6aa53d70b",
|
||||
"reference": "b3dffd68afa61ca70f2327f2dd9bbeb6aa53d70b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"symfony/intl": "~2.3|~3.0|~4.0|~5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.13-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for intl's ICU-related data and classes",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"icu",
|
||||
"intl",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2019-11-27T13:56:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-intl-idn",
|
||||
"version": "v1.13.1",
|
||||
|
@ -766,6 +899,59 @@
|
|||
],
|
||||
"time": "2019-12-28T07:09:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/intl-extra",
|
||||
"version": "v3.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/intl-extra.git",
|
||||
"reference": "291d79ef98891da3efe14f0771fbe03a25fe6bec"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/intl-extra/zipball/291d79ef98891da3efe14f0771fbe03a25fe6bec",
|
||||
"reference": "291d79ef98891da3efe14f0771fbe03a25fe6bec",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/intl": "^4.3|^5.0",
|
||||
"twig/twig": "^2.4|^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^4.4|^5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Twig\\Extra\\Intl\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com",
|
||||
"homepage": "http://fabien.potencier.org",
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"description": "A Twig extension for Intl",
|
||||
"homepage": "https://twig.symfony.com",
|
||||
"keywords": [
|
||||
"intl",
|
||||
"twig"
|
||||
],
|
||||
"time": "2019-12-28T07:09:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v3.0.1",
|
||||
|
|
|
@ -8,6 +8,10 @@ configuration:
|
|||
images:
|
||||
signature: ''
|
||||
stamp: ''
|
||||
global_substitutions:
|
||||
# TODO extract to parameters
|
||||
'%invoice_number%': '999'
|
||||
'%invoice_date%': '01.01.1970'
|
||||
|
||||
services:
|
||||
-
|
||||
|
@ -24,7 +28,53 @@ translations:
|
|||
source:
|
||||
variables:
|
||||
title: 'Счёт на оплату №%invoice_number% от %invoice_date%'
|
||||
currency: '%currency%'
|
||||
currency: 'EUR'
|
||||
rows:
|
||||
supplier: 'Поставщик'
|
||||
buyer: 'Покупатель'
|
||||
# service table
|
||||
th_number: '№'
|
||||
th_name: 'Наименование работ, услуг'
|
||||
th_amount: 'Кол-во'
|
||||
th_units: 'Ед.'
|
||||
th_price: 'Цена'
|
||||
th_sum: 'Сумма'
|
||||
tf_total: 'Итого'
|
||||
# bank data
|
||||
account_data: 'Банковские реквизиты поставщика'
|
||||
account_number: 'Номер счёта'
|
||||
bank: 'Банк'
|
||||
bank_address: 'Адрес'
|
||||
swift: 'SWIFT'
|
||||
corr_bank: 'Банк-посредник'
|
||||
total_to_pay: 'Всего к оплате'
|
||||
signature: 'Подпись'
|
||||
supplier:
|
||||
title: '123456'
|
||||
short_title: '123'
|
||||
address: 'some address'
|
||||
extra: []
|
||||
bank:
|
||||
account: '9999999999999999999'
|
||||
name: 'Some Bank of some Country'
|
||||
address: 'Some address'
|
||||
swift: 'SOMESWIFT'
|
||||
corr_bank:
|
||||
name: 'SOME CORR BANK'
|
||||
swift: 'SOMESWIFT2'
|
||||
buyer:
|
||||
title: '"Some Client" LLC'
|
||||
address: 'Some Address'
|
||||
extra:
|
||||
- 'VAT: EU12313123'
|
||||
- 'IBAN: EU123131231231232112'
|
||||
static_substitutions:
|
||||
'%contract_date%': '01.01.1970'
|
||||
|
||||
target:
|
||||
variables:
|
||||
title: 'Счёт на оплату №%invoice_number% от %invoice_date%'
|
||||
currency: 'EUR'
|
||||
rows:
|
||||
supplier: 'Поставщик'
|
||||
buyer: 'Покупатель'
|
||||
|
@ -66,5 +116,3 @@ translations:
|
|||
- 'IBAN: EU123131231231232112'
|
||||
static_substitutions:
|
||||
'%contract_date%': '01.01.1970'
|
||||
'%currency%': 'EUR'
|
||||
#target:
|
|
@ -6,7 +6,7 @@ use App\Kernel;
|
|||
use App\Twig\NumberToWordsExtension;
|
||||
use App\Util\StringReplacer;
|
||||
use Twig\Environment as Twig;
|
||||
use Twig\Extra\Html\HtmlExtension;
|
||||
use Twig\Extra\{Html\HtmlExtension, Intl\IntlExtension};
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
class InvoiceGenerator
|
||||
|
@ -15,13 +15,23 @@ class InvoiceGenerator
|
|||
{
|
||||
$twig = static::createTwig();
|
||||
|
||||
$sourceStaticSubstitutions = $config['translations']['source']['static_substitutions'];
|
||||
//$sourceStaticSubstitutions = $config['translations']['target']['static_substitutions'];
|
||||
$sourceStaticSubstitutions = array_merge(
|
||||
$config['translations']['source']['static_substitutions'],
|
||||
$config['configuration']['global_substitutions']
|
||||
);
|
||||
$targetStaticSubstitutions = array_merge(
|
||||
$config['translations']['target']['static_substitutions'],
|
||||
$config['configuration']['global_substitutions']
|
||||
);
|
||||
|
||||
$source = StringReplacer::recursiveReplace(
|
||||
$config['translations']['source']['variables'],
|
||||
$sourceStaticSubstitutions
|
||||
);
|
||||
//$target = StringReplacer::recursiveReplace($config['translations']['target']['variables']);
|
||||
$target = StringReplacer::recursiveReplace(
|
||||
$config['translations']['target']['variables'],
|
||||
$targetStaticSubstitutions
|
||||
);
|
||||
|
||||
// @TODO fix multilingual substitution depending on the context
|
||||
$services = StringReplacer::recursiveReplace($config['services'], $sourceStaticSubstitutions);
|
||||
|
@ -31,7 +41,7 @@ class InvoiceGenerator
|
|||
'configuration' => $config['configuration'],
|
||||
'trans_data' => [
|
||||
'source' => $source,
|
||||
//'target' => $target,
|
||||
'target' => $target,
|
||||
],
|
||||
'services' => $services,
|
||||
'images' => $images,
|
||||
|
@ -55,6 +65,7 @@ class InvoiceGenerator
|
|||
$twig = new Twig($loader);
|
||||
|
||||
$twig->addExtension(new NumberToWordsExtension());
|
||||
$twig->addExtension(new IntlExtension());
|
||||
$twig->addExtension(new HtmlExtension());
|
||||
|
||||
return $twig;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</td>
|
||||
<td width="50%">
|
||||
{{ include ('invoice_side.html.twig', {
|
||||
t: trans_data.source,
|
||||
t: trans_data.target,
|
||||
services: services,
|
||||
images: images,
|
||||
context: 'target',
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">{{ t.rows.supplier }}</td>
|
||||
<td rowspan="2">{{ t.rows.supplier }}:</td>
|
||||
<td colspan="2">{{ t.supplier.title }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">{{ t.supplier.address }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="{{ 2 + t.buyer.extra|length }}">{{ t.rows.buyer }}</td>
|
||||
<td rowspan="{{ 2 + t.buyer.extra|length }}">{{ t.rows.buyer }}:</td>
|
||||
<td colspan="2">{{ t.buyer.title }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -61,10 +61,11 @@
|
|||
</tfoot>
|
||||
</table>
|
||||
|
||||
<!-- Total to pay -->
|
||||
<table class="fat">
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
{{ t.rows.total_to_pay }}: {{ total|ntw(locale) }}
|
||||
{{ t.rows.total_to_pay }}: {{ total|ntw(locale) }} {{ t.currency|currency_name(locale) }}.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue