Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libPosSystemAPI/DTO/PayItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace fiskaltrust.DevKit.POSSystemAPI.lib.DTO
public class PayItem
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string ftPayItemId { get; set; } = string.Empty;
public string? ftPayItemId { get; set; } = string.Empty;
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The ftPayItemId property is now declared as string? but the initializer is still = string.Empty. Since [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] only omits a property when its value equals the type's default (null for reference types), an instance of PayItem where ftPayItemId is never set will still serialize the property as "" — not omit it. This defeats the purpose of the change, because any PayItem that isn't processed through the ReceiptRequest constructor (e.g. deserialized from JSON and re-serialized, or directly constructed outside of ReceiptRequest) will still emit "ftPayItemId": "" in the JSON payload.

The default initializer should be changed from = string.Empty to = null (or simply removed, since null is already the implicit default for string?), so that the [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] attribute works correctly and the property is omitted from serialization when no ID is assigned.

Suggested change
public string? ftPayItemId { get; set; } = string.Empty;
public string? ftPayItemId { get; set; }

Copilot uses AI. Check for mistakes.

public string Description { get; set; } = string.Empty;
public decimal Amount { get; set; }
Expand Down
8 changes: 8 additions & 0 deletions libPosSystemAPI/DTO/ReceiptRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public ReceiptRequest(string cbReceiptReference, ReceiptCaseBuilder buildableRec
{
this.cbReceiptReference = cbReceiptReference;
this.cbChargeItems = cbChargeItems;
// verify that empty ftPayItemIDs are null
foreach (var payItem in cbPayItems)
{
if (payItem.ftPayItemId == "")
{
payItem.ftPayItemId = null;
}
}
Comment on lines +27 to +34
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The normalization loop in the constructor mutates the PayItem objects in the caller-provided cbPayItems list in-place (setting ftPayItemId = null on the original objects). This is an unexpected side effect: callers may not expect that passing their list into the ReceiptRequest constructor will modify their PayItem objects. If the root issue (see PayItem.cs line 9) is fixed by changing the default initializer to null, then this normalization loop would become unnecessary and could be removed entirely.

Suggested change
// verify that empty ftPayItemIDs are null
foreach (var payItem in cbPayItems)
{
if (payItem.ftPayItemId == "")
{
payItem.ftPayItemId = null;
}
}

Copilot uses AI. Check for mistakes.
this.cbPayItems = cbPayItems;
this.ftReceiptCase = buildableReceiptCase.Build();
}
Expand Down