-
Notifications
You must be signed in to change notification settings - Fork 11
HP-2883: Implement Business Central bills import service #114
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
573f51d
38f51dd
38ed9c9
e8a0032
e833bf2
a4ac782
b979df2
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 | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| <?php | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| declare(strict_types=1); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| namespace hiqdev\php\billing\bill; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| class BillReversesId | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| /** @var int|null */ | ||||||||||||||||||||||||||||||||||||||||||||||
| protected $id; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| public function __construct($id = null) | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| $this->id = $id; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| public function getId(): int | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| return $this->id; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The property is documented as Either make the return type nullable to match the property, or restrict the constructor so a 🐛 Option A — fix the return type to match the nullable property- public function getId(): int
+ public function getId(): ?int
{
return $this->id;
}🐛 Option B — restrict construction to the typed factory only- public function __construct($id = null)
+ private function __construct(int $id)
{
$this->id = $id;
}
public function getId(): int
{
return $this->id;
}With a private constructor, callers are forced through 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| public static function fromInt(int $id): self | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| return new self($id); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace hiqdev\php\billing\bill; | ||
|
|
||
| class BillSource | ||
| { | ||
| /** @var int|string|null */ | ||
| protected $id; | ||
|
|
||
| protected ?string $name = null; | ||
|
|
||
| public function __construct($id = null, ?string $name = null) | ||
| { | ||
| $this->id = $id; | ||
| $this->name = $name; | ||
| } | ||
|
|
||
| public function getId() | ||
| { | ||
| return $this->id; | ||
| } | ||
|
|
||
| public function getName(): ?string | ||
| { | ||
| return $this->name; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace hiqdev\php\billing\bill; | ||
|
|
||
| /** | ||
| * BillTxn | ||
| * | ||
| * Represents an immutable external payment transaction identifier. | ||
| * | ||
| * A TransactionId uniquely identifies a financial transaction | ||
| * as defined by an external payment or accounting system | ||
| * (e.g. Business Central, merchant gateways, banks). | ||
| * | ||
| * This value: | ||
| * - Is created by an external system, never generated internally | ||
| * - Is stable across retries, webhooks, and re-imports | ||
| * - Is used for idempotency and reconciliation | ||
| * - Has meaning outside of the database and application boundaries | ||
| * | ||
| * Uniqueness is guaranteed only within the scope of a source system | ||
| * (see Source / external system). | ||
| * | ||
| * Typical examples: | ||
| * - UUIDs | ||
| * - Gateway transaction references | ||
| * - Accounting document numbers | ||
| */ | ||
| class BillTxn | ||
| { | ||
| /** @var int|string|null */ | ||
| protected $value; | ||
|
|
||
| public function __construct($txn = null) | ||
| { | ||
| $this->value = $txn; | ||
| } | ||
|
|
||
| public function getValue() | ||
| { | ||
| return $this->value; | ||
| } | ||
|
|
||
| public static function fromString(string $txn): self | ||
| { | ||
| return new self($txn); | ||
| } | ||
| } |
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.
🛠️ Refactor suggestion | 🟠 Major
setReversesIdparameter is untyped — add?BillReversesIdhintThe
@param BillReversesId|nulldocblock documents the intended type, but the actual parameter declaration is untyped. This is inconsistent with the constructor signature (line 92:BillReversesId $reversesId = null) and silently accepts any value at runtime.♻️ Proposed fix
🤖 Prompt for AI Agents