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
6 changes: 3 additions & 3 deletions Deeplex.Saverwalter.WebAPI/Controllers/ZaehlerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ZaehlerEntryBase
public int Id { get; set; }
public string Kennnummer { get; set; } = null!;
public SelectionEntry Typ { get; set; } = null!;
public AdresseEntryBase? Adresse { get; set; }
public SelectionEntry? Wohnung { get; set; }
public ZaehlerstandEntryBase? LastZaehlerstand { get; set; }
public DateOnly? Ende { get; set; }
Expand All @@ -48,9 +49,10 @@ public ZaehlerEntryBase(Zaehler entity, Permissions permissions)
Entity = entity;

Id = entity.ZaehlerId;
Adresse = entity.Adresse is Adresse a ? new AdresseEntryBase(a, permissions) : null;
Kennnummer = entity.Kennnummer;
Typ = new((int)entity.Typ, entity.Typ.ToString());
Wohnung = entity.Wohnung is Wohnung w ? new(w.WohnungId, $"{w.Adresse?.Anschrift ?? "Unbekannte Anschrift"}, {w.Bezeichnung}") : null;
Wohnung = entity.Wohnung is Wohnung w ? new(w.WohnungId, w.Bezeichnung) : null;
var letzterStand = entity.Staende?.OrderBy(s => s.Datum).ToList().LastOrDefault();
Ende = entity.Ende;
if (letzterStand is Zaehlerstand stand)
Expand All @@ -66,7 +68,6 @@ public class ZaehlerEntry : ZaehlerEntryBase
{
public string? Notiz { get; set; }
public IEnumerable<SelectionEntry>? SelectedUmlagen { get; set; }
public AdresseEntryBase? Adresse { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime LastModified { get; set; }

Expand All @@ -76,7 +77,6 @@ public class ZaehlerEntry : ZaehlerEntryBase
public ZaehlerEntry() : base() { }
public ZaehlerEntry(Zaehler entity, Permissions permissions) : base(entity, permissions)
{
Adresse = entity.Adresse is Adresse a ? new AdresseEntryBase(a, permissions) : null;
SelectedUmlagen = entity.Umlagen.ToList()
.Select(e => new SelectionEntry(e.UmlageId, e.Typ.Bezeichnung + " - " + e.GetWohnungenBezeichnung()));

Expand Down
23 changes: 21 additions & 2 deletions Deeplex.Saverwalter.WebAPI/Services/PermissionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,24 @@ protected override Task HandleRequirementAsync(
OperationAuthorizationRequirement requirement,
Zaehlerstand entity)
{
return HandleWohnungSubRequirementAsync(context, requirement, entity.Zaehler.Wohnung!);
if (entity.Zaehler.Wohnung != null)
{
return HandleWohnungSubRequirementAsync(context, requirement, entity.Zaehler.Wohnung);
}
if (entity.Zaehler.Adresse == null || entity.Zaehler.Adresse.Wohnungen.Count == 0)
{
context.Succeed(requirement);
return Task.CompletedTask;
}
else
{
foreach (var wohnung in entity.Zaehler.Adresse.Wohnungen.ToList())
{
HandleWohnungSubRequirementAsync(context, requirement, wohnung);
}

return Task.CompletedTask;
}
}
}

Expand Down Expand Up @@ -482,6 +499,8 @@ protected Task HandleWohnungSubRequirementAsync(AuthorizationHandlerContext cont
}

protected static bool IsAuthorized(Guid userId, Wohnung wohnung, VerwalterRolle rolle)
=> wohnung.Verwalter.Count > 0 && wohnung.Verwalter.AsQueryable().Any(Utils.HasRequiredAuth(rolle, userId));
=> wohnung != null &&
wohnung.Verwalter.Count > 0 &&
wohnung.Verwalter.AsQueryable().Any(Utils.HasRequiredAuth(rolle, userId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

<Row>
<TextInput
placeholder="Wird aus Vertragsversion genommen"
placeholder="Wird aus Nachtrag genommen"
required
readonly
value={entry.beginn && convertDateGerman(new Date(entry.beginn))}
labelText="Beginn (aus Vertragsversion)"
labelText="Beginn (aus Nachtrag)"
/>
<WalterDatePicker
disabled={readonly}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
if (searchParams) {
if (searchQuery) {
searchParams.set('search', searchQuery);
window.history.replaceState(
{},
'',
`?${searchParams.toString()}`
);
window.history.replaceState({}, '', `?${searchParams.toString()}`);
} else {
searchParams.delete('search');
window.history.replaceState(
Expand Down Expand Up @@ -161,8 +157,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
style="right: -1em; position: sticky;"
on:click={add}
iconDescription="Eintrag hinzufügen"
icon={Add}>Eintrag hinzufügen</Button
>
icon={Add}>
Eintrag hinzufügen
</Button>
{/if}
</ToolbarContent>
</Toolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

function close() {
addModalOpen = false;
addEntry = {};
changeTracker.set(tracker);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

const headers = [
{ key: 'kennnummer', value: 'Kennnummer' },
{ key: 'adresse.anschrift', value: 'Adresse'},
{ key: 'wohnung.text', value: 'Wohnung' },
{ key: 'typ.text', value: 'Typ' },
{ key: 'lastZaehlerstand.datum', value: 'Letztes Ablesedatum' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
/>
<WalterVertragVersionen
entry={vertragversionEntry}
title="Versionen:"
title="Nachträge"
rows={data.entry.versionen}
/>
<WalterMieten
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

<WalterGrid>
<WalterVertrag fetchImpl={data.fetchImpl} {entry} />
<Tile light>Vertragsversion:</Tile>
<Tile light>Nachtrag:</Tile>
<WalterVertragVersion entry={entryVersion} />
</WalterGrid>
Loading