Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/b-7.0.x' into b-7.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieg committed Nov 16, 2024
2 parents 50b82b0 + c11373b commit ccd0085
Show file tree
Hide file tree
Showing 31 changed files with 683 additions and 409 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/dispatch_full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Trigger all configurations

on:
workflow_dispatch:

jobs:
shop70:
if: always()
uses: oxid-eSales/github-actions/.github/workflows/universal_workflow_light.yml@v4
with:
testplan: '~/defaults/7.0.x.yml,~/module-invoice.yml,~/_custom.yml'
runs_on: '"ubuntu-latest"'
defaults: 'v4'
plan_folder: '.github/fresh-advance'
custom_testplan_yaml: |
global:
title: '7.0.x-full'
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

shop71:
if: always()
uses: oxid-eSales/github-actions/.github/workflows/universal_workflow_light.yml@v4
with:
testplan: '~/defaults/7.1.x.yml,~/module-invoice.yml,~/_custom.yml'
runs_on: '"ubuntu-latest"'
defaults: 'v4'
plan_folder: '.github/fresh-advance'
custom_testplan_yaml: |
global:
title: '7.1.x-full'
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

shop72:
if: always()
uses: oxid-eSales/github-actions/.github/workflows/universal_workflow_light.yml@v4
with:
testplan: '~/defaults/7.2.x.yml,~/module-invoice.yml,~/_custom.yml'
runs_on: '"ubuntu-latest"'
defaults: 'v4'
plan_folder: '.github/fresh-advance'
custom_testplan_yaml: |
global:
title: '7.2.x-full'
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/dispatch_module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
testplan: ${{ needs.build_testplan.outputs.testplan }}
runs_on: '"ubuntu-latest"'
defaults: 'v4'
plan_folder: '.github/oxid-esales'
plan_folder: '.github/fresh-advance'
secrets:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
Expand Down
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [v3.0.0] - Unreleased
## [v3.1.0] - 2024-10-01

### Added
- New setting for configuring the filename of the invoice document in the order confirmation email

## [v3.0.1] - 2024-09-28

### Fixed
- Fix the issue with the invoice filename in the email - now its "invoice.pdf" instead of "example.pdf"

## [v3.0.0] - 2024-09-26

### Added
- Logo updated
Expand All @@ -14,10 +24,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Possibility to set a template for Invoice number and use invoice number from the Order
- Blocks in body.html.twig for customizing the template by your needs
- Possibility to automatically calculate the current date by specific format from the settings
- Double-check question for Regeneration of the document
- New block for showing if document already generated with Download button

### Changed
- Invoice document footer setting moved to Layout settings group
- Improve quality tools configurations
- In admin controller there is no separate Save action anymore, it saves And generates the new document at once

### Fixed
- Add signer line in the invoice document only if value is not empty

### Removed
- Smarty support

## [v2.1.0] - 2023-11-08

Expand Down Expand Up @@ -74,6 +93,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- PDF file generated from order data with possibility to adjust some of the fields and regenerate the invoice file
- Invoice generated in Shop's main language (if translation available)

[v3.1.0]: https://github.com/Fresh-Advance/Invoice/compare/v3.0.1...v3.1.0
[v3.0.1]: https://github.com/Fresh-Advance/Invoice/compare/v3.0.0...v3.0.1
[v3.0.0]: https://github.com/Fresh-Advance/Invoice/compare/v2.2.0...v3.0.0
[v2.2.0]: https://github.com/Fresh-Advance/Invoice/compare/v2.1.0...v2.2.0
[v2.1.0]: https://github.com/Fresh-Advance/Invoice/compare/v2.0.0...v2.1.0
[v2.0.0]: https://github.com/Fresh-Advance/Invoice/compare/v1.3.0...v2.0.0
Expand Down
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@
## Features

