Skip to content
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

Save document issue local date #441

Merged
merged 4 commits into from
Jun 7, 2023
Merged

Conversation

thenmaster
Copy link
Member

No description provided.

Nuno Goncalves added 2 commits June 6, 2023 11:21
This will replace the current date field that is used for showing the
emission date in generated pdfs and SAFT report generation for the PT
module specifically

This just adds the field to the entity and makes it accessible for the
pdf generation. Currently fallsback to the existing date field in case
of no local date value to avoid any problems with upgrading/migrating
old data
not the current date

This should avoid some weird edge cases for daylight savings months
Unlike the export data, there is no fallback tothe current date column
since we are querying the data directly from the database and adding a
fallback would most likly come with a large performance penalty in an
already slow process
Also cleanup some unused code from the latest SAFT version generator to
facilitate reading and analysis
QJPAPTReceiptInvoiceEntity invoice = QJPAPTReceiptInvoiceEntity.jPAPTReceiptInvoiceEntity;

JPAQuery<PTReceiptInvoiceEntity> query = this.createQuery();

query.from(invoice)
.where(invoice.instanceOf(JPAPTReceiptInvoiceEntity.class).and(invoice.date.between(from, to))
.where(invoice.instanceOf(JPAPTReceiptInvoiceEntity.class).and(invoice.localDate.between(from, to))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a reminder to ensure the release notes include this constraint regarding SAFT

@@ -127,6 +126,9 @@ protected <D extends AbstractDAOPTGenericInvoice<T>> T issue(final T document, f
+ " does not have a series unique code specified"))
.toString();

ZoneId timezone = document.getBusiness().getTimezone();
LocalDate issueLocalDate = document.getLocalDate().orElse(LocalDate.ofInstant(invoiceDate.toInstant(), timezone));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw exception in these handlers when localDate is null (e.g. DocumentIssuingException)
Do the same for all country handlers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per a discussion done in person, the agreed upon approach will be to remove the mandatory check in the generic invoice builder. That will make it so that the field isn't mandatory so we will fill it in with the current local date for the business that is issuing the invoice if no value is provided by the user

Copy link
Contributor

@Vasco-F Vasco-F left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments regarding requirement of the localDate Field in generic documents handlers

Since we want to provide a default value as we do for the current date
field, it make no sense to make this field mandatory
@thenmaster thenmaster merged commit bd63236 into master Jun 7, 2023
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