Conversation
ert78gb
left a comment
There was a problem hiding this comment.
Thank you for your contribution I have a question and a change request. Please also extend the readme file with the new field. Please add the The invoice number of the down payment invoice can be defined here if the final bill of the down payment invoice can't be identified with the order number. If both invoice number and order number is present, order number takes precedent. note too. It is already in the szamlazz.hu documentation.
| if (this._options.prepaymentInvoiceNumber !== null && this._options.prepaymentInvoiceNumber !== undefined) { | ||
| assert(typeof this._options.prepaymentInvoiceNumber === 'string', '"prepaymentInvoiceNumber" should be a string') | ||
| assert(this._options.prepaymentInvoiceNumber.length > 0, '"prepaymentInvoiceNumber" should be minimum 1 character') | ||
| assert(this._options.finalInvoice === true, '"prepaymentInvoiceNumber" should only be set if "finalInvoice" is true') |
There was a problem hiding this comment.
Should we use this assert in the line 83 or just set the finalInvoice = true automatically when the prepaymentInvoiceNumber field has a value?
I think better to set finalInvoice = true automatically. It is more developer friendly.
Do you know anything that against it?
There was a problem hiding this comment.
I deliberately did not do this, because in this case finalInvoice is not a 'hidden' field (like adjustmentInvoice is), so I think it would be weird to change it without notice.
But if you think that is the better pattern, I can change ot of course.
There was a problem hiding this comment.
I made some API call to identify how it is working.
Case 1:
orderNumberis not providedprepaymentInvoiceNumberis not providedfinalInvoice: true
Error: A hivatkozott előlegszámla nem beazonosítható. Rendelésszám: nincs megadva, előlegszámla száma: nincs megadva.
Case 2:
orderNumber: '1223'Invoice with this order number has not been created beforeprepaymentInvoiceNumberis not providedfinalInvoice: true
Error: A hivatkozott előlegszámla nem beazonosítható. Rendelésszám: 1223, előlegszámla száma: nincs megadva.
Case 3:
orderNumberis not providedprepaymentInvoiceNumber: Test-01finalInvoice: true
Error: A hivatkozott előlegszámla nem beazonosítható. Rendelésszám: nincs megadva, előlegszámla száma: Test-01.
Case 4:
orderNumberis not providedprepaymentInvoiceNumber: Test-01finalInvoiceos not provided
Successfully created a new invoice.
Case 5:
orderNumber: C001prepaymentInvoiceNumber: Test-01finalInvoiceos not provided
Successfully created a new invoice.
Case 6:
orderNumber: C001prepaymentInvoiceNumber: Test-01finalInvoiceos not provided
Just tested could I create more invoices with same order number. Szamlazz.hu allows it every data is same, but if I modify anything the response is Már létező rendelésszám: C001. Az ismétlődés engedélyezhető a Beállítások oldalon.
Case 7:
orderNumber: C001prepaymentInvoiceNumberis not providedfinalInvoice: true
Error: A hivatkozott előlegszámla nem beazonosítható. Rendelésszám: C001, előlegszámla száma: nincs megadva.
Case 8:
orderNumberis not providedprepaymentInvoiceNumber: Test-02Invoice has been created in earlierfinalInvoice: true
Error: A hivatkozott előlegszámla nem beazonosítható. Rendelésszám: nincs megadva, előlegszámla száma: Test-02
Case 9:
orderNumber: C002prepaymentInvoiceNumberis not providedfinalInvoiceis not providedprepaymentInvoice: true
Successfully created a new pre-payment invoice.
Case 10:
orderNumber: C002prepaymentInvoiceNumberis not providedfinalInvoiceis not providedprepaymentInvoice: true
Not created new pre-invoice. Same as Case6
Case 11:
orderNumber: C002prepaymentInvoiceNumberis not providedfinalInvoiceis not providedprepaymentInvoiceis not provided
Created new a new invoice. It is surprising me.
Case 12:
orderNumber: C002prepaymentInvoiceNumberis not providedfinalInvoice: trueprepaymentInvoiceis not provided
Created a new final invoice
Case 13:
orderNumber: C002prepaymentInvoiceNumberis not providedfinalInvoice: trueprepaymentInvoiceis not provided
Error: A hivatkozott előlegszámla nem beazonosítható. Rendelésszám: C002, előlegszámla száma: nincs megadva.
Based on these tests
-
szamlazz.hu differensiate 3 invoice type (
alap.tipuselement in the invoice query xml)SZ=> standard invoiceES=> pre-invoiceVS=> final invoice
-
orderNumberis an optional field -
To create a final invoice have to provide the
orderNumberthe invoice number of the pre-invoiceprepaymentInvoiceNumber. Please add this validation to the PR. -
Does not matter do we provide the
prepaymentInvoiceNumberwhen we create a standard or pre-invoice. After that I agree with you keep the current validation.
|
@ert78gb By accident I commited a small change here that I didn't mean to. It fixes the order of 2 fields in the buyer xml. Should I revert the commit here and open another PR for it (as I planned), or can it remain here since it is a small change? Ps.: I did not had time to resolve the review stuff yet, but still plan to do it. |
|
I am thinking on finish your PR because it is valuable but I am also sort on time. regarding to the |
This PR adds support for creating final invoices.
It introduces two new fields to the Invoice class:
finalInvoice: bool - it indicates whether the invoice is a final invoiceprepaymentInvoiceNumber: string - not always needed, but contains theinvoiceIdof the prepayment invoice to which this final invoice belongsSince
prepaymentInvoiceNumberis not required for creating a final invoice (at least according to the documentation), I did not use the pattern what theadjustmentInvoiceNumberfield is doing (hiding theadjustmentInvoicefield behind it).