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

Small problems at using #65

Closed
ralfdreibrodt opened this issue Jan 3, 2025 · 9 comments · Fixed by #67 or #68
Closed

Small problems at using #65

ralfdreibrodt opened this issue Jan 3, 2025 · 9 comments · Fixed by #67 or #68
Assignees

Comments

@ralfdreibrodt
Copy link

I had three problems during installation and creating my first invoice:
a) "Full-Fledged Example" from README:

$ curl -v -X POST
http://localhost:3000/api/invoice/transform-and-create/UBL
-F lang=de
-F mapping=@contrib/mappings/default-invoice.yaml \

In line three the backslash is missing

b) https://www.guido-flohr.net/creating-electronic-invoices-with-free-and-open-source-software/
This will create a directory dist that you can copy wherever you like.
Whenever I move the dist directory, I get an error:

node:internal/modules/cjs/loader:1137
throw err;
^

Error: Cannot find module '@esgettext/runtime'
Require stack:

  • /var/www/dist/src/main.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object. (/var/www/dist/src/main.js:3:19)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/var/www/dist/src/main.js' ]
    }

Node.js v18.19.0

Without moving dist it is working, until:
c) changing the format to Factur-X-XRechnung
The software is crashing:

/var/www/e-invoice-eu-main/dist/src/format/format-factur-x.service.js:239
const hash = await crypto.subtle.digest('SHA-512', encoder.encode(data));
^

ReferenceError: crypto is not defined
at FormatFacturXXRechnungService.setTrailerInfoID (/var/www/e-invoice-eu-main/dist/src/format/format-factur-x.service.js:239:22)
at FormatFacturXXRechnungService.createPDFA (/var/www/e-invoice-eu-main/dist/src/format/format-factur-x.service.js:172:14)
at FormatFacturXXRechnungService.generate (/var/www/e-invoice-eu-main/dist/src/format/format-factur-x.service.js:88:20)
at async InvoiceController.create (/var/www/e-invoice-eu-main/dist/src/invoice/invoice.controller.js:52:30)

Node.js v18.19.0

After googling the error message, I added before the above line 239 this:
const crypto = require('crypto');
Now the software is not crashing anymore and the validator says everthing is correct, but I have no idea, whether that's true.

@gflohr gflohr self-assigned this Jan 3, 2025
@gflohr
Copy link
Owner

gflohr commented Jan 3, 2025

About the validation, please read this documentation: https://github.com/gflohr/e-invoice-eu/blob/main/contrib/validators/README.md You should definitely validate your invoices before sending them. It is very unlikely that they are correct from the beginning.

I will take care of the other two problems next week. I am currently travelling.

gflohr added a commit that referenced this issue Jan 3, 2025
add missing backslash

See #65, issue a), thanks to @ralfdreibrodt.
@gflohr gflohr mentioned this issue Jan 3, 2025
@gflohr
Copy link
Owner

gflohr commented Jan 3, 2025

Until I fix the other two issues, you may consider to use the containerized version on dockerhub.

@gflohr
Copy link
Owner

gflohr commented Jan 7, 2025

I had three problems during installation and creating my first invoice: a) "Full-Fledged Example" from README:

$ curl -v -X POST
http://localhost:3000/api/invoice/transform-and-create/UBL
-F lang=de
-F mapping=@contrib/mappings/default-invoice.yaml \

In line three the backslash is missing

Fixed.

@gflohr
Copy link
Owner

gflohr commented Jan 7, 2025

b) https://www.guido-flohr.net/creating-electronic-invoices-with-free-and-open-source-software/ This will create a directory dist that you can copy wherever you like. Whenever I move the dist directory, I get an error:

Sorry, my bad, you can not move the directory.

gflohr added a commit that referenced this issue Jan 7, 2025
Possible fix for #65 part c.
@gflohr gflohr linked a pull request Jan 7, 2025 that will close this issue
@gflohr gflohr closed this as completed in #67 Jan 7, 2025
@gflohr
Copy link
Owner

gflohr commented Jan 7, 2025

I cannot reproduce the reference error for crypto but I have tried to fix it. Can you update to the latest commit and try again?

@gflohr gflohr reopened this Jan 7, 2025
@ralfdreibrodt
Copy link
Author

Thank you for your changes. The documentation is now correct.

I cannot reproduce the reference error for crypto but I have tried to fix it.
Can you update to the latest commit and try again?

It still does not work, but the error message changed. Btw this is a Debian 12.

[Nest] 899611 - 01/08/2025, 1:32:45 PM LOG [Request] POST /api/invoice/create/Factur-X-XRechnung 201 - 171ms
/var/www/e-invoice-eu-main/dist/format/format-factur-x.service.js:240
const hash = await crypto_1.default.subtle.digest('SHA-512', encoder.encode(data));
^

TypeError: Cannot read properties of undefined (reading 'subtle')
at FormatFacturXXRechnungService.setTrailerInfoID (/var/www/e-invoice-eu-main/dist/format/format-factur-x.service.js:240:45)
at FormatFacturXXRechnungService.createPDFA (/var/www/e-invoice-eu-main/dist/format/format-factur-x.service.js:173:14)
at FormatFacturXXRechnungService.generate (/var/www/e-invoice-eu-main/dist/format/format-factur-x.service.js:89:20)
at async InvoiceController.create (/var/www/e-invoice-eu-main/dist/invoice/invoice.controller.js:52:30)

Node.js v18.19.0

@gflohr
Copy link
Owner

gflohr commented Jan 8, 2025

I could reproduce the issue with node 18. It should now work with node 18, 20, and 22.

Can you try again?

@gflohr gflohr reopened this Jan 8, 2025
@ralfdreibrodt
Copy link
Author

Thank you, it is working now!

@gflohr
Copy link
Owner

gflohr commented Jan 8, 2025

Thank you for reporting the problems!

@gflohr gflohr closed this as completed Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants