DeliveryService: Fix duplicate LsNr error
All checks were successful
Test / Run tests (push) Successful in 1m49s

This commit is contained in:
2024-09-21 22:03:53 +02:00
parent 165770fa37
commit 5c12dba125

View File

@ -444,6 +444,7 @@ namespace Elwig.Services {
var date = DateOnly.ParseExact(vm.Date!, "dd.MM.yyyy"); var date = DateOnly.ParseExact(vm.Date!, "dd.MM.yyyy");
int? newLnr = (deliveryNew || dateHasChanged) ? await ctx.NextLNr(date) : null; int? newLnr = (deliveryNew || dateHasChanged) ? await ctx.NextLNr(date) : null;
string? newLsNr = (newLnr != null) ? Utils.GenerateLsNr(date, vm.Branch!.ZwstId, newLnr.Value) : null;
string? newTimeString = null; string? newTimeString = null;
if (partNew && timeIsDefault) { if (partNew && timeIsDefault) {
@ -459,7 +460,7 @@ namespace Elwig.Services {
TimeString = newTimeString ?? oldDelivery?.TimeString, TimeString = newTimeString ?? oldDelivery?.TimeString,
LNr = newLnr ?? oldDelivery!.LNr, LNr = newLnr ?? oldDelivery!.LNr,
ZwstId = vm.Branch!.ZwstId, ZwstId = vm.Branch!.ZwstId,
LsNr = vm.LsNr!, LsNr = newLsNr ?? vm.LsNr!,
MgNr = (int)vm.MgNr!, MgNr = (int)vm.MgNr!,
Comment = string.IsNullOrEmpty(vm.Comment) ? null : vm.Comment, Comment = string.IsNullOrEmpty(vm.Comment) ? null : vm.Comment,
}; };