-
Notifications
You must be signed in to change notification settings - Fork 29
Option to send corrections #44
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,13 @@ class InvoiceSubmission extends InvoiceRecord | |
| */ | ||
| private $rectificationData = []; | ||
|
|
||
| /** | ||
| * Identifies if a submission is to subsanate a previous one accepted with errors | ||
| * | ||
| * @var YesNoType|null | ||
| */ | ||
| public $isCorrection; | ||
|
Comment on lines
+56
to
+61
|
||
|
|
||
| /** | ||
| * Invoice type (TipoFactura). | ||
| * @var InvoiceType | ||
|
|
@@ -442,6 +449,13 @@ public function rules(): array | |
|
|
||
| return ($value instanceof YesNoType) ? true : 'Must be an instance of YesNoType.'; | ||
| }], | ||
| ['isCorrection', function ($value): bool|string { | ||
| if ($value === null) { | ||
| return true; | ||
| } | ||
|
|
||
| return ($value instanceof YesNoType) ? true : 'Must be an instance of YesNoType.'; | ||
| }], | ||
| ['invoiceWithoutRecipient', function ($value): bool|string { | ||
| if ($value === null) { | ||
| return true; | ||
|
|
@@ -557,7 +571,7 @@ public function rules(): array | |
|
|
||
| /** | ||
| * Deprecated: Use InvoiceSerializer::toInvoiceXml() instead. | ||
| * | ||
| * | ||
| * @deprecated This method has been replaced by InvoiceSerializer::toInvoiceXml() | ||
| * @return \DOMDocument | ||
| * @throws \Exception | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||||||||||||||||||||||||||||||
| use eseperio\verifactu\models\Breakdown; | ||||||||||||||||||||||||||||||||||
| use eseperio\verifactu\models\BreakdownDetail; | ||||||||||||||||||||||||||||||||||
| use eseperio\verifactu\models\ComputerSystem; | ||||||||||||||||||||||||||||||||||
| use eseperio\verifactu\models\enums\YesNoType; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| use eseperio\verifactu\models\enums\YesNoType; |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block uses tabs and is missing spaces after if/before {, which is inconsistent with the surrounding style in this file (spaces indentation + if (...) {). Reformat to match the existing code style to keep diffs consistent and avoid formatter churn.
| // Subsanacion (optional) | |
| if($invoice->isCorrection) { | |
| $root->appendChild($doc->createElementNS(self::SF_NAMESPACE, 'sf:Subsanacion', (string) $invoice->isCorrection->value)); | |
| } | |
| // Subsanacion (optional) | |
| if ($invoice->isCorrection) { | |
| $root->appendChild($doc->createElementNS(self::SF_NAMESPACE, 'sf:Subsanacion', (string) $invoice->isCorrection->value)); | |
| } |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($invoice->isCorrection) is effectively a null-check because YesNoType::NO is still truthy (it’s an enum object). That means Subsanacion will be emitted for both YES and NO whenever the property is set, which may not match the intended “only send for corrections” behavior. Make the intent explicit by checking !== null (emit both YES/NO) or comparing to YesNoType::YES (emit only for corrections).
| // Subsanacion (optional) | |
| if($invoice->isCorrection) { | |
| $root->appendChild($doc->createElementNS(self::SF_NAMESPACE, 'sf:Subsanacion', (string) $invoice->isCorrection->value)); | |
| } | |
| // Subsanacion (optional) | |
| if ($invoice->isCorrection === YesNoType::YES) { | |
| $root->appendChild($doc->createElementNS(self::SF_NAMESPACE, 'sf:Subsanacion', (string) $invoice->isCorrection->value)); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,10 @@ public function testToInvoiceXml(): void | |||||||||||
| $this->assertEquals(1, $nombreRazon->length); | ||||||||||||
| $this->assertEquals('Test Company', $nombreRazon->item(0)->textContent); | ||||||||||||
|
|
||||||||||||
| // Verify subsanation is not present | ||||||||||||
| $correction = $dom->getElementsByTagNameNS(InvoiceSerializer::SF_NAMESPACE, 'Subsanacion'); | ||||||||||||
|
Comment on lines
+59
to
+60
|
||||||||||||
| // Verify subsanation is not present | |
| $correction = $dom->getElementsByTagNameNS(InvoiceSerializer::SF_NAMESPACE, 'Subsanacion'); | |
| // Verify subsanation element is present and defaults to NO | |
| $correction = $dom->getElementsByTagNameNS(InvoiceSerializer::SF_NAMESPACE, 'Subsanacion'); | |
| $this->assertEquals(1, $correction->length); |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test method is inconsistent with the rest of the file: it lacks a : void return type, doesn’t assert the NodeList length before reading item(0), and the name/comment use “Subsanation” while the XML element is Subsanacion. Align the naming, add : void, and assert $subsanation->length === 1 before reading item(0) to avoid null dereferences.
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createBasicInvoiceSubmission() now always sets $invoice->isCorrection = YesNoType::NO;. If the intention is that Subsanacion is optional and omitted unless explicitly requested, this should be left as null here so the “default invoice” path doesn’t force emission of the node.
| $invoice->isCorrection = YesNoType::NO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README example sets
isCorrectionto a boolean (true), but the model expects aYesNoType(and validation enforces that). Update the example to useYesNoType::YES(and optionally shownull/unset for the default).