* Adjustable invoice pages margins
* Adjustable invoice pages header and footer
* Adjustable invoice pages header and footer (images are possible in inlined CSS)
* Invoice numbering automation (uses the order's oxbillnr field)
* Several fields are adjustable before invoice generation:
* Invoice number template (or number itself, if number automation is not used)
* Invoice date (with configurable format for automatic calculation)
* Invoice signer person
* PDF Invoice file generated in shop Default language
* Currently we have DE, EN and LT translations available here. Feel free to add yours.
* Total sum shown in words in the invoice.

* Currently we have DE, EN and LT translations available. Feel free to add yours.
* PDF Invoice can be automatically generated and attached to order confirmation email
* Invoice filename configurable through settings
* Total sum shown in words in the invoice.
* Only Twig shop installations supported
* Tested with PHP 8.0 and 8.1
* Tested with MySQL 5.7 and 8.0
* Tested with:
* Shop 7.0 - PHP 8.0, 8.1, MySQL 5.7 and 8.0
* Shop 7.1 - PHP 8.1, 8.2, MySQL 5.7 and 8.0
* Shop 7.2 - PHP 8.2, 8.3, MySQL 5.7 and 8.0

## Compatibility

Expand All @@ -35,7 +38,6 @@
* Show Vat for every product in list
* The Credit note issuing functionality
* Possibility to send generated invoice or credit note by email with button click.
* Possibility to add image for invoice background
* Other improvements? (feel free to ask in Issues section for possible additional functions)

## Installation
Expand Down Expand Up @@ -70,6 +72,16 @@ If so, create the file `var/configuration/shops/1/template_extension_chain.yaml`
- oe_moduletemplate(please put your module id instead of the module template example)
```
### More information you might need for the template
The order variable in the template is the Order model object, so you can access all its fields and methods.
Some examples you might need for achieving the desired result:
* Customer number: {{ order.getOrderUser().getFieldData('oxcustnr') }}
* Payment method: {{ order.getPaymentType().oxpayments__oxdesc.value }}
* Order net sum: {{ order.getOrderNetSum() }}
## License
Please make sure you checked the License before using the module. License
Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"payments"
],
"minimum-stability": "dev",
"prefer-stable": true,
"prefer-dist": true,
"require": {
"php": "^8.0",
"oxid-esales/oxideshop-ce": "*",
Expand Down
1 change: 0 additions & 1 deletion google9e85c30aeea032ed.html

This file was deleted.

21 changes: 18 additions & 3 deletions metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'en' => 'Invoice module for OXID eShop.',
],
'thumbnail' => 'logo.png',
'version' => '3.0.0',
'version' => '3.1.0',
'author' => 'Anton Fedurtsya',
'email' => '[email protected]',
'url' => 'https://github.com/Fresh-Advance',
Expand All @@ -31,7 +31,8 @@
],
'extend' => [
\OxidEsales\Eshop\Application\Model\OrderArticle::class => \FreshAdvance\Invoice\Transition\Model\OrderArticle::class,
\OxidEsales\Eshop\Core\Language::class => \FreshAdvance\Invoice\Language\Extension\Language::class
\OxidEsales\Eshop\Core\Language::class => \FreshAdvance\Invoice\Language\Extension\Language::class,
\OxidEsales\Eshop\Core\Email::class => \FreshAdvance\Invoice\Transition\Core\Email::class,
],
'settings' => [
/** Main */
Expand Down Expand Up @@ -83,7 +84,7 @@
'group' => 'fa_invoice_layout',
'name' => \FreshAdvance\Invoice\Document\Settings\DocumentLayoutSettings::SETTING_DOCUMENT_HEADER,
'type' => 'str',
'value' => 'Document Header Example; HTML with simple inline css can go here<br>Change in Module Settings',
'value' => '<small>Document Header Example; HTML with simple inline css can go here - Change in Module Settings</small>',
],
[
'group' => 'fa_invoice_layout',
Expand All @@ -105,6 +106,20 @@
'type' => 'str',
'value' => 'ABC-%1$s',
],

// group emails
[
'group' => 'fa_invoice_emails',
'name' => \FreshAdvance\Invoice\Settings\ModuleSettings::SETTING_SEND_INVOICE_ON_USER_ORDER_EMAIL,
'type' => 'bool',
'value' => false
],
[
'group' => 'fa_invoice_emails',
'name' => \FreshAdvance\Invoice\Settings\ModuleSettings::SETTING_INVOICE_ON_ORDER_EMAIL_FILENAME,
'type' => 'str',
'value' => 'invoice.pdf',
],
],
'events' => [
'onActivate' => '\FreshAdvance\Invoice\Transition\Core\Events::onActivate',
Expand Down
15 changes: 15 additions & 0 deletions src/Settings/ModuleSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class ModuleSettings implements ModuleSettingsInterface
public const SETTING_DOCUMENT_IS_FOR_ARCHIVE = 'fa_invoice_IsForArchive';
public const SETTING_INVOICE_NUMBER_FORMAT = 'fa_invoice_InvoiceNumberFormat';
public const SETTING_INVOICE_DATE_FORMAT = 'fa_invoice_InvoiceDateFormat';
public const SETTING_SEND_INVOICE_ON_USER_ORDER_EMAIL = 'fa_invoice_SendInvoiceOnUserOrderEmail';
public const SETTING_INVOICE_ON_ORDER_EMAIL_FILENAME = 'fa_invoice_InvoiceOnOrderEmailFilename';

public function __construct(
private ModuleSettingServiceInterface $moduleSettingService
Expand Down Expand Up @@ -47,10 +49,23 @@ public function getInvoiceDateFormat(): string
return $this->getStringSetting(self::SETTING_INVOICE_DATE_FORMAT);
}

public function getInvoiceInOrderEmailFilename(): string
{
return $this->getStringSetting(self::SETTING_INVOICE_ON_ORDER_EMAIL_FILENAME);
}

private function getStringSetting(string $key): string
{
return $this->moduleSettingService
->getString($key, Module::MODULE_ID)
->toString();
}

public function isSendInvoiceOnUserOrderEmailActive(): bool
{
return $this->moduleSettingService->getBoolean(
self::SETTING_SEND_INVOICE_ON_USER_ORDER_EMAIL,
Module::MODULE_ID
);
}
}
4 changes: 4 additions & 0 deletions src/Settings/ModuleSettingsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ public function isForArchive(): bool;
public function getInvoiceNumberFormat(): string;

public function getInvoiceDateFormat(): string;

public function isSendInvoiceOnUserOrderEmailActive(): bool;

public function getInvoiceInOrderEmailFilename(): string;
}
47 changes: 23 additions & 24 deletions src/Transition/Controller/Admin/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace FreshAdvance\Invoice\Transition\Controller\Admin;

use FreshAdvance\Invoice\DataType\InvoiceDataInterface;
use FreshAdvance\Invoice\Document\InvoiceGeneratorInterface;
use FreshAdvance\Invoice\Service\Invoice;
use FreshAdvance\Invoice\Service\InvoiceServiceInterface;
Expand All @@ -22,52 +21,52 @@ class InvoiceController extends AdminController
{
use ServiceContainer;

public const ORDER_ID_REQUEST_PARAM = 'orderId';

protected $_sThisTemplate = '@fa_invoice/admin/invoice';

public function render()
{
$orderService = $this->getServiceFromContainer(Invoice::class);
$this->addTplParam('invoiceData', $orderService->getInvoiceDataByOrderId($this->getEditObjectId()));
$invoiceDataService = $this->getServiceFromContainer(Invoice::class);
$invoiceData = $invoiceDataService->getInvoiceDataByOrderId($this->getEditObjectId());
$this->addTplParam('invoiceData', $invoiceData);

$moduleSettingsService = $this->getServiceFromContainer(ModuleSettingsInterface::class);
$this->addTplParam('moduleSettings', $moduleSettingsService);

if (is_file($invoiceData->getInvoicePath())) {
$this->addTplParam('invoiceExists', true);
$this->addTplParam(
'invoiceFileName',
$invoiceDataService->getInvoiceFileName($invoiceData->getInvoiceConfiguration())
);

/** @var int $fileTimestamp */
$fileTimestamp = filemtime($invoiceData->getInvoicePath());
$this->addTplParam('invoiceDate', date('Y-m-d H:i:s', $fileTimestamp));
}

return parent::render();
}

public function saveData(): void
{
$invoiceService = $this->getServiceFromContainer(Invoice::class);
$requestService = $this->getServiceFromContainer(RequestInterface::class);
$invoiceService->saveOrderInvoiceData($requestService->getInvoiceConfigurationFromRequest());
}

public function downloadOrderInvoice(): void
{
$orderId = $this->getOrderIdFromRequest();
$generator = $this->getServiceFromContainer(InvoiceGeneratorInterface::class);

$invoiceDataService = $this->getServiceFromContainer(Invoice::class);
$invoiceData = $invoiceDataService->getInvoiceDataByOrderId($orderId);
$invoiceService->saveOrderInvoiceData($requestService->getInvoiceConfigurationFromRequest());

$this->proceedToGenerateAndDownload($invoiceData, $invoiceDataService);
$invoiceData = $invoiceService->getInvoiceDataByOrderId($requestService->getInvoiceIdFromRequest());
$generator->generate($invoiceData);
}

protected function getOrderIdFromRequest(): string
public function downloadOrderInvoice(): void
{
$request = $this->getServiceFromContainer(RequestInterface::class);
return $request->getInvoiceIdFromRequest();
}
$invoiceDataService = $this->getServiceFromContainer(Invoice::class);
$invoiceService = $this->getServiceFromContainer(InvoiceServiceInterface::class);

protected function proceedToGenerateAndDownload(
InvoiceDataInterface $invoiceData,
Invoice $invoiceDataService
): void {
$generator = $this->getServiceFromContainer(InvoiceGeneratorInterface::class);
$generator->generate($invoiceData);
$invoiceData = $invoiceDataService->getInvoiceDataByOrderId($request->getInvoiceIdFromRequest());

$invoiceService = $this->getServiceFromContainer(InvoiceServiceInterface::class);
$invoiceService->triggerInvoiceFileDownload(
$invoiceDataService->getInvoiceFileName($invoiceData->getInvoiceConfiguration()),
$invoiceData->getInvoicePath()
Expand Down
Loading

0 comments on commit ccd0085

Please sign in to comment.