Skip to content

Revert "Setup upgrade 1.6.3: Set all langs to lowercase" #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

nielsdrost7
Copy link
Contributor

Reverts #1232

sudwebdesign and others added 30 commits January 21, 2025 17:35
Discounts factur-x with or without vat fully validated
- `TAXES_AFTER_DISCOUNTS=false` (ip_config.php)

- Change `get_invoice_discount_percent()` to get % vat rate(s)
- - it's valid but bad value
- Global Discount move after/before taxes
- - in function of config_item('taxes_after_discounts')
- - - in views (quotes & invoices) & pdf templates

- get by `config_item('taxes_after_discounts')`
- - is set to true in ip_config example (Origin calculation)
Admin GUI
+ invoices/views/partial_itemlist_table
+ quotes/views/partial_itemlist_table
+ + Removed old thead's (display none)
+ invoices/views/partial_itemlist_responsive
+ quotes/views/partial_itemlist_responsive

6 New files:
+ invoices/views/partial_itemlist_table_invoice_discount.php
+ quotes/views/partial_itemlist_table_invoice_discount.php
Called in amount total table (same 4 table & responsive mode)

+ layout/views/partial/itemlist_table_item_discount_show.php
+ layout/views/partial/itemlist_table_item_discount_input.php
+ layout/views/partial/itemlist_responsive_item_discount_show.php
+ layout/views/partial/itemlist_responsive_item_discount_input.php
Called in quotes|invoices itemlist (One for new and edit)

Public GUI (refactored)
+ application/views/invoice_templates/public/InvoicePlane_Web.php
+ application/views/quote_templates/public/InvoicePlane_Web.php

Typos:
+ Indents tab2spaces

