Repository navigation
feat(donations): import donations from a Business Central export - #100
Conversation
| continue; | ||
| } | ||
|
|
||
| occurrences[code] = occurrences.GetValueOrDefault(code) + 1; |
There was a problem hiding this comment.
The real export has no N° ligne column, so the key of a line is {code}#{n}. But n only counts the lines that passed the checks. If a Poivron line is rejected (for example, missing quality) and then fixed in BC, every Poivron line after it moves by one on the next import. The fixed line is then skipped as "already imported" and another line is imported a second time. I'll fix it by counting the position on every row with that code, before the checks.
| return Error(line, DonationImportErrorCode.InactiveCatalogItem, $"The Business Central item {line.ItemCode} is matched to {catalogItem.Name}, which is no longer in the price grid. Review its mapping."); | ||
| } | ||
|
|
||
| if (!string.Equals(line.Unit.Trim(), catalogItem.Unit.Trim(), StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
Prices are per kg (#28), but the export lines are in CA. This check compares the line unit with the catalog item unit, not with the unit of the price. So 48 CA times a price per kg passes, and the value on the receipt is wrong. I'll fix it by rejecting lines that are not in kg until we know how to convert a case.
The position in the fallback key only counted rows that passed the checks. Fixing a rejected row shifted the key of every later row of the same item, so one line was skipped as already imported and another was imported twice.
Prices are per kg (#28), but the unit check only compared the line with the catalog item, so a line in CA was valued with a price per kg. Such lines are now rejected with UnitMismatch until we know how to turn a case into kg.
… migration after develop's
Closes #77
Overview
Imports donations from a Business Central purchase order export.
Lignessheet. Every invalid row is reported with its row number, an error code and a message, and the valid rows are still imported.AddDonationImportsmigration, its SQL script, the format documentation and an anonymized sample file.Testing
Checklist
Notes
dotnet ef database update --project src/MoissonMontreal.Apilocally.