91 lines
3.8 KiB
C#
91 lines
3.8 KiB
C#
using Elwig.Models;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Elwig.Helpers {
|
|
public class ClientParameters {
|
|
|
|
public enum Type { Matzen, GWK };
|
|
|
|
public bool IsMatzen => Client == Type.Matzen;
|
|
public bool IsGWK => Client == Type.GWK;
|
|
|
|
public string NameToken;
|
|
public string NameShort;
|
|
public string Name;
|
|
public string? NameSuffix;
|
|
public string NameType;
|
|
public string NameFull => NameSuffix == null ? $"{Name} {NameType}" : $"{Name}, {NameSuffix}, {NameType}";
|
|
public Type? Client;
|
|
|
|
public PostalDest PostalDest {
|
|
set {
|
|
Plz = value.AtPlz.Plz;
|
|
Ort = value.AtPlz.Ort.Name;
|
|
}
|
|
}
|
|
public int Plz { get; private set; }
|
|
public string Ort { get; private set; }
|
|
public string Address;
|
|
public string Sender1 => $"{NameShort} | {Address} | {Plz} {Ort}";
|
|
public string Sender2;
|
|
|
|
public string? Iban;
|
|
public string? Bic;
|
|
public string? UstIdNr;
|
|
public string? LfbisNr;
|
|
|
|
public string? PhoneNr;
|
|
public string? FaxNr;
|
|
public string? EmailAddress;
|
|
public string? Website;
|
|
|
|
public int DeliveryObligation;
|
|
public int DeliveryRight;
|
|
public decimal VatNormal;
|
|
public decimal VatReduced;
|
|
public decimal VatFlatRate;
|
|
|
|
public string? TextDeliveryNote;
|
|
|
|
public ClientParameters(AppDbContext ctx) : this(ctx.ClientParameters.ToDictionary(e => e.Param, e => e.Value)) { }
|
|
|
|
public ClientParameters(Dictionary<string, string?> parameters) {
|
|
try {
|
|
NameToken = parameters["CLIENT_NAME_TOKEN"] ?? throw new KeyNotFoundException();
|
|
NameShort = parameters["CLIENT_NAME_SHORT"] ?? throw new KeyNotFoundException();
|
|
Name = parameters["CLIENT_NAME"] ?? throw new KeyNotFoundException();
|
|
NameSuffix = parameters.GetValueOrDefault("CLIENT_NAME_SUFFIX");
|
|
NameType = parameters["CLIENT_NAME_TYPE"] ?? throw new KeyNotFoundException();
|
|
switch (Name) {
|
|
case "Winzergenossenschaft für Matzen und Umgebung": Client = Type.Matzen; break;
|
|
case "Winzerkeller im Weinviertel": Client = Type.GWK; break;
|
|
};
|
|
|
|
Plz = int.Parse(parameters["CLIENT_PLZ"] ?? "");
|
|
Ort = parameters["CLIENT_ORT"] ?? throw new KeyNotFoundException();
|
|
Address = parameters["CLIENT_ADDRESS"] ?? throw new KeyNotFoundException();
|
|
PhoneNr = parameters.GetValueOrDefault("CLIENT_PHONE");
|
|
FaxNr = parameters.GetValueOrDefault("CLIENT_FAX");
|
|
EmailAddress = parameters.GetValueOrDefault("CLIENT_EMAIL");
|
|
Website = parameters.GetValueOrDefault("CLIENT_WEBSITE");
|
|
LfbisNr = parameters.GetValueOrDefault("CLIENT_LFBISNR");
|
|
UstIdNr = parameters.GetValueOrDefault("CLIENT_USTIDNR");
|
|
Bic = parameters.GetValueOrDefault("CLIENT_BIC");
|
|
Iban = parameters.GetValueOrDefault("CLIENT_IBAN");
|
|
Sender2 = parameters.GetValueOrDefault("DOCUMENT_SENDER") ?? "";
|
|
|
|
DeliveryObligation = int.Parse(parameters["DELIVERY_OBLIGATION"] ?? "");
|
|
DeliveryRight = int.Parse(parameters["DELIVERY_RIGHT"] ?? "");
|
|
VatNormal = decimal.Parse(parameters["VAT_NORMAL"] ?? "");
|
|
VatReduced = decimal.Parse(parameters["VAT_REDUCED"] ?? "");
|
|
VatFlatRate = decimal.Parse(parameters["VAT_FLATRATE"] ?? "");
|
|
|
|
TextDeliveryNote = parameters.GetValueOrDefault("TEXT_DELIVERY_NOTE");
|
|
} catch {
|
|
throw new KeyNotFoundException();
|
|
}
|
|
}
|
|
}
|
|
}
|