Bugfixes
+ Fixed: VAT selector value on left (new item line : quote & invoice)
+ + Cause: missing `class="td-amount"` in parent td (table template)
+ Fixed: Currency symbol inside item quote price input field (#1212)
+ Fixed: Item lines, total quote not same as invoice
+ + Cause: $item->item_total (with taxe)
+ + Fix  : $item->item_subtotal (without taxe)
+ + in: application/view/quote_templates/public/InvoicePlane_Web.php

Improve
+ get config in (Q&I) `partial_itemlist_table` (like responsive)
+ + Same in other partial's
+ guest/views/quote_view.php Item line: discount to item_discount
+ Inputs Price & Discount \w currency by helper (like responsive)
Invoices & Quotes pdf templates:

app /views/invoice_templates/pdf/InvoicePlane.php (refactorised)
Now InvoicePlane - [overdue | paid].php include InvoicePlane.php

app /views/quote_templates/pdf/InvoicePlane.php (refactorised)

New helper discount_global_print_in_pdf() (see pdf_helper)

Remove no needed `htmlsc`

---

Fixes

+ Label removed & replaced by aria-label in input (Fix bad fix)
+ + [partial_itemlist_table[quot|invoic]e_discount access lint
fix](d04a3ea)

+ Missing $item on add new item (oups, never dev on prod mode)
+ + in app mod layout itemlist_responsive_item_discount_input.php

+ Double invoice discount line (same): missing one `!` (line 202)
+ + in app /views/invoice_templates/public/InvoicePlane_web.php

+ SepaQr\Exceptions (and pdf not generated). See #1214
+ + Amount of the credit transfer cannot be smaller than 0.01 Euro
+ + Amount of the credit transfer cannot be higher than 999999999.99

+ Item table head duplicated when 9 to 13 items (bad head in 2nd page)
+ + in app /views/(quote|invoice)_templates/pdf/InvoicePlane.php
+ + + Possibility to return same as previous
+ + + just set `$add_table_and_head_for_sums` to 0/false

+ PDF Watermark AND XRechnung (ZUGFeRD XML) (issue #912)

Note PDF Watermark:
Watermark in eInvoicing aro not allowed by Mpdf\MpdfException
Message:
PDFA and PDFX do not permit transparency, so mPDF does not allow
Watermarks!
Fixed in mpdf_helper line 102:
From
`if (get_setting('pdf_watermark'))`
To
`if ( ! $embed_xml && get_setting('pdf_watermark'))`

---

Improved Style

+ New stamp system (by css) for pdf & public view (now are translated)

+ New files in assets/core/scss (DRY principle)
+ + _template.scss (imported in ip[_blue]/template.scss)
+ + _stamp.scss (imported in template.scss & in ip[_blue]/style.scss)

+ + Note: Need to rebuild css files with `yarn build sass` command

+ + Todo: Apply to [InvoicePlane-Themes
v1](https://github.com/InvoicePlane/InvoicePlane-Themes/tree/development/v1)

---

Improved

+ module
+ + guest controler View
+ + invoices controler Invoices
+ + quotes controler Quotes
+ + + Linter ( + tab2spaces)
+ + + & add taxes_after_discounts
+ + + + to remove
```
$taxes_after_discounts = config_item('taxes_after_discounts');
```
+ + + + in view's (DRY)

---

Idea: Display taxes columns/cell in view & pdf (like admin view)
How: Add `show_taxes` in controllers like this commit
+ Note: maybe check with percent is best (in case of total == 0)
+ + (Copied from InvoicePlane_Web templates)
Sample:
```
'show_taxes' =>
$this->invoice_tax_total + $this->invoice_item_tax_total != 0; #Inv.
$this->quote_tax_total + $this->quote_item_tax_total != 0; #Quote
```
+ Typo ($filname)

+ For Subject to VAT SpecifiedTaxRegistration 'VA' (vat_id)
+ + not called if all items 100% discount (make taxes = 0)

+ DivisionByZeroError break pdf generation
+ + In `get_invoice_discount_percent()`
+ + Now return percent = '0.01'; // fix by faker (wip)
+ + + See Todo (below)

---

Improve:

+ Not subject to VAT
+ + `invoice_tax_total` 2 `invoice_item_tax_total`
+ + `invoice_total` 2 `invoice_item_subtotal`

---

Todo (idea, wip):

+ Transform get_invoice_discount_percent() to helper
+ + for get/dispatch discount percent vat's rate (of invoice)
+ + to remove `fix by faker (wip)`
Return to item subtotal = quantity * price

Calculate item discount on item subtotal

Calculate global (Q&I) discount on item subtotal

All taxes calculation with item subtotal discounted (wip)

global (Q&I) discount dispatched Proportionally by item
And not apply in Mdl_invoice_amount->calculate_discount()

In mdl tax rate (invoice) removed:
$this->mdl_invoice_amounts->calculate_invoice_taxes($invoice_id);
It Called in calculate (in test, same as quote. Maybe old)

Fix missing currency_symbol on price (Add new item)
In partial_itemlist_table (quote & invoice)
Fix currencyElement function's
• In formattedFloat: (function's renamed)
•• PHP number_format add `,` of thousand separator by default
• Fix cvc-datatype-valid.1.2.1:
•• '1,000.00' is not a valid value for 'decimal'

formattedDate function's renamed

Removed
• old file helpers/zugferd_helper.php (unused)
• bad example file helpers/XMLconfig/Zugferdv23g.php
Best reflect of taxes applied after discounts
wip need to correct me
Refacto guest & partial itemlist(s)
+ Add tooltips to explain's Discount Calculation (admin & guest)

Vars in ip_lang.php (2)
+ global_discount
+ no_open_invoices

Fixes
+ Missing Quote $item->item_tax_rate_name
+ + in default_select() of quotes/models/Mdl_quote_item.php
+ Guest `See pdf` on same tab/window (missing target="_blank")
+ Guest invoice view page never show `Pay now` button
+ Guest invoices view page `Pay now` buttons go to 404 (old url)
+ + in guest/views/invoices_index
+ + OLD: guest/payment_handler/make_payment/#invoice_url_key#
+ + NEW: guest/payment_information/form/#invoice_url_key#

Improve
+ Add filter `Overdue` & `All` (guest/invoices/status/***)
+ + in guest/ views/invoices_index & controllers/invoices
+ Add filter `Viewed` & `All` (guest/quotes/status/***)
+ + in guest/ views/quotes_index & controllers/quotes
If taxes applied after discounts, items_subtotal need to be real
(without item discount applied) to dispatch good discount amount

Global discount (amount) = 1

Before
Items Prices IDiscount GDiscount Total
1     10     1         0.56      8.44
1     10     1         0.56      8.44
                       1.12      16.88

Now (Fixed & Expected)
Items Prices IDiscount GDiscount Total
1     10     1         0.50      8.50
1     10     1         0.50      8.50
                       1         17.00
floatval(100.000,00) become 100 but expected 100000
Need `standardize_amount`
Mdl_invoices: copy_invoice, copy_credit_invoice
Mdl_quote   : copy_quote
Mdl_payments: save
Removed last invoice amounts calculate. Why? it's a copy & sended

Fix missing 'wrong_cron_key_provided' in ip_lang
Sometime global discount total (calculated) differ of user value
Need little adjust to be valid in ZugFerd standard (maybe cents)

Like discount = 100 / 6 items (with same subtotal) = 16.66666...
But the around = 16.67
and 16.67 x 6 = 100.02 Not 100.00 (and this isn't valid)

Only if in ipconfig.php `LEGACY_CALCULATION = false`
Like custom_title = '' in db & $default is 'InvoicePlane'
Return '' but 'InvoicePlane' is expected

Because Mdl_settings->setting() default fallback not returned

Now, if in db = '' return $default & if $default = '' return ''

Nothing change for other types like int, float & null
sudwebdesign and others added 26 commits May 12, 2025 18:50
statement_indentation: false (Best for views)
statement_indentation: true  (Best for full PHP)
Adjust locally to find bad indents in other than views

Add +,-,<,>,!=,== operators in binary_operator_spaces
to respect e-invoice helper (& other)

Note: The `exclude` rule not effective with **
composer update
vendor/bin/pint                          : PASS (v1.22.1)
vendor/bin/rector process                : [OK] (v2.0.16)
vendor/bin/phpcs -p --standard=phpcs.xml : [OK] (v3.13.0)

235 files refactorized / 386

pint.json rule note:
OK for views (Miss indents)    "statement_indentation": false,
No for views (OK other)        "statement_indentation": true,
Multibyte convert by pint make error when decrypt old Secret key

In settings page: Stripe Enabled SK error (same for Paypal)

---

A PHP Error was encountered Severity: Warning

Message: openssl_decrypt(): IV passed is 20 bytes long which is longer
than the 16 expected by selected cipher, truncating

Filename: libraries/Cryptor.php Line Number: 189

Backtrace:

File: application/libraries/Cryptor.php Line: 189
Function: openssl_decrypt

File: application/libraries/Cryptor.php Line: 103
Function: decryptString

File: application/libraries/Crypt.php Line: 74
Function: Decrypt

...
Improvements:
`format_client` show custom value
`ClientTitleEnum` in lib & always loaded
& Minimal to activate eInvoice is user_tax_code

Warnings:
- Undefined array key 0
- Attempt to read property "item_tax_rate_percent" on null
partial_item_table to itemlist...
```
Message: Class "FPDI" not found

Filename: application/helpers/pdf_helper.php Line Number: 218

Backtrace:

File: application/modules/invoices/controllers/Invoices.php Line: 306
Function: generate_invoice_sumex
```
**Be careful**:
Show sumex settings panel when 'sumex' != 0 in db before this.
If set sumex to No. After save settings, the panel never show.

Todo:
Improve lib like eInvoice | Remove it if unused by anyone.

**Need Sumex?** (& Settings panel):
- Set SUMEX_SETTINGS=true in ipconfig.php
- Improve and/or finish libraries/Sumex.php
- Add invoice_template/(pdf&public) to be same as
https://cloud.githubusercontent.com/assets/4939519/23583357/a5b28e06-0142-11e7-9273-4d63b38eb422.png
- - Note: Replace $item->item_description by $item->item_date

---

Initiated by @denysvitali on #453 & (IMHO) never finished
See #453
To reproduce:
Click on `add products` btn, select one(s) & sumbit or cancel or X
Make Ctrl+s, don't save invoice
- If previously item(s) select, make Ctrl+s add item(s) line
- If previously nothing selected, make Ctrl+s do nothing

Explanation:
The modal is present in DOM but not displayed
Imp: Only post to server if item exist on db (& Fix 403)
Fix: Delete item not call check_items_tax_usages
Add edit links
Some idents
Sumex:
- OFF (hide missing)
- dashboard link lang
** Now you can leave empty the custom client title field **

Fixes:
- tryFrom: strict compare: array_search return 0 (key) for 'mr' opt.

- When choose the "Custom" title option in selector and
save with client_title_custom with empty value.
The client_title is set to `custom` by default in db
Prevent (and simplify) InvoicePlane update usage
When `LEGACY_CALCULATION` option not (added manually) in ipconfig
The `legacy_calculation` is false & hide `Add global taxes` menu
* Setup upgrade 1.6.3: Set all langs to lowercase

Why? see
#1230 (comment)

* Fix IP search bad user_language file on login (after setup)

Get an error like:
Unable to load the requested language file: language/French/ip_lang.php

Reason:
When user are logged in before call & complete setup,
On next login, session return old params.

Need destroy session to be set by new params from database
(Here for langs)

* [IP-939]: Processing e-invoices flow (and some bugfixes): `development` branch for version 1.6.3 (#1247)

Prepare for 1.6.3 and 1.7.0

---------

Co-authored-by: Thomas Ingles <[email protected]>

---------

Co-authored-by: Niels Drost <[email protected]>
@nielsdrost7 nielsdrost7 changed the base branch from development-v163 to develop-v163rc1 May 19, 2025 08:42
@nielsdrost7 nielsdrost7 changed the base branch from develop-v163rc1 to develop-163rc1 May 19, 2025 08:42
@nielsdrost7 nielsdrost7 deleted the revert-1232-development-setup-lowercase-languages branch May 19, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants