diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index a51f72198..65d14c7a1 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -399,6 +399,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -1316,6 +1320,9 @@ CustomerVermittlungArbeitControl.xaml + + ColorPicker.xaml + CustomerWohnhilfeControl.xaml diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index 8aaf8253d..ffa0e051a 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -649,6 +649,11 @@ namespace BeWo AppSettings.ShowInfoButtonInCalender = showInfoButtonInCalender; BS.Shared.Settings.ApplicationSettings.SupportConceptExpirationLimitInMonths = AppSettings.HilfeplanAuslaufAuswahl; + + if(MainControl is object) + { + MainControl.UpdateMandator(); + } } } @@ -1300,12 +1305,17 @@ namespace BeWo foreach (var blubb in openWindowCollection) { var abc = (Window)blubb; + var title = abc.Title; - if (!abc.Title.Equals("BeWoPlaner") && blubb.GetType() == typeof(WindowContentHolder)) + if (!title.Equals("BeWoPlaner") && blubb.GetType() == typeof(WindowContentHolder)) { abc.Close(); } - else if (abc.Title.IndexOf("Popup") >= 0) + else if (title.IndexOf("Popup") >= 0) + { + abc.Close(); + } + else if (title.IndexOf("Druckvorschau") >= 0) { abc.Close(); } diff --git a/BeWo/Converter/UserPermission2BoolConverter.cs b/BeWo/Converter/UserPermission2BoolConverter.cs index e61ade63d..cf5c73043 100644 --- a/BeWo/Converter/UserPermission2BoolConverter.cs +++ b/BeWo/Converter/UserPermission2BoolConverter.cs @@ -30,6 +30,12 @@ namespace BeWo.Converter { if (setting == SettingsKeys.AllowGkvAbrechnung) return BeWoApp.AppSettings.AllowGkvAbrechnung; + + if (setting == SettingsKeys.ShowGkvBzEinzel) + return BeWoApp.Mandator.ShowGkvBzEinzel; + + if (setting == SettingsKeys.ShowGkvBzUrbelege) + return BeWoApp.Mandator.ShowGkvBzUrbelege; } } catch (Exception) diff --git a/BeWo/DebugConfig.cs b/BeWo/DebugConfig.cs index 668901304..7facbb6e1 100644 --- a/BeWo/DebugConfig.cs +++ b/BeWo/DebugConfig.cs @@ -122,12 +122,12 @@ namespace BeWo new DebugConfig() { DebugConfigMode = DebugConfigMode.FeatureDakota, - AutoLogin = true, - SelectView = UIContext.Finance, + AutoLogin = false, + SelectView = UIContext.Administration, SelectIndex = 8, - //Username = "m1", - //Password = "bewobewo", - //Profilename = "5000000000" + Username = "m1", + Password = "bewobewo", + Profilename = "5000000000" }); return name2config; diff --git a/BeWo/MainControl.xaml b/BeWo/MainControl.xaml index 3aeae28f1..de5241718 100644 --- a/BeWo/MainControl.xaml +++ b/BeWo/MainControl.xaml @@ -61,9 +61,9 @@ HorizontalAlignment="Stretch" Grid.IsSharedSizeScope="True"> - + - + @@ -71,8 +71,9 @@ - + + + + + + + + + + + + + + + + - + + + @@ -32,7 +36,8 @@ Grid.Row="0" Grid.Column="0" Margin="3" - VerticalAlignment="Center"> + VerticalAlignment="Center" + ToolTip="Wenn kein Ansprechpartner hinterlegt ist, so wird der aktuelle Benutzer als Ansprechpartner verwendet."> IK Nummer (Leistungserbringer) + + + + + + + + + + + + + + + + + + + + + + diff --git a/BeWo/ViewModel/GkvAbrechnungVM.cs b/BeWo/ViewModel/GkvAbrechnungVM.cs index da12532c1..7dc0c6bf0 100644 --- a/BeWo/ViewModel/GkvAbrechnungVM.cs +++ b/BeWo/ViewModel/GkvAbrechnungVM.cs @@ -342,10 +342,15 @@ namespace BeWo.ViewModel public bool IsFormularEnabled => LastTransferProtokoll is object; public GkvAbrechnungReportRequest ReportRequest - => new GkvAbrechnungReportRequest(DataContract.GkvAbrechnungOid.Value); + => new GkvAbrechnungReportRequest(DataContract.GkvAbrechnungOid.Value, false); public string ReportLink => BeWoApp.SiteOfOrigin + "/ReportView.aspx" + ReportRequest.GetUrlPathString(); + public GkvAbrechnungReportRequest ReportRequest2 + => new GkvAbrechnungReportRequest(DataContract.GkvAbrechnungOid.Value, true); + public string ReportLink2 + => BeWoApp.SiteOfOrigin + "/ReportView.aspx" + ReportRequest2.GetUrlPathString(); + public void FirePropertyIsReady2CreateChanged() => FirePropertyChanged(nameof(IsReady2Create)); public bool IsReady2Create diff --git a/BeWo/ViewModel/ImageVM.cs b/BeWo/ViewModel/ImageVM.cs index 699861d94..069486cdb 100644 --- a/BeWo/ViewModel/ImageVM.cs +++ b/BeWo/ViewModel/ImageVM.cs @@ -14,8 +14,6 @@ namespace BeWo.ViewModel private byte[] _Original; private byte[] _MediumThumbnail; private byte[] _SmallThumbnail; - private BitmapImage _BitmapImage; - private ImageSource _ImageSource; public ImageVM() : this(new ImageDC()) { diff --git a/BeWo/ViewModel/InvoiceBaseVM.cs b/BeWo/ViewModel/InvoiceBaseVM.cs index ae32fe6a5..dda1041d1 100644 --- a/BeWo/ViewModel/InvoiceBaseVM.cs +++ b/BeWo/ViewModel/InvoiceBaseVM.cs @@ -9,11 +9,12 @@ using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.Extensions; +using BS.Shared.Interface; using BS.Shared.Translation; namespace BeWo.ViewModel { - public class InvoiceBaseVM : AbstractDCMapperVM + public class InvoiceBaseVM : AbstractDCMapperVM, IInvoiceBase { public static string PropertyName_AccountingPeriodEnd = "AccountingPeriodEnd"; @@ -116,85 +117,45 @@ namespace BeWo.ViewModel }; private DateTime? _AccountingPeriodEnd; - private DateTime? _AccountingPeriodStart; - private string _CreatorFirstName = string.Empty; - private string _CreatorLastName = string.Empty; - private string _CustomerReferenceNumber = string.Empty; - private DateTime? _DueDate; - private int? _DunningLetterCount; - private DateTime? _InvoiceDate; - private InvoiceItemListVM _InvoiceItems; - private string _InvoiceNumber = string.Empty; - private string _InvoiceTitle = string.Empty; - internal bool _IsReviewed; - internal bool _IsSent; - internal bool _IsExported; - internal bool _IsPaid; - private string _PartialPayment = string.Empty; - internal bool _NeuErstellen; - internal bool _DiffErstellen; - internal bool _IsChecked; - private string _Notice = string.Empty; - private long? _RecipientCostBearerOid; - private long? _RecipientCustomerOid; - private string _RecipientDivision = string.Empty; - private string _RecipientOrganisation = string.Empty; - private long? _RecipientOrganisationOid; - private String _RecipientPostBox; - private string _RecipientPersonFirstName = string.Empty; - private string _RecipientPersonLastName = string.Empty; - private long? _RecipientPersonOid; - private string _RecipientPostCode = string.Empty; - private string _RecipientAddressLine1 = string.Empty; - private string _RecipientStreet = string.Empty; - private string _RecipientTown = string.Empty; - private string _SenderDivision = string.Empty; - private string _SenderFax = string.Empty; - private string _SenderFirstName = string.Empty; - private string _SenderLastName = string.Empty; - private string _SenderOrganisation = string.Empty; - private string _SenderPhone = string.Empty; - private long? _SupportConceptOid; - private decimal? _TotalAmount; public InvoiceBaseVM(InvoiceBaseDC pDC) : this(pDC, false) { } @@ -922,6 +883,8 @@ namespace BeWo.ViewModel } } + public string SenderAddressLine1 { get; set; } + public decimal? TotalAmount { get { return _TotalAmount; } @@ -954,6 +917,10 @@ namespace BeWo.ViewModel get; set; } + public string SenderStreet => DataContract.SenderStreet; + public string SenderTown => DataContract.SenderTown; + public string SenderPostCode => DataContract.SenderPostCode; + protected override void InitByDataContract(InvoiceBaseDC pDataContract) { _SupportConceptOid = pDataContract.SupportConceptOid; diff --git a/BeWo/ViewModel/MandatorVM.cs b/BeWo/ViewModel/MandatorVM.cs index 30617d3d4..8c96e8997 100644 --- a/BeWo/ViewModel/MandatorVM.cs +++ b/BeWo/ViewModel/MandatorVM.cs @@ -7,6 +7,7 @@ using BS.Shared.Extensions; using BeWo.Core; using BS.Shared.Core; using BS.Shared.DataContracts.Compact; +using System.Windows.Media; namespace BeWo.ViewModel { @@ -53,6 +54,12 @@ namespace BeWo.ViewModel private string _IBAN; private CompactEmployeeDC _SoziotherapieAnsprechpartner; private ImageVM _Logo; + private string _ColorWaitTooLongStr; + private string _ColorSendUrbelegeStr; + private SolidColorBrush _ColorWaitTooLong; + private SolidColorBrush _ColorSendUrbelege; + private bool _ShowGkvBzEinzel; + private bool _ShowGkvBzUrbelege; public MandatorVM(IList invoiceNumberList, MandatorDC pDC) : base(pDC, true) { @@ -586,7 +593,66 @@ namespace BeWo.ViewModel FirePropertyChanged(nameof(Logo)); } } - + public SolidColorBrush ColorWaitTooLong + { + get { return _ColorWaitTooLong; } + + set + { + if (!AreDifferent(ColorWaitTooLong, value)) + return; + + _ColorWaitTooLongStr = value?.ToString(); + _ColorWaitTooLong = value; + StoreDirtyInformation(AreDifferent(DataContract.ColorWaitTooLong, value), nameof(ColorWaitTooLong)); + FirePropertyChanged(nameof(ColorWaitTooLong)); + } + } + public SolidColorBrush ColorSendUrbelege + { + get { return _ColorSendUrbelege; } + + set + { + if (!AreDifferent(ColorSendUrbelege, value)) + return; + + _ColorSendUrbelegeStr = value?.ToString(); + _ColorSendUrbelege = value; + StoreDirtyInformation(AreDifferent(DataContract.ColorSendUrbelege, value), nameof(ColorSendUrbelege)); + FirePropertyChanged(nameof(ColorSendUrbelege)); + } + } + public bool ShowGkvBzEinzel + { + get { return _ShowGkvBzEinzel; } + + set + { + if (!AreDifferent(ShowGkvBzEinzel, value)) + return; + + _ShowGkvBzEinzel = value; + StoreDirtyInformation(AreDifferent(DataContract.ShowGkvBzEinzel, value), nameof(ShowGkvBzEinzel)); + FirePropertyChanged(nameof(ShowGkvBzEinzel)); + } + } + public bool ShowGkvBzUrbelege + { + get { return _ShowGkvBzUrbelege; } + + set + { + if (!AreDifferent(ShowGkvBzUrbelege, value)) + return; + + _ShowGkvBzUrbelege = value; + StoreDirtyInformation(AreDifferent(DataContract.ShowGkvBzUrbelege, value), nameof(ShowGkvBzUrbelege)); + FirePropertyChanged(nameof(ShowGkvBzUrbelege)); + } + } + + public bool CanEditIKLeistungserbringer { get; set; } public string CanEditIKLeistungserbringerTooltip { get; set; } @@ -612,6 +678,12 @@ namespace BeWo.ViewModel CanEditIKLeistungserbringer = pDataContract.CanEditIKLeistungserbringer; CanEditIKLeistungserbringerTooltip = pDataContract.CanEditIKLeistungserbringerTooltip; _SoziotherapieAnsprechpartner = pDataContract.SoziotherapieAnsprechpartner; + _ColorWaitTooLong = ColorExtensions.ParseSolidColorBrush(pDataContract.ColorWaitTooLong); + _ColorWaitTooLongStr = pDataContract.ColorWaitTooLong; + _ColorSendUrbelege = ColorExtensions.ParseSolidColorBrush(pDataContract.ColorSendUrbelege); + _ColorSendUrbelegeStr = pDataContract.ColorSendUrbelege; + _ShowGkvBzEinzel = pDataContract.ShowGkvBzEinzel; + _ShowGkvBzUrbelege = pDataContract.ShowGkvBzUrbelege; if(pDataContract.Logo is object) Logo = new ImageVM(pDataContract.Logo); @@ -677,7 +749,12 @@ namespace BeWo.ViewModel pDataContract.BankAccount.Bic = Bic; pDataContract.BankAccount.IBAN = IBAN; pDataContract.SoziotherapieAnsprechpartner = SoziotherapieAnsprechpartner; - + + pDataContract.ColorWaitTooLong = _ColorWaitTooLongStr; + pDataContract.ColorSendUrbelege = _ColorSendUrbelegeStr; + pDataContract.ShowGkvBzEinzel = ShowGkvBzEinzel; + pDataContract.ShowGkvBzUrbelege = ShowGkvBzUrbelege; + pDataContract.Logo = Logo.CommitToDataContract(); return pDataContract; diff --git a/Dakota/Logic/DakotaInfoCreator.cs b/Dakota/Logic/DakotaInfoCreator.cs index 5cbaecaa7..c682186fd 100644 --- a/Dakota/Logic/DakotaInfoCreator.cs +++ b/Dakota/Logic/DakotaInfoCreator.cs @@ -194,16 +194,16 @@ namespace Dakota.Logic info.IKAbsender = DakotaConfig.IKAbsender; info.IKKostentrager = infoParameter.IKKostentrager; info.IKKrankenkasse = infoParameter.IKKrankenkasse; - info.IKLeistungserbringer = infoParameter.IKLeistungserbringer; + info.IKLeistungserbringer = infoParameter.AddressInformation.IKLeistungserbringer; info.Rechnungsnummer = infoParameter.InvoiceBase.InvoiceNumber; info.Rechnungsdatum = infoParameter.InvoiceBase.InvoiceDate.Value; info.Rechnungsart = SchlüsselRechnungsart.AbrechnungÜberAbrechnungsstelleOhneInkassovollmacht; - info.Name1 = infoParameter.Mandator.Name; - info.Name2 = "Rene Evertz"; - info.Name3 = "Entwickler bei ownSoft"; - info.Name4 = "dakota.exchange@ownsoft.de"; + info.Name1 = infoParameter.AddressInformation.OrganisationName; + info.Name2 = infoParameter.AddressInformation.Phone; + info.Name3 = infoParameter.AddressInformation.Mail; + info.Name4 = "Entwicklung: dakota.exchange@ownsoft.de"; return info; } @@ -215,7 +215,7 @@ namespace Dakota.Logic info.IKAbsender = DakotaConfig.IKAbsender; info.IKKostentrager = infoParameter.IKKostentrager; info.IKKrankenkasse = infoParameter.IKKrankenkasse; - info.IKLeistungserbringer = infoParameter.IKLeistungserbringer; + info.IKLeistungserbringer = infoParameter.AddressInformation.IKLeistungserbringer; info.Rechnungsnummer = infoParameter.InvoiceBase.InvoiceNumber; info.Rechnungsdatum = infoParameter.InvoiceBase.InvoiceDate.Value; diff --git a/Dakota/Logic/DakotaManager.cs b/Dakota/Logic/DakotaManager.cs index f5167c810..a101b7853 100644 --- a/Dakota/Logic/DakotaManager.cs +++ b/Dakota/Logic/DakotaManager.cs @@ -1,4 +1,5 @@ -using BS.Shared.DataContracts; +using BeWo.Data.Models; +using BS.Shared.DataContracts; using Dakota.Models.Infos; using System; using System.Collections.Generic; @@ -40,7 +41,7 @@ namespace Dakota.Logic IsSammelrechnung = isSammelrechnung; } - public void Add(ServiceInvoiceDC serviceInvoice, OrganisationDC organisation, CustomerDC customer, MandatorDC mandator, int datenaustauschreferenz, int transfernummer) + public void Add(ServiceInvoiceDC serviceInvoice, OrganisationDC organisation, CustomerDC customer, AddressInformation address, int datenaustauschreferenz, int transfernummer) { try { @@ -75,7 +76,7 @@ namespace Dakota.Logic { foreach (var invoice in peroid.InvoiceItems) { - var info_nutz_item = new InfoParameterInvoiceItem(serviceInvoice, invoice, organisation, customer, mandator); + var info_nutz_item = new InfoParameterInvoiceItem(serviceInvoice, invoice, organisation, customer, address); DakotaInfoCreator.AddInfoParameter(nutzdaten, info_nutz_item, Version); } diff --git a/Dakota/Models/Infos/InfoParameterInvoiceItem.cs b/Dakota/Models/Infos/InfoParameterInvoiceItem.cs index e9deeb7be..a21129002 100644 --- a/Dakota/Models/Infos/InfoParameterInvoiceItem.cs +++ b/Dakota/Models/Infos/InfoParameterInvoiceItem.cs @@ -1,4 +1,5 @@ -using BS.Shared.DataContracts; +using BeWo.Data.Models; +using BS.Shared.DataContracts; using Dakota.Models.Schlüssels; using System; using System.Collections.Generic; @@ -15,22 +16,21 @@ namespace Dakota.Models.Infos public ServiceInvoiceDC ServiceInvoice { get; set; } public CustomerDC Customer { get; set; } public OrganisationDC Organisation { get; set; } - public MandatorDC Mandator { get; set; } + public AddressInformation AddressInformation { get; set; } public string Abrechnungsposition { get; set; } public string IKKostentrager => Organisation.IKKostentrager; public string IKKrankenkasse => Organisation.IKKrankenkasse; - public string IKLeistungserbringer => Mandator.IKLeistungserbringer; - public InfoParameterInvoiceItem(ServiceInvoiceDC serviceInvoice, InvoiceItemDC invoiceItem, OrganisationDC organisation, CustomerDC customer, MandatorDC mandator) + public InfoParameterInvoiceItem(ServiceInvoiceDC serviceInvoice, InvoiceItemDC invoiceItem, OrganisationDC organisation, CustomerDC customer, AddressInformation addressInformation) { InvoiceItem = invoiceItem; InvoiceBase = serviceInvoice.InvoiceBase; ServiceInvoice = serviceInvoice; Customer = customer; Organisation = organisation; - Mandator = mandator; + AddressInformation = addressInformation; // Todo: Valid prüfen Abrechnungsposition = invoiceItem.UnitDescription?.Substring(6) ?? "TODO"; diff --git a/Data/Data.csproj b/Data/Data.csproj index 4cfb6b550..5465251e0 100644 --- a/Data/Data.csproj +++ b/Data/Data.csproj @@ -391,6 +391,7 @@ + diff --git a/Data/Entities/Address.cs b/Data/Entities/Address.cs index ce709453e..e73c7fd7d 100644 --- a/Data/Entities/Address.cs +++ b/Data/Entities/Address.cs @@ -1,4 +1,5 @@ using BS.Shared; +using BS.Shared.Interface; using System.Diagnostics; namespace BeWo.Data.Entities diff --git a/Data/Entities/InvoiceBase.cs b/Data/Entities/InvoiceBase.cs index 2398ea31f..18cbf2f7f 100644 --- a/Data/Entities/InvoiceBase.cs +++ b/Data/Entities/InvoiceBase.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using BS.Shared; +using BS.Shared.Interface; namespace BeWo.Data.Entities { - public class InvoiceBase : BeWoEntityBase + public class InvoiceBase : BeWoEntityBase, IInvoiceBase { public static string PropertyName_AccountingPeriodEnd = "AccountingPeriodEnd"; @@ -825,5 +826,9 @@ namespace BeWo.Data.Entities { get; set; } + + public virtual string SenderStreet => SenderAddress?.Street; + public virtual string SenderTown => SenderAddress?.Town; + public virtual string SenderPostCode => SenderAddress?.PostalCode; } } \ No newline at end of file diff --git a/Data/Entities/Mandator.cs b/Data/Entities/Mandator.cs index d3b8a13e7..6c4d42bd6 100644 --- a/Data/Entities/Mandator.cs +++ b/Data/Entities/Mandator.cs @@ -1,5 +1,5 @@ using System; - +using System.Collections.Generic; using BS.Shared; namespace BeWo.Data.Entities @@ -41,12 +41,19 @@ namespace BeWo.Data.Entities private string _Apikey; private string _IKLeistungserbringer; - public Mandator() { this._Tid = TableID.Mandator; } + public virtual BankAccount BankAccount { get; set; } + public virtual Employee SoziotherapieAnsprechpartner { get; set; } + public virtual Image Logo { get; set; } + public virtual string ColorWaitTooLong { get; set; } + public virtual string ColorSendUrbelege { get; set; } + public virtual bool ShowGkvBzEinzel { get; set; } + public virtual bool ShowGkvBzUrbelege { get; set; } + public virtual long BeWoClientType { get @@ -365,9 +372,6 @@ namespace BeWo.Data.Entities } } } - public virtual BankAccount BankAccount { get; set; } - public virtual Employee SoziotherapieAnsprechpartner { get; set; } - public virtual Image Logo { get; set; } protected virtual string GetSettingValue(string key) { diff --git a/Data/Mappings/Mandator.hbm.xml b/Data/Mappings/Mandator.hbm.xml index d03336e99..e9c93988f 100644 --- a/Data/Mappings/Mandator.hbm.xml +++ b/Data/Mappings/Mandator.hbm.xml @@ -29,6 +29,10 @@ + + + + diff --git a/Data/Models/AddressInformation.cs b/Data/Models/AddressInformation.cs new file mode 100644 index 000000000..071b88ca4 --- /dev/null +++ b/Data/Models/AddressInformation.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Data.Models +{ + public class AddressInformation + { + public string IKLeistungserbringer { get; set; } + public string OrganisationName { get; set; } + public string Street { get; set; } + public string PostCode { get; set; } + public string Town { get; set; } + public string Phone { get; set; } + public string Fax { get; set; } + public string Mail { get; set; } + public string Website { get; set; } + } +} diff --git a/Model/Changes_2024_12_05 Dakota Update 1.2.txt b/Model/Changes_2024_12_05 Dakota Update 1.2.txt new file mode 100644 index 000000000..8b98ec800 --- /dev/null +++ b/Model/Changes_2024_12_05 Dakota Update 1.2.txt @@ -0,0 +1,5 @@ +ALTER TABLE `mandator` +ADD COLUMN `ColorWaitTooLong` VARCHAR(16) NULL DEFAULT NULL AFTER `ImageOid`, +ADD COLUMN `ColorSendUrbelege` VARCHAR(16) NULL DEFAULT NULL AFTER `ColorWaitTooLong`, +ADD COLUMN `ShowGkvBzEinzel` TINYINT NULL DEFAULT NULL AFTER `ColorSendUrbelege`, +ADD COLUMN `ShowGkvBzUrbelege` TINYINT NULL DEFAULT NULL AFTER `ShowGkvBzEinzel`; diff --git a/Report/AbstractReportCreator.cs b/Report/AbstractReportCreator.cs index 44cfeb97b..2342c3cb0 100644 --- a/Report/AbstractReportCreator.cs +++ b/Report/AbstractReportCreator.cs @@ -31,6 +31,14 @@ namespace BeWo.Report long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende); + public XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, + long orgaOid, long empOid, + long? serviceCategoryOid) + { + var end = DateTime.DaysInMonth(year, month); + return CreateServiceOverviewSingleCustomerReport(customerOid, month, year, orgaOid, empOid, serviceCategoryOid, 1, end); + } + public abstract XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, diff --git a/Report/DefaultReportCreator.cs b/Report/DefaultReportCreator.cs index 03205b688..a44cb7cae 100644 --- a/Report/DefaultReportCreator.cs +++ b/Report/DefaultReportCreator.cs @@ -21,6 +21,7 @@ using BeWo.Service.Reporting; using System.Web; using BeWo.Data.Security; using BS.Shared.ReportRequests; +using System.Drawing; namespace BeWo.Report { @@ -1784,12 +1785,73 @@ namespace BeWo.Report var gkvAbrechnung = DAOFactory.GenericDAO.LoadByID(req.Oid); var gkvAbrechnungDC = MapperFactory.GkvAbrechnungDC_GkvAbrechnung.MapToNewDC(gkvAbrechnung); - var ro = GkvAbrechnungRO.Create(gkvAbrechnungDC, mandator, employee); + var invoicebase = gkvAbrechnungDC.InvoiceBases.First(); + var customer_oid = invoicebase.CustomerOid; + + var plugin = PluginLoader.FindClass(); + var address_information = plugin.GetAddressInformation(customer_oid); + + var ro = GkvAbrechnungRO.Create(gkvAbrechnungDC, mandator, employee, address_information); var report = FindReportImp(); report.SetReportDataSource(ro); - return report as XtraReport; + var xtra = report as XtraReport; + + if (req.AddUrbelege) + { + AddQuittierungsbelegToReport(xtra, gkvAbrechnung); + } + + return report as XtraReport; + } + + private void AddQuittierungsbelegToReport(XtraReport xtra, GkvAbrechnung gkvAbrechnung) + { + xtra.CreateDocument(); + + var dict = new Dictionary>(); + foreach (var invb in gkvAbrechnung.InvoiceBases) + { + var coid = invb.CostBearer2SupportConcept.SupportConcept.Customer.Oid.Value; + + if (!dict.ContainsKey(coid)) + dict.Add(coid, new HashSet()); + + var points = dict[coid]; + + var start = invb.AccountingPeriodStart.Value; + var end = invb.AccountingPeriodEnd.Value; + + var start_1 = start.AddMonths(1); + var runner = new DateTime(start_1.Year, start_1.Month, 1); + + points.Add(new Point(start.Year, start.Month)); + + while(runner <= end) + { + points.Add(new Point(runner.Year, runner.Month)); + + runner = runner.AddMonths(1); + } + } + + foreach (var kv in dict) + { + var coid = kv.Key; + + foreach (var point in kv.Value.OrderBy(x => x.X).ThenBy(x => x.Y)) + { + var year = point.X; + var month = point.Y; + + var quittierung = CreateServiceOverviewSingleCustomerReport(coid, month, year, 0, 0, null); + + quittierung.CreateDocument(); + + xtra.Pages.AddRange(quittierung.Pages); + } + } } } } \ No newline at end of file diff --git a/Report/ReportObjects/GkvAbrechnungRO.cs b/Report/ReportObjects/GkvAbrechnungRO.cs index 5263ed07d..3c8dca6e5 100644 --- a/Report/ReportObjects/GkvAbrechnungRO.cs +++ b/Report/ReportObjects/GkvAbrechnungRO.cs @@ -1,4 +1,6 @@ using BeWo.Data.Entities; +using BeWo.Data.Models; +using BeWo.Service.Plugins; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; @@ -46,7 +48,7 @@ namespace BeWo.Report.ReportObjects public ImageSource Logo { get; set; } - public static GkvAbrechnungRO Create(GkvAbrechnungDC abrechnung, Mandator mandator, Employee employee) + public static GkvAbrechnungRO Create(GkvAbrechnungDC abrechnung, Mandator mandator, Employee employee, AddressInformation addressInformation) { var protokoll = (GkvTransferProtokollDC)abrechnung.LastTransferProtokoll; var organisation = abrechnung.Organisation; @@ -54,10 +56,10 @@ namespace BeWo.Report.ReportObjects var result = new GkvAbrechnungRO(); - result.SenderOrganisationName = mandator.Name; - result.SenderStreet = mandator.Street; - result.SenderPostCodeAndTown = $"{mandator.PostalCode} {mandator.Town}"; - result.SenderWebsite = mandator.Website; + result.SenderOrganisationName = addressInformation.OrganisationName; + result.SenderStreet = addressInformation.Street; + result.SenderPostCodeAndTown = $"{addressInformation.PostCode} {addressInformation.Town}"; + result.SenderWebsite = addressInformation.Website; result.SenderBankName = mandator.BankAccount.BankName; result.SenderBankIBAN = mandator.BankAccount.IBAN; result.SenderBankBIC = mandator.BankAccount.Bic; @@ -65,9 +67,9 @@ namespace BeWo.Report.ReportObjects var person = mandator.SoziotherapieAnsprechpartner?.Person ?? employee.Person; result.SenderContactPerson = person.FirstNameLastName; - result.SenderPhone = GetSenderInformation(person, mandator, ContactType.business_Phone); - result.SenderFax = GetSenderInformation(person, mandator, ContactType.business_Fax); - result.SenderMail = GetSenderInformation(person, mandator, ContactType.business_Mail); + result.SenderPhone = addressInformation.Phone; + result.SenderFax = addressInformation.Fax; + result.SenderMail = addressInformation.Mail; var receiver_first = invoicebase.RecipientPersonFirstName; var receiver_last = invoicebase.RecipientPersonLastName; @@ -85,23 +87,18 @@ namespace BeWo.Report.ReportObjects result.KrankenkasseIK = organisation.IKKostentrager; result.KrankenkasseName = organisation.Name; - result.SenderIK = mandator.IKLeistungserbringer; + result.SenderIK = addressInformation.IKLeistungserbringer; result.Rechnungsnummer = protokoll.Rechnungsnummer; result.Rechnungsdatum = protokoll.ErstelltAm.Value.ToString("dd.MM.yyyy"); result.AnzahlDerUrbelege = string.Empty; result.InvoiceBase = invoicebase; - result.Logo = new ImageSource(false, mandator.Logo.Original); + + if(mandator.Logo?.Original is object) + result.Logo = new ImageSource(false, mandator.Logo.Original); return result; } - - private static string GetSenderInformation(Person person, Mandator mandator, ContactType contactType) - { - var rtn = person.Contacts.FirstOrDefault(x => x.Type == contactType)?.Value.ToNullIfEmpty(); - - return rtn; - } } } diff --git a/Report/ReportObjects/ServicesOverviewRO.cs b/Report/ReportObjects/ServicesOverviewRO.cs index a12e446b2..e0ac7c12e 100644 --- a/Report/ReportObjects/ServicesOverviewRO.cs +++ b/Report/ReportObjects/ServicesOverviewRO.cs @@ -22,77 +22,42 @@ namespace BeWo.Report.ReportObjects public class ServicesOverviewRO : AbstractBeWoReportObject { private List _Services = new List(); - private List _ServicesDouble = new List(); public long CustomerOid { get; set; } - public string AbsenceTimes { get; set; } - public List Abwesenheiten { get; set; } - public List AllEmployees { get; set; } = new List(); - public string ApprovedEndDate { get; set; } - public decimal ApprovedFLSPerMonth { get; set; } - public decimal ApprovedFLSPerMonthTotal { get; set; } - public decimal ApprovedFLSPerWeek { get; set; } - public decimal ApprovedFLSPerWeekTotal { get; set; } - public decimal ApprovedFLSTotal { get; set; } - public string ApprovedStartDate { get; set; } - public string ContactEmployee { get; set; } - public string Costbearer { get; set; } - public DateTime? CustomerBirthday { get; set; } - public string CustomerCity { get; set; } - public string CustomerFirstName { get; set; } - public string CustomerLastName { get; set; } - public string CustomerName { get; set; } - public string CustomerPostalCode { get; set; } - public string CustomerStreet { get; set; } - public string CustomerInsuranceNumer { get; set; } - public DateTime EndDate { get; set; } - public decimal? FreeMinutesThisMonth { get; set; } - public decimal MinutenGeleistetGesamt { get; set; } - public decimal MinutenSollGesamt { get; set; } - public string MainAttendant { get; set; } - public string MainAttendantCommaSeperated { get; set; } - public string Month { get; set; } - public string ReferenceNumber { get; set; } - public string RequestedEndDate { get; set; } - public string RequestedStartDate { get; set; } - public string Salutation { get; set; } - public decimal RateFactor { get; set; } - public decimal MinutenGeleistetBisVormonat { get; set; } - public decimal MinutenSollBisVormonat { get; set; } public List Services diff --git a/ReportImp/DiakonieKKKleve/DiakonieKKKleve.csproj b/ReportImp/DiakonieKKKleve/DiakonieKKKleve.csproj index 4be346abf..d951f97c6 100644 --- a/ReportImp/DiakonieKKKleve/DiakonieKKKleve.csproj +++ b/ReportImp/DiakonieKKKleve/DiakonieKKKleve.csproj @@ -200,6 +200,7 @@ RechnungSoziotherapie.cs + Component diff --git a/ReportImp/DiakonieKKKleve/Service/DkkkAccountingService.cs b/ReportImp/DiakonieKKKleve/Service/DkkkAccountingService.cs new file mode 100644 index 000000000..9933b7859 --- /dev/null +++ b/ReportImp/DiakonieKKKleve/Service/DkkkAccountingService.cs @@ -0,0 +1,40 @@ +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Data.Models; +using BeWo.Service.Plugins; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DiakonieKKKleve.Service +{ + public class DkkkAccountingService : AccountingService + { + public override AddressInformation GetAddressInformation(long? customer_oid = null) + { + var info = base.GetAddressInformation(); + + if (customer_oid is null) + return info; + + var c = DAOFactory.GenericDAO.GetByID(customer_oid.Value); + + foreach (var t2c in c.Team2CustomerList) + { + if (t2c.Team.Name.Contains("Nord")) + { + info.IKLeistungserbringer = "500506341"; + info.Street = "Stechbahn 33"; + info.PostCode = "47533"; + info.Town = "Kleve"; + + return info; + } + } + + return info; + } + } +} diff --git a/Service/DCEntityMapper/InvoiceBaseDC_InvoiceBase.cs b/Service/DCEntityMapper/InvoiceBaseDC_InvoiceBase.cs index 22e09cb19..23c90cd5a 100644 --- a/Service/DCEntityMapper/InvoiceBaseDC_InvoiceBase.cs +++ b/Service/DCEntityMapper/InvoiceBaseDC_InvoiceBase.cs @@ -145,6 +145,7 @@ namespace BeWo.Service.DCEntityMapper if(customer is object) { + pDataContract.CustomerOid = customer.Oid.Value; pDataContract.CustomerFirstName = customer.Person.FirstName; pDataContract.CustomerLastName = customer.Person.LastName; var error = Validator.ValidateCustomer(customer.InsuranceNumber, customer.VersichertenStatus); diff --git a/Service/DCEntityMapper/MandatorDC_Mandator.cs b/Service/DCEntityMapper/MandatorDC_Mandator.cs index 7f8856bc6..c4e3d8d76 100644 --- a/Service/DCEntityMapper/MandatorDC_Mandator.cs +++ b/Service/DCEntityMapper/MandatorDC_Mandator.cs @@ -31,6 +31,11 @@ namespace BeWo.Service.DCEntityMapper to.AllowSbd = !string.IsNullOrEmpty(to.ClientId) && to.ClientId == "SBD"; + to.ShowGkvBzEinzel = from.ShowGkvBzEinzel; + to.ShowGkvBzUrbelege = from.ShowGkvBzUrbelege; + to.ColorSendUrbelege = from.ColorSendUrbelege; + to.ColorWaitTooLong = from.ColorWaitTooLong; + #if DEBUG //pDataContract.AllowSbd = true; #endif @@ -77,6 +82,11 @@ namespace BeWo.Service.DCEntityMapper to.SoziotherapieAnsprechpartner = MapperFactory.CompactEmployeeDC_Employee.MergeWithEntity(from.SoziotherapieAnsprechpartner, to.SoziotherapieAnsprechpartner, false); to.Logo = MapperFactory.ImageDC_Image.MergeWithEntity(from.Logo, to.Logo, false); + to.ShowGkvBzEinzel = from.ShowGkvBzEinzel; + to.ShowGkvBzUrbelege = from.ShowGkvBzUrbelege; + to.ColorSendUrbelege = from.ColorSendUrbelege; + to.ColorWaitTooLong = from.ColorWaitTooLong; + return to; } diff --git a/Service/Plugins/AccountingService.cs b/Service/Plugins/AccountingService.cs index 556a1a20a..98b2fba21 100644 --- a/Service/Plugins/AccountingService.cs +++ b/Service/Plugins/AccountingService.cs @@ -1,218 +1,221 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.ServiceModel; -using BeWo.Data.Access; -using BeWo.Data.Entities; -using BeWo.Service.Core; -using BeWo.Service.DCEntityMapper; -using BeWo.Service.Invoicing; -using BeWo.Service.ServiceContracts; -using BS.Shared; -using BS.Shared.Core; -using BS.Shared.DataContracts; -using BS.Shared.DataContracts.Compact; -using BS.Shared.Extensions; - -namespace BeWo.Service.Plugins -{ - public class AccountingService : AbstractIDSpecificDefaultClass - { - public virtual List GenerateInitialServiceInvoices(long costBearerOid, long? supportConceptOid, DateTimeSpan invoicePeriod) - { - var cs = PluginLoader.FindClass(); - IEnumerable supportConcepts; - // GetAllActiveSupportConceptCostbearer returns a "Flat" SupportConcept List, one for each CostBearer2SupportConcept! - if (!supportConceptOid.HasValue) - { - supportConcepts = cs.GetAllActiveSupportConceptCostbearer(false, true, 0) - .Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid)); - } - else - { - supportConcepts = cs.GetCompactSupportConcepts(supportConceptOid.Value, null) - .Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid)); - } - - DateTimeSpan newSpan = null; - if (invoicePeriod != null) - { - //invoicePeriod.StartDateTime = invoicePeriod.StartDateTime.Date; - //invoicePeriod.EndDateTime = invoicePeriod.EndDateTime.Date; - newSpan = new DateTimeSpan(); - newSpan.StartDateTime = invoicePeriod.StartDateTime.Date; - newSpan.EndDateTime = invoicePeriod.EndDateTime.Date.AddDays(1).AddTicks(-1); - if (!supportConceptOid.HasValue) - { - supportConcepts = - supportConcepts.Where(sc => sc.StartDate < newSpan.EndDateTime && sc.EndDate >= newSpan.StartDate); - } - } - var supportConcepts2ServiceRecords = supportConcepts.ToDictionary( - i => i, - i => MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs( - DAOFactory.SearchDAO.FindServiceRecordsInSpan(i.CostBearerRelOids[0], newSpan))); - var cb = DAOFactory.GenericDAO.LoadByID(costBearerOid); - String tenant = PluginLoader.Tenant; - var factory = PluginLoader.FindClass(cb.ID); - if (factory == null) - { - factory = InvoiceFactory.GetInstance(cb.ID, tenant); - } - - var creator = factory.CreateInvoiceCreator(cb.ID, tenant, supportConcepts2ServiceRecords); +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceModel; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Data.Models; +using BeWo.Data.Security; +using BeWo.Service.Configuration; +using BeWo.Service.Core; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Invoicing; +using BeWo.Service.ServiceContracts; +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using BS.Shared.Extensions; + +namespace BeWo.Service.Plugins +{ + public class AccountingService : AbstractIDSpecificDefaultClass + { + public virtual List GenerateInitialServiceInvoices(long costBearerOid, long? supportConceptOid, DateTimeSpan invoicePeriod) + { + var cs = PluginLoader.FindClass(); + IEnumerable supportConcepts; + // GetAllActiveSupportConceptCostbearer returns a "Flat" SupportConcept List, one for each CostBearer2SupportConcept! + if (!supportConceptOid.HasValue) + { + supportConcepts = cs.GetAllActiveSupportConceptCostbearer(false, true, 0) + .Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid)); + } + else + { + supportConcepts = cs.GetCompactSupportConcepts(supportConceptOid.Value, null) + .Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid)); + } + + DateTimeSpan newSpan = null; + if (invoicePeriod != null) + { + //invoicePeriod.StartDateTime = invoicePeriod.StartDateTime.Date; + //invoicePeriod.EndDateTime = invoicePeriod.EndDateTime.Date; + newSpan = new DateTimeSpan(); + newSpan.StartDateTime = invoicePeriod.StartDateTime.Date; + newSpan.EndDateTime = invoicePeriod.EndDateTime.Date.AddDays(1).AddTicks(-1); + if (!supportConceptOid.HasValue) + { + supportConcepts = + supportConcepts.Where(sc => sc.StartDate < newSpan.EndDateTime && sc.EndDate >= newSpan.StartDate); + } + } + var supportConcepts2ServiceRecords = supportConcepts.ToDictionary( + i => i, + i => MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs( + DAOFactory.SearchDAO.FindServiceRecordsInSpan(i.CostBearerRelOids[0], newSpan))); + var cb = DAOFactory.GenericDAO.LoadByID(costBearerOid); + String tenant = PluginLoader.Tenant; + var factory = PluginLoader.FindClass(cb.ID); + if (factory == null) + { + factory = InvoiceFactory.GetInstance(cb.ID, tenant); + } + + var creator = factory.CreateInvoiceCreator(cb.ID, tenant, supportConcepts2ServiceRecords); var newInvoices = creator.GenerateServiceInvoices(costBearerOid, invoicePeriod, supportConcepts2ServiceRecords); - - //Prüfe ob Rechnungen neu sind oder Diff vorhanden - var differenzRechnungChecks = GetNewInvoices(newInvoices, invoicePeriod?.StartDate, invoicePeriod?.EndDate); - var resultList = ErstelleNeueRechnungen(differenzRechnungChecks); - - - return resultList; - } - - protected virtual List ErstelleNeueRechnungen(List differenzRechnungChecks) - { - var rechnungen = new List(); - foreach (var item in differenzRechnungChecks) - { - if (item.VorhandeneRechungen.Count == 0) - { - item.NeueRechnung.InvoiceBase.NeuErstellen = true; - rechnungen.Add(item.NeueRechnung); - } - else - { - rechnungen.Add(ErstelleDifferenzRechnung(item)); - } - } - - return rechnungen; - } - - protected virtual ServiceInvoiceDC ErstelleDifferenzRechnung(DifferenzRechnungCheck item) - { - ServiceInvoiceDC diffRechnung = null; - var alterBetrag = item.VorhandeneRechungen.Sum(i => i.ClaimSum ?? 0); - - if (item.NeueRechnung.ClaimSum == alterBetrag) - { - diffRechnung = item.NeueRechnung; - diffRechnung.InvoiceBase.NeuErstellen = false; - diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnung wurde bereits erstellt"); - } - else - { - diffRechnung = new ServiceInvoiceDC(); - diffRechnung.OriginalZurDifferenz = item.NeueRechnung; - diffRechnung.InvoiceBase = new InvoiceBaseDC(); - CopyInvoiceBaseDC(item.NeueRechnung.InvoiceBase, diffRechnung); - - var newItem = new InvoiceItemDC(); - newItem.ItemPeriodStart = item.NeueRechnung.InvoiceBase.AccountingPeriodStart; - newItem.ItemPeriodEnd = item.NeueRechnung.InvoiceBase.AccountingPeriodEnd; - newItem.UnitCount = 1; - newItem.AmountPerUnit = item.NeueRechnung.ClaimSum - alterBetrag; - newItem.AmountTotal = newItem.AmountPerUnit; - newItem.GrossAmountTotal = newItem.AmountTotal; - newItem.ItemDescription = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber, alterBetrag); - diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber, alterBetrag); - - var newSip = new ServiceInvoicePeriodDC(); - newSip.Claim = newItem.AmountTotal; - newSip.Start = item.NeueRechnung.InvoiceBase.AccountingPeriodStart; - newSip.End = item.NeueRechnung.InvoiceBase.AccountingPeriodEnd; - diffRechnung.ServiceInvoicePeriods = new List(); - diffRechnung.ServiceInvoicePeriods.Add(newSip); - newSip.InvoiceItems = new List(); - newSip.InvoiceItems.Add(newItem); - } - return diffRechnung; - } - - protected virtual List GetNewInvoices(List invoices, DateTime? start, DateTime? end) - { - List result = new List(); - var existingInvoices = DAOFactory.SearchDAO.GetInvoiceBases(start, end, false); - - foreach (var si in invoices) - { - var checkResult = new DifferenzRechnungCheck(); - result.Add(checkResult); - checkResult.NeueRechnung = si; - checkResult.VorhandeneRechungen = new List(); - - foreach (var i2 in existingInvoices.Where(i => i.Type == InvoiceType.Service)) - { - if (si.InvoiceBase.SupportConceptCostBearerRelDc != null && si.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer2SupportConceptOid == i2.CostBearer2SupportConceptOid) - { - var siAlt = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(i2.Oid.Value); - var siDCAlt = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(siAlt); - - //InvoiceItems vergleichen? - //foreach (var sip in si.ServiceInvoicePeriods) - //{ - // foreach (var ii in sip.InvoiceItems) - // { - // typNeu = ii.ItemDescription; - // } - //} - - //foreach (var sip in siAlt.ServiceInvoicePeriodList) - //{ - // foreach (var ii in sip.InvoiceItemList) - // { - // typAlt = ii.ItemDescription; - // } - //} - - //if (typAlt == typNeu) - //{ - // exist = true; - //} - - checkResult.VorhandeneRechungen.Add(siDCAlt); - } - } - } - return result; - } - - public virtual List UpdateServiceInvoices(List invoices) - { - //if (!Data.Security.UserRightHelper.LoggedInUserHasRight(UserRightType.AccountingTransactionView_Create)) - //{ - // throw new FaultException(new BeWoFault("Du kommst hier nicht rein!", BeWoFaultType.CustomWithoutDetails)); - //} - var originals = DAOFactory.GenericDAO.LoadByIDs(invoices.Select(i => i.ServiceInvoiceOid.Value)); - MapperFactory.ServiceInvoiceDC_ServiceInvoice.MergeWithEntitys(invoices, originals); - DAOFactory.GenericDAO.Update(originals); - return originals.Select(e => e.Version.Value).ToList(); - } - - public virtual List GetInvoiceBases(DateTime? startDate, DateTime? endDate) - { - DateTime? end = endDate; - if (end.HasValue) - { - end = end.Value.Date.AddDays(1).AddTicks(-1); - } - var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end); - - return MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(list); - } - - public virtual List GetInvoiceBases(DateTime? startDate, DateTime? endDate, bool filterByInvoiceDate) - { - DateTime? end = endDate; - if (end.HasValue) - { - end = end.Value.Date.AddDays(1).AddTicks(-1); - } - var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end, filterByInvoiceDate); - - return MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(list); + + //Prüfe ob Rechnungen neu sind oder Diff vorhanden + var differenzRechnungChecks = GetNewInvoices(newInvoices, invoicePeriod?.StartDate, invoicePeriod?.EndDate); + var resultList = ErstelleNeueRechnungen(differenzRechnungChecks); + + + return resultList; + } + + protected virtual List ErstelleNeueRechnungen(List differenzRechnungChecks) + { + var rechnungen = new List(); + foreach (var item in differenzRechnungChecks) + { + if (item.VorhandeneRechungen.Count == 0) + { + item.NeueRechnung.InvoiceBase.NeuErstellen = true; + rechnungen.Add(item.NeueRechnung); + } + else + { + rechnungen.Add(ErstelleDifferenzRechnung(item)); + } + } + + return rechnungen; + } + + protected virtual ServiceInvoiceDC ErstelleDifferenzRechnung(DifferenzRechnungCheck item) + { + ServiceInvoiceDC diffRechnung = null; + var alterBetrag = item.VorhandeneRechungen.Sum(i => i.ClaimSum ?? 0); + + if (item.NeueRechnung.ClaimSum == alterBetrag) + { + diffRechnung = item.NeueRechnung; + diffRechnung.InvoiceBase.NeuErstellen = false; + diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnung wurde bereits erstellt"); + } + else + { + diffRechnung = new ServiceInvoiceDC(); + diffRechnung.OriginalZurDifferenz = item.NeueRechnung; + diffRechnung.InvoiceBase = new InvoiceBaseDC(); + CopyInvoiceBaseDC(item.NeueRechnung.InvoiceBase, diffRechnung); + + var newItem = new InvoiceItemDC(); + newItem.ItemPeriodStart = item.NeueRechnung.InvoiceBase.AccountingPeriodStart; + newItem.ItemPeriodEnd = item.NeueRechnung.InvoiceBase.AccountingPeriodEnd; + newItem.UnitCount = 1; + newItem.AmountPerUnit = item.NeueRechnung.ClaimSum - alterBetrag; + newItem.AmountTotal = newItem.AmountPerUnit; + newItem.GrossAmountTotal = newItem.AmountTotal; + newItem.ItemDescription = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber, alterBetrag); + diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber, alterBetrag); + + var newSip = new ServiceInvoicePeriodDC(); + newSip.Claim = newItem.AmountTotal; + newSip.Start = item.NeueRechnung.InvoiceBase.AccountingPeriodStart; + newSip.End = item.NeueRechnung.InvoiceBase.AccountingPeriodEnd; + diffRechnung.ServiceInvoicePeriods = new List(); + diffRechnung.ServiceInvoicePeriods.Add(newSip); + newSip.InvoiceItems = new List(); + newSip.InvoiceItems.Add(newItem); + } + return diffRechnung; + } + + protected virtual List GetNewInvoices(List invoices, DateTime? start, DateTime? end) + { + List result = new List(); + var existingInvoices = DAOFactory.SearchDAO.GetInvoiceBases(start, end, false); + + foreach (var si in invoices) + { + var checkResult = new DifferenzRechnungCheck(); + result.Add(checkResult); + checkResult.NeueRechnung = si; + checkResult.VorhandeneRechungen = new List(); + + foreach (var i2 in existingInvoices.Where(i => i.Type == InvoiceType.Service)) + { + if (si.InvoiceBase.SupportConceptCostBearerRelDc != null && si.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer2SupportConceptOid == i2.CostBearer2SupportConceptOid) + { + var siAlt = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(i2.Oid.Value); + var siDCAlt = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(siAlt); + + //InvoiceItems vergleichen? + //foreach (var sip in si.ServiceInvoicePeriods) + //{ + // foreach (var ii in sip.InvoiceItems) + // { + // typNeu = ii.ItemDescription; + // } + //} + + //foreach (var sip in siAlt.ServiceInvoicePeriodList) + //{ + // foreach (var ii in sip.InvoiceItemList) + // { + // typAlt = ii.ItemDescription; + // } + //} + + //if (typAlt == typNeu) + //{ + // exist = true; + //} + + checkResult.VorhandeneRechungen.Add(siDCAlt); + } + } + } + return result; + } + + public virtual List UpdateServiceInvoices(List invoices) + { + //if (!Data.Security.UserRightHelper.LoggedInUserHasRight(UserRightType.AccountingTransactionView_Create)) + //{ + // throw new FaultException(new BeWoFault("Du kommst hier nicht rein!", BeWoFaultType.CustomWithoutDetails)); + //} + var originals = DAOFactory.GenericDAO.LoadByIDs(invoices.Select(i => i.ServiceInvoiceOid.Value)); + MapperFactory.ServiceInvoiceDC_ServiceInvoice.MergeWithEntitys(invoices, originals); + DAOFactory.GenericDAO.Update(originals); + return originals.Select(e => e.Version.Value).ToList(); + } + + public virtual List GetInvoiceBases(DateTime? startDate, DateTime? endDate) + { + DateTime? end = endDate; + if (end.HasValue) + { + end = end.Value.Date.AddDays(1).AddTicks(-1); + } + var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end); + + return MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(list); + } + + public virtual List GetInvoiceBases(DateTime? startDate, DateTime? endDate, bool filterByInvoiceDate) + { + DateTime? end = endDate; + if (end.HasValue) + { + end = end.Value.Date.AddDays(1).AddTicks(-1); + } + var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end, filterByInvoiceDate); + + return MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(list); } public virtual List GetInvoiceBases(DateTime? startDate, DateTime? endDate, long costBearerOid, String invoiceId) @@ -225,369 +228,388 @@ namespace BeWo.Service.Plugins var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end, costBearerOid, invoiceId); return MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(list); - } - - - public virtual void DeactivateInvoiceBases(List invoices) - { - ServiceLogic.SetActivationType(invoices.ToDictionary(i => i.InvoiceBaseOid.Value, i => i.InvoiceBaseVersion.Value), ActivationTypeId.Deleted); - } - - public virtual void DeactivateServiceInvoices(List invoices) - { - ServiceLogic.SetActivationType(invoices.ToDictionary(i => i.ServiceInvoiceOid.Value, i => i.ServiceInvoiceVersion.Value), ActivationTypeId.Deleted); - ServiceLogic.SetActivationType(invoices.ToDictionary(i => i.InvoiceBase.InvoiceBaseOid.Value, i => i.InvoiceBase.InvoiceBaseVersion.Value), ActivationTypeId.Deleted); - } - - public virtual void StorniereInvoiceBases(List invoices) - { - foreach (var item in invoices) - { - if (item.Type == InvoiceType.Service) - { - ErstelleStornoRechnung(item); - } - else if (item.Type == InvoiceType.Settlement) - { - //ErstelleStornoSpitzabrechnung(item); - } - else - { - ErstelleStornoAllgemeineRechnung(item); - } - } - } - - public virtual InvoiceBase ErstelleStornoAllgemeineRechnung(InvoiceBaseDC ibdc) - { - InvoiceBase newInvoice = new InvoiceBase(); - - var oldInvoice = DAOFactory.GenericDAO.LoadByID(ibdc.InvoiceBaseOid.Value); - - CopyInvoiceBase(oldInvoice, newInvoice); - SetzeStornoInfos(newInvoice); - - return newInvoice; - } - - public virtual ServiceInvoice ErstelleStornoRechnung(InvoiceBaseDC ibdc) - { - ServiceInvoice newInvoice = new ServiceInvoice(); - - var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(ibdc.InvoiceBaseOid.Value); - - CopyServiceInvoice(serviceInvoice, newInvoice); - SetzeStornoInfos(newInvoice); - - return newInvoice; - } - - //public virtual InvoiceBase ErstelleStornoSpitzabrechnung(InvoiceBaseDC ibdc) - //{ - // InvoiceBase newInvoice = new InvoiceBase(); - - // var oldInvoice = DAOFactory.GenericDAO.LoadByID(ibdc.InvoiceBaseOid.Value); - - // CopyInvoiceBase(oldInvoice, newInvoice); - // SetzeStornoInfos(newInvoice); - - // return newInvoice; - //} - - public virtual ServiceInvoice ErstelleStornoRechnung(ServiceInvoiceDC sidc) - { - ServiceInvoice newInvoice = new ServiceInvoice(); - - var serviceInvoice = DAOFactory.GenericDAO.LoadByID(sidc.ServiceInvoiceOid.Value); - - CopyServiceInvoice(serviceInvoice, newInvoice); - SetzeStornoInfos(newInvoice); - - return newInvoice; - } - - public virtual void SaveStornoRechnung(InvoiceBase originalInvoice, ServiceInvoice stornoInvoice) - { - DAOFactory.GenericDAO.Insert(stornoInvoice); - originalInvoice.StornoInvoiceBaseOid = stornoInvoice.Oid; - DAOFactory.GenericDAO.Update(originalInvoice); - - } - - public virtual void SetzeStornoInfos(InvoiceBase newInvoice) - { - foreach (var ii in newInvoice.InvoiceItems) - { - if (ii.AmountTotal.HasValue) - { - ii.AmountTotal *= -1; - } - - if (ii.GrossAmountTotal.HasValue) - { - ii.GrossAmountTotal *= -1; - } - } - } - - public virtual void SetzeStornoInfos(ServiceInvoice newInvoice) - { - foreach (var sip in newInvoice.ServiceInvoicePeriodList) - { - sip.HoursNotBillableAbsence = 0; - sip.HoursNotBillableNotApproved = 0; - if (sip.Claim.HasValue) - { - sip.Claim *= -1; - } - - foreach (var ii in sip.InvoiceItemList) - { - if (ii.AmountTotal.HasValue) - { - ii.AmountTotal *= -1; - } - - if (ii.GrossAmountTotal.HasValue) - { - ii.GrossAmountTotal *= -1; - } - } - } - } - - private void CopyServiceInvoice(ServiceInvoice existingInvoice, ServiceInvoice copyInvoice) - { - copyInvoice.AmountAdvancePayments = existingInvoice.AmountAdvancePayments; - copyInvoice.AmountEquityContribution = existingInvoice.AmountEquityContribution; - copyInvoice.ServiceUnitOid = existingInvoice.ServiceUnitOid; - - - CopyInvoiceBase(existingInvoice.InvoiceBase, copyInvoice.InvoiceBase); - - foreach (var sip in existingInvoice.ServiceInvoicePeriodList) - { - var copySip = new ServiceInvoicePeriod(); - copyInvoice.ServiceInvoicePeriodList.Add(copySip); - - CopyServiceInvoicePeriod(sip, copySip); - } - } - - //private void CopySettlementInvoice(SettlementInvoice existingInvoice, SettlementInvoice copyInvoice) - // { - - // CopyInvoiceBase(existingInvoice.InvoiceBase, copyInvoice.InvoiceBase); - - - // } - - private void CopyInvoiceBase(InvoiceBase existing, InvoiceBase copy) - { - copy.AccountingPeriodEnd = existing.AccountingPeriodEnd; - copy.AccountingPeriodStart = existing.AccountingPeriodStart; - copy.CostBearer2SupportConcept = existing.CostBearer2SupportConcept; - copy.CreatorFirstName = existing.CreatorFirstName; - copy.CreatorLastName = existing.CreatorLastName; - copy.CustomerReferenceNumber = existing.CustomerReferenceNumber; - copy.DueDate = existing.DueDate; - copy.DunningLetterCount = existing.DunningLetterCount; - copy.InvoiceDate = existing.InvoiceDate; - copy.InvoiceId = existing.InvoiceId; - copy.InvoiceNumber = existing.InvoiceNumber; - copy.InvoiceTitle = existing.InvoiceTitle; - copy.InvoiceTypeText = existing.InvoiceTypeText; - copy.IsPaid = existing.IsPaid; - copy.IsPrinted = existing.IsPrinted; - copy.RecipientCostBearerOid = existing.RecipientCostBearerOid; - copy.RecipientCustomerOid = existing.RecipientCustomerOid; - copy.RecipientDivision = existing.RecipientDivision; - copy.RecipientOrganisation = existing.RecipientOrganisation; - copy.RecipientOrganisationOid = existing.RecipientOrganisationOid; - copy.RecipientPersonFirstName = existing.RecipientPersonFirstName; - copy.RecipientPersonLastName = existing.RecipientPersonLastName; - copy.RecipientPersonOid = existing.RecipientPersonOid; - copy.SenderDivision = existing.SenderDivision; - copy.SenderFirstName = existing.SenderFirstName; - copy.SenderLastName = existing.SenderLastName; - copy.SenderOrganisation = existing.SenderOrganisation; - copy.SupportConceptOid = existing.SupportConceptOid; - copy.Type = existing.Type; - copy.XMLData = existing.XMLData; - - foreach (var ii in existing.InvoiceItems) - { - var copyItem = new InvoiceItem(); - copy.InvoiceItems.Add(copyItem); - - CopyInvoiceItem(ii, copyItem); - - } - - if (existing.RecipientAddress != null) - { - copy.RecipientAddress = CreateCopyAddress(existing.RecipientAddress); - } - - if (existing.RecipientContacts != null) - { - copy.RecipientContacts = new List(); - foreach (var existingContact in existing.RecipientContacts) - { - copy.RecipientContacts.Add(CreateCopyContact(existingContact)); - } - } - - if (existing.SenderAddress != null) - { - copy.SenderAddress = existing.SenderAddress; - } - - if (existing.SenderContacts != null) - { - copy.SenderContacts = new List(); - foreach (var existingContact in existing.SenderContacts) - { - copy.SenderContacts.Add(CreateCopyContact(existingContact)); - } - } - - } - - public void CopyInvoiceBaseDC(InvoiceBaseDC orgRechnung, ServiceInvoiceDC diffRechnung) - { - diffRechnung.InvoiceBase.DiffErstellen = true; - diffRechnung.InvoiceBase.AccountingPeriodStart = orgRechnung.AccountingPeriodStart; - diffRechnung.InvoiceBase.AccountingPeriodEnd = orgRechnung.AccountingPeriodEnd; - diffRechnung.InvoiceBase.CustomerLastName = orgRechnung.CustomerLastName; - diffRechnung.InvoiceBase.CustomerFirstName = orgRechnung.CustomerFirstName; - diffRechnung.InvoiceBase.CustomerReferenceNumber = orgRechnung.CustomerReferenceNumber; - diffRechnung.InvoiceBase.InvoiceBaseOid = orgRechnung.InvoiceBaseOid; - diffRechnung.InvoiceBase.InvoiceDate = orgRechnung.InvoiceDate; - diffRechnung.InvoiceBase.InvoiceId = orgRechnung.InvoiceId; - diffRechnung.InvoiceBase.InvoiceNumber = orgRechnung.InvoiceNumber; - diffRechnung.InvoiceBase.InvoiceTitle = orgRechnung.InvoiceTitle; - diffRechnung.InvoiceBase.InvoiceTypeText = orgRechnung.InvoiceTypeText; - diffRechnung.InvoiceBase.RecipientAddressLine1 = orgRechnung.RecipientAddressLine1; - diffRechnung.InvoiceBase.RecipientAddressOid = orgRechnung.RecipientAddressOid; - diffRechnung.InvoiceBase.RecipientAddressVersion = orgRechnung.RecipientAddressVersion; - diffRechnung.InvoiceBase.RecipientContactInformations = orgRechnung.RecipientContactInformations; - diffRechnung.InvoiceBase.RecipientCostBearerOid = orgRechnung.RecipientCostBearerOid; - diffRechnung.InvoiceBase.RecipientCustomerOid = orgRechnung.RecipientCustomerOid; - diffRechnung.InvoiceBase.RecipientDivision = orgRechnung.RecipientDivision; - diffRechnung.InvoiceBase.RecipientOrganisation = orgRechnung.RecipientOrganisation; - diffRechnung.InvoiceBase.RecipientOrganisationOid = orgRechnung.RecipientOrganisationOid; - diffRechnung.InvoiceBase.RecipientPersonFirstName = orgRechnung.RecipientPersonFirstName; - diffRechnung.InvoiceBase.RecipientPersonLastName = orgRechnung.RecipientPersonLastName; - diffRechnung.InvoiceBase.RecipientPersonOid = orgRechnung.RecipientPersonOid; - diffRechnung.InvoiceBase.RecipientPostCode = orgRechnung.RecipientPostCode; - diffRechnung.InvoiceBase.RecipientSalutationAddressField = orgRechnung.RecipientSalutationAddressField; - diffRechnung.InvoiceBase.RecipientStreet = orgRechnung.RecipientStreet; - diffRechnung.InvoiceBase.RecipientTown = orgRechnung.RecipientTown; - diffRechnung.InvoiceBase.SenderAddressOid = orgRechnung.SenderAddressOid; - diffRechnung.InvoiceBase.SenderAddressVersion = orgRechnung.SenderAddressVersion; - diffRechnung.InvoiceBase.SenderContactInformations = orgRechnung.SenderContactInformations; - diffRechnung.InvoiceBase.SenderDivision = orgRechnung.SenderDivision; - diffRechnung.InvoiceBase.SenderFirstName = orgRechnung.SenderFirstName; - diffRechnung.InvoiceBase.SenderLastName = orgRechnung.SenderLastName; - diffRechnung.InvoiceBase.SenderOrganisation = orgRechnung.SenderOrganisation; - diffRechnung.InvoiceBase.SenderPostCode = orgRechnung.SenderPostCode; - diffRechnung.InvoiceBase.SenderStreet = orgRechnung.SenderStreet; - diffRechnung.InvoiceBase.SenderTown = orgRechnung.SenderTown; - diffRechnung.InvoiceBase.SupportConceptCostBearerRelDc = orgRechnung.SupportConceptCostBearerRelDc; - diffRechnung.InvoiceBase.SupportConceptOid = orgRechnung.SupportConceptOid; - diffRechnung.InvoiceBase.TotalAmount = orgRechnung.TotalAmount; - diffRechnung.InvoiceBase.Type = orgRechnung.Type; - } - - private Contact CreateCopyContact(Contact existingContact) - { - Contact newContact = new Contact(); - newContact.Value = existingContact.Value; - newContact.Type = existingContact.Type; - - return newContact; - } - - private Address CreateCopyAddress(Address address) - { - Address newAddress = new Address(); - newAddress.AddressLine1 = address.AddressLine1; - newAddress.AddressLine2 = address.AddressLine2; - newAddress.Country = address.Country; - newAddress.PostalCode = address.PostalCode; - newAddress.State = address.State; - newAddress.Street = address.Street; - newAddress.Town = address.Town; - - return newAddress; - } - - private void CopyServiceInvoicePeriod(ServiceInvoicePeriod existingSip, ServiceInvoicePeriod copySip) - { - copySip.AccountingInterval = existingSip.AccountingInterval; - copySip.ApprovedAmountDefaultHourlyRate = existingSip.ApprovedAmountDefaultHourlyRate; - copySip.ApprovedBE = existingSip.ApprovedBE; - copySip.ApprovedFixedAmount = existingSip.ApprovedFixedAmount; - copySip.ApprovedHours = existingSip.ApprovedHours; - copySip.Claim = existingSip.Claim; - copySip.End = existingSip.End; - copySip.HoursNotBillableAbsence = existingSip.HoursNotBillableAbsence; - copySip.HoursNotBillableNotApproved = existingSip.HoursNotBillableNotApproved; - copySip.ServiceUnitName = existingSip.ServiceUnitName; - copySip.Start = existingSip.Start; - copySip.Notice = existingSip.Notice; - copySip.Customer = existingSip.Customer; - copySip.SupportConceptApprovalPeriod = existingSip.SupportConceptApprovalPeriod; - - foreach (var ii in existingSip.InvoiceItemList) - { - var copyItem = new InvoiceItem(); - copySip.InvoiceItemList.Add(copyItem); - - CopyInvoiceItem(ii, copyItem); - } - - } - - private void CopyInvoiceItem(InvoiceItem existingItem, InvoiceItem copyItem) - { - copyItem.AccountingInterval = existingItem.AccountingInterval; - copyItem.AmountPerUnit = existingItem.AmountPerUnit; - copyItem.AmountTotal = existingItem.AmountTotal; - copyItem.ApprovalUnit = existingItem.AccountingInterval; - copyItem.ApprovedPerUnit = existingItem.ApprovedPerUnit; - copyItem.GrossAmountTotal = existingItem.GrossAmountTotal; - copyItem.ItemDescription = existingItem.ItemDescription; - copyItem.ItemPeriodEnd = existingItem.ItemPeriodEnd; - copyItem.ItemPeriodStart = existingItem.ItemPeriodStart; - copyItem.MaxApprovedAmount = existingItem.MaxApprovedAmount; - copyItem.MaxApprovedUnitCount = existingItem.MaxApprovedUnitCount; - copyItem.RateFactor = existingItem.RateFactor; - copyItem.ReceivedAmount = existingItem.ReceivedAmount; - copyItem.SupportConceptApprovalPeriodOid = existingItem.SupportConceptApprovalPeriodOid; - copyItem.UnitCount = existingItem.UnitCount; - copyItem.UnitDescription = existingItem.UnitDescription; - copyItem.Notice = existingItem.Notice; - copyItem.ServiceRecord = existingItem.ServiceRecord; - } - - public virtual Settlement2DC ErstelleDifferenzSpitzabrechnung(Settlement2DC neueRechnung, Settlement2DC letzteRechnung) - { - var diff = neueRechnung.Claim - letzteRechnung.Claim; - var ii = new InvoiceItemDC(); - - neueRechnung.Claim = diff; - neueRechnung.InvoiceItems = new List(); - neueRechnung.InvoiceItems.Add(ii); - - return neueRechnung; - } - } - - public class DifferenzRechnungCheck - { - public ServiceInvoiceDC NeueRechnung { get; set; } - public IList VorhandeneRechungen { get; set; } - } + } + + + public virtual void DeactivateInvoiceBases(List invoices) + { + ServiceLogic.SetActivationType(invoices.ToDictionary(i => i.InvoiceBaseOid.Value, i => i.InvoiceBaseVersion.Value), ActivationTypeId.Deleted); + } + + public virtual void DeactivateServiceInvoices(List invoices) + { + ServiceLogic.SetActivationType(invoices.ToDictionary(i => i.ServiceInvoiceOid.Value, i => i.ServiceInvoiceVersion.Value), ActivationTypeId.Deleted); + ServiceLogic.SetActivationType(invoices.ToDictionary(i => i.InvoiceBase.InvoiceBaseOid.Value, i => i.InvoiceBase.InvoiceBaseVersion.Value), ActivationTypeId.Deleted); + } + + public virtual void StorniereInvoiceBases(List invoices) + { + foreach (var item in invoices) + { + if (item.Type == InvoiceType.Service) + { + ErstelleStornoRechnung(item); + } + else if (item.Type == InvoiceType.Settlement) + { + //ErstelleStornoSpitzabrechnung(item); + } + else + { + ErstelleStornoAllgemeineRechnung(item); + } + } + } + + public virtual InvoiceBase ErstelleStornoAllgemeineRechnung(InvoiceBaseDC ibdc) + { + InvoiceBase newInvoice = new InvoiceBase(); + + var oldInvoice = DAOFactory.GenericDAO.LoadByID(ibdc.InvoiceBaseOid.Value); + + CopyInvoiceBase(oldInvoice, newInvoice); + SetzeStornoInfos(newInvoice); + + return newInvoice; + } + + public virtual ServiceInvoice ErstelleStornoRechnung(InvoiceBaseDC ibdc) + { + ServiceInvoice newInvoice = new ServiceInvoice(); + + var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(ibdc.InvoiceBaseOid.Value); + + CopyServiceInvoice(serviceInvoice, newInvoice); + SetzeStornoInfos(newInvoice); + + return newInvoice; + } + + //public virtual InvoiceBase ErstelleStornoSpitzabrechnung(InvoiceBaseDC ibdc) + //{ + // InvoiceBase newInvoice = new InvoiceBase(); + + // var oldInvoice = DAOFactory.GenericDAO.LoadByID(ibdc.InvoiceBaseOid.Value); + + // CopyInvoiceBase(oldInvoice, newInvoice); + // SetzeStornoInfos(newInvoice); + + // return newInvoice; + //} + + public virtual ServiceInvoice ErstelleStornoRechnung(ServiceInvoiceDC sidc) + { + ServiceInvoice newInvoice = new ServiceInvoice(); + + var serviceInvoice = DAOFactory.GenericDAO.LoadByID(sidc.ServiceInvoiceOid.Value); + + CopyServiceInvoice(serviceInvoice, newInvoice); + SetzeStornoInfos(newInvoice); + + return newInvoice; + } + + public virtual void SaveStornoRechnung(InvoiceBase originalInvoice, ServiceInvoice stornoInvoice) + { + DAOFactory.GenericDAO.Insert(stornoInvoice); + originalInvoice.StornoInvoiceBaseOid = stornoInvoice.Oid; + DAOFactory.GenericDAO.Update(originalInvoice); + + } + + public virtual void SetzeStornoInfos(InvoiceBase newInvoice) + { + foreach (var ii in newInvoice.InvoiceItems) + { + if (ii.AmountTotal.HasValue) + { + ii.AmountTotal *= -1; + } + + if (ii.GrossAmountTotal.HasValue) + { + ii.GrossAmountTotal *= -1; + } + } + } + + public virtual void SetzeStornoInfos(ServiceInvoice newInvoice) + { + foreach (var sip in newInvoice.ServiceInvoicePeriodList) + { + sip.HoursNotBillableAbsence = 0; + sip.HoursNotBillableNotApproved = 0; + if (sip.Claim.HasValue) + { + sip.Claim *= -1; + } + + foreach (var ii in sip.InvoiceItemList) + { + if (ii.AmountTotal.HasValue) + { + ii.AmountTotal *= -1; + } + + if (ii.GrossAmountTotal.HasValue) + { + ii.GrossAmountTotal *= -1; + } + } + } + } + + private void CopyServiceInvoice(ServiceInvoice existingInvoice, ServiceInvoice copyInvoice) + { + copyInvoice.AmountAdvancePayments = existingInvoice.AmountAdvancePayments; + copyInvoice.AmountEquityContribution = existingInvoice.AmountEquityContribution; + copyInvoice.ServiceUnitOid = existingInvoice.ServiceUnitOid; + + + CopyInvoiceBase(existingInvoice.InvoiceBase, copyInvoice.InvoiceBase); + + foreach (var sip in existingInvoice.ServiceInvoicePeriodList) + { + var copySip = new ServiceInvoicePeriod(); + copyInvoice.ServiceInvoicePeriodList.Add(copySip); + + CopyServiceInvoicePeriod(sip, copySip); + } + } + + //private void CopySettlementInvoice(SettlementInvoice existingInvoice, SettlementInvoice copyInvoice) + // { + + // CopyInvoiceBase(existingInvoice.InvoiceBase, copyInvoice.InvoiceBase); + + + // } + + private void CopyInvoiceBase(InvoiceBase existing, InvoiceBase copy) + { + copy.AccountingPeriodEnd = existing.AccountingPeriodEnd; + copy.AccountingPeriodStart = existing.AccountingPeriodStart; + copy.CostBearer2SupportConcept = existing.CostBearer2SupportConcept; + copy.CreatorFirstName = existing.CreatorFirstName; + copy.CreatorLastName = existing.CreatorLastName; + copy.CustomerReferenceNumber = existing.CustomerReferenceNumber; + copy.DueDate = existing.DueDate; + copy.DunningLetterCount = existing.DunningLetterCount; + copy.InvoiceDate = existing.InvoiceDate; + copy.InvoiceId = existing.InvoiceId; + copy.InvoiceNumber = existing.InvoiceNumber; + copy.InvoiceTitle = existing.InvoiceTitle; + copy.InvoiceTypeText = existing.InvoiceTypeText; + copy.IsPaid = existing.IsPaid; + copy.IsPrinted = existing.IsPrinted; + copy.RecipientCostBearerOid = existing.RecipientCostBearerOid; + copy.RecipientCustomerOid = existing.RecipientCustomerOid; + copy.RecipientDivision = existing.RecipientDivision; + copy.RecipientOrganisation = existing.RecipientOrganisation; + copy.RecipientOrganisationOid = existing.RecipientOrganisationOid; + copy.RecipientPersonFirstName = existing.RecipientPersonFirstName; + copy.RecipientPersonLastName = existing.RecipientPersonLastName; + copy.RecipientPersonOid = existing.RecipientPersonOid; + copy.SenderDivision = existing.SenderDivision; + copy.SenderFirstName = existing.SenderFirstName; + copy.SenderLastName = existing.SenderLastName; + copy.SenderOrganisation = existing.SenderOrganisation; + copy.SupportConceptOid = existing.SupportConceptOid; + copy.Type = existing.Type; + copy.XMLData = existing.XMLData; + + foreach (var ii in existing.InvoiceItems) + { + var copyItem = new InvoiceItem(); + copy.InvoiceItems.Add(copyItem); + + CopyInvoiceItem(ii, copyItem); + + } + + if (existing.RecipientAddress != null) + { + copy.RecipientAddress = CreateCopyAddress(existing.RecipientAddress); + } + + if (existing.RecipientContacts != null) + { + copy.RecipientContacts = new List(); + foreach (var existingContact in existing.RecipientContacts) + { + copy.RecipientContacts.Add(CreateCopyContact(existingContact)); + } + } + + if (existing.SenderAddress != null) + { + copy.SenderAddress = existing.SenderAddress; + } + + if (existing.SenderContacts != null) + { + copy.SenderContacts = new List(); + foreach (var existingContact in existing.SenderContacts) + { + copy.SenderContacts.Add(CreateCopyContact(existingContact)); + } + } + + } + + public void CopyInvoiceBaseDC(InvoiceBaseDC orgRechnung, ServiceInvoiceDC diffRechnung) + { + diffRechnung.InvoiceBase.DiffErstellen = true; + diffRechnung.InvoiceBase.AccountingPeriodStart = orgRechnung.AccountingPeriodStart; + diffRechnung.InvoiceBase.AccountingPeriodEnd = orgRechnung.AccountingPeriodEnd; + diffRechnung.InvoiceBase.CustomerLastName = orgRechnung.CustomerLastName; + diffRechnung.InvoiceBase.CustomerFirstName = orgRechnung.CustomerFirstName; + diffRechnung.InvoiceBase.CustomerReferenceNumber = orgRechnung.CustomerReferenceNumber; + diffRechnung.InvoiceBase.InvoiceBaseOid = orgRechnung.InvoiceBaseOid; + diffRechnung.InvoiceBase.InvoiceDate = orgRechnung.InvoiceDate; + diffRechnung.InvoiceBase.InvoiceId = orgRechnung.InvoiceId; + diffRechnung.InvoiceBase.InvoiceNumber = orgRechnung.InvoiceNumber; + diffRechnung.InvoiceBase.InvoiceTitle = orgRechnung.InvoiceTitle; + diffRechnung.InvoiceBase.InvoiceTypeText = orgRechnung.InvoiceTypeText; + diffRechnung.InvoiceBase.RecipientAddressLine1 = orgRechnung.RecipientAddressLine1; + diffRechnung.InvoiceBase.RecipientAddressOid = orgRechnung.RecipientAddressOid; + diffRechnung.InvoiceBase.RecipientAddressVersion = orgRechnung.RecipientAddressVersion; + diffRechnung.InvoiceBase.RecipientContactInformations = orgRechnung.RecipientContactInformations; + diffRechnung.InvoiceBase.RecipientCostBearerOid = orgRechnung.RecipientCostBearerOid; + diffRechnung.InvoiceBase.RecipientCustomerOid = orgRechnung.RecipientCustomerOid; + diffRechnung.InvoiceBase.RecipientDivision = orgRechnung.RecipientDivision; + diffRechnung.InvoiceBase.RecipientOrganisation = orgRechnung.RecipientOrganisation; + diffRechnung.InvoiceBase.RecipientOrganisationOid = orgRechnung.RecipientOrganisationOid; + diffRechnung.InvoiceBase.RecipientPersonFirstName = orgRechnung.RecipientPersonFirstName; + diffRechnung.InvoiceBase.RecipientPersonLastName = orgRechnung.RecipientPersonLastName; + diffRechnung.InvoiceBase.RecipientPersonOid = orgRechnung.RecipientPersonOid; + diffRechnung.InvoiceBase.RecipientPostCode = orgRechnung.RecipientPostCode; + diffRechnung.InvoiceBase.RecipientSalutationAddressField = orgRechnung.RecipientSalutationAddressField; + diffRechnung.InvoiceBase.RecipientStreet = orgRechnung.RecipientStreet; + diffRechnung.InvoiceBase.RecipientTown = orgRechnung.RecipientTown; + diffRechnung.InvoiceBase.SenderAddressOid = orgRechnung.SenderAddressOid; + diffRechnung.InvoiceBase.SenderAddressVersion = orgRechnung.SenderAddressVersion; + diffRechnung.InvoiceBase.SenderContactInformations = orgRechnung.SenderContactInformations; + diffRechnung.InvoiceBase.SenderDivision = orgRechnung.SenderDivision; + diffRechnung.InvoiceBase.SenderFirstName = orgRechnung.SenderFirstName; + diffRechnung.InvoiceBase.SenderLastName = orgRechnung.SenderLastName; + diffRechnung.InvoiceBase.SenderOrganisation = orgRechnung.SenderOrganisation; + diffRechnung.InvoiceBase.SenderPostCode = orgRechnung.SenderPostCode; + diffRechnung.InvoiceBase.SenderStreet = orgRechnung.SenderStreet; + diffRechnung.InvoiceBase.SenderTown = orgRechnung.SenderTown; + diffRechnung.InvoiceBase.SupportConceptCostBearerRelDc = orgRechnung.SupportConceptCostBearerRelDc; + diffRechnung.InvoiceBase.SupportConceptOid = orgRechnung.SupportConceptOid; + diffRechnung.InvoiceBase.TotalAmount = orgRechnung.TotalAmount; + diffRechnung.InvoiceBase.Type = orgRechnung.Type; + } + + private Contact CreateCopyContact(Contact existingContact) + { + Contact newContact = new Contact(); + newContact.Value = existingContact.Value; + newContact.Type = existingContact.Type; + + return newContact; + } + + private Address CreateCopyAddress(Address address) + { + Address newAddress = new Address(); + newAddress.AddressLine1 = address.AddressLine1; + newAddress.AddressLine2 = address.AddressLine2; + newAddress.Country = address.Country; + newAddress.PostalCode = address.PostalCode; + newAddress.State = address.State; + newAddress.Street = address.Street; + newAddress.Town = address.Town; + + return newAddress; + } + + private void CopyServiceInvoicePeriod(ServiceInvoicePeriod existingSip, ServiceInvoicePeriod copySip) + { + copySip.AccountingInterval = existingSip.AccountingInterval; + copySip.ApprovedAmountDefaultHourlyRate = existingSip.ApprovedAmountDefaultHourlyRate; + copySip.ApprovedBE = existingSip.ApprovedBE; + copySip.ApprovedFixedAmount = existingSip.ApprovedFixedAmount; + copySip.ApprovedHours = existingSip.ApprovedHours; + copySip.Claim = existingSip.Claim; + copySip.End = existingSip.End; + copySip.HoursNotBillableAbsence = existingSip.HoursNotBillableAbsence; + copySip.HoursNotBillableNotApproved = existingSip.HoursNotBillableNotApproved; + copySip.ServiceUnitName = existingSip.ServiceUnitName; + copySip.Start = existingSip.Start; + copySip.Notice = existingSip.Notice; + copySip.Customer = existingSip.Customer; + copySip.SupportConceptApprovalPeriod = existingSip.SupportConceptApprovalPeriod; + + foreach (var ii in existingSip.InvoiceItemList) + { + var copyItem = new InvoiceItem(); + copySip.InvoiceItemList.Add(copyItem); + + CopyInvoiceItem(ii, copyItem); + } + + } + + private void CopyInvoiceItem(InvoiceItem existingItem, InvoiceItem copyItem) + { + copyItem.AccountingInterval = existingItem.AccountingInterval; + copyItem.AmountPerUnit = existingItem.AmountPerUnit; + copyItem.AmountTotal = existingItem.AmountTotal; + copyItem.ApprovalUnit = existingItem.AccountingInterval; + copyItem.ApprovedPerUnit = existingItem.ApprovedPerUnit; + copyItem.GrossAmountTotal = existingItem.GrossAmountTotal; + copyItem.ItemDescription = existingItem.ItemDescription; + copyItem.ItemPeriodEnd = existingItem.ItemPeriodEnd; + copyItem.ItemPeriodStart = existingItem.ItemPeriodStart; + copyItem.MaxApprovedAmount = existingItem.MaxApprovedAmount; + copyItem.MaxApprovedUnitCount = existingItem.MaxApprovedUnitCount; + copyItem.RateFactor = existingItem.RateFactor; + copyItem.ReceivedAmount = existingItem.ReceivedAmount; + copyItem.SupportConceptApprovalPeriodOid = existingItem.SupportConceptApprovalPeriodOid; + copyItem.UnitCount = existingItem.UnitCount; + copyItem.UnitDescription = existingItem.UnitDescription; + copyItem.Notice = existingItem.Notice; + copyItem.ServiceRecord = existingItem.ServiceRecord; + } + + public virtual Settlement2DC ErstelleDifferenzSpitzabrechnung(Settlement2DC neueRechnung, Settlement2DC letzteRechnung) + { + var diff = neueRechnung.Claim - letzteRechnung.Claim; + var ii = new InvoiceItemDC(); + + neueRechnung.Claim = diff; + neueRechnung.InvoiceItems = new List(); + neueRechnung.InvoiceItems.Add(ii); + + return neueRechnung; + } + + public virtual AddressInformation GetAddressInformation(long? customer_oid = null) + { + var user = UserRightHelper.GetLoggedInUser().Employee; + var mandator = AppSettings.GetMandatorEntity(); + + return new AddressInformation() + { + IKLeistungserbringer = mandator.IKLeistungserbringer, + Fax = user.Person.Contacts.FirstOrDefault(x => x.Type == ContactType.business_Fax)?.Value.ToNullIfEmpty(), + Mail = user.Person.Contacts.FirstOrDefault(x => x.Type == ContactType.business_Mail)?.Value.ToNullIfEmpty(), + Phone = user.Person.Contacts.FirstOrDefault(x => x.Type == ContactType.business_Phone)?.Value.ToNullIfEmpty(), + OrganisationName = mandator.Name, + PostCode = mandator.PostalCode, + Street = mandator.Street, + Town = mandator.Town, + Website = mandator.Website + }; + } + } + + public class DifferenzRechnungCheck + { + public ServiceInvoiceDC NeueRechnung { get; set; } + public IList VorhandeneRechungen { get; set; } + } } \ No newline at end of file diff --git a/Service/Plugins/PluginLoader.cs b/Service/Plugins/PluginLoader.cs index 6b132a220..6dc018f2a 100644 --- a/Service/Plugins/PluginLoader.cs +++ b/Service/Plugins/PluginLoader.cs @@ -50,7 +50,7 @@ namespace BeWo.Service.Plugins //t = "2499262621"; // HPH Bersenbrück //t = "4950382346"; // Holsinger //t = "5973016645"; // Verein Lebensgestaltung Hanau - //t = "7375324044"; // Diakonie KK Kleve + t = "7375324044"; // Diakonie KK Kleve //t = "1441747891"; // BeWo Mobil Köln //t = "5120047701"; // Trialog //t = "3629696651"; // Soziale Dienste Niederrhein (SDN) diff --git a/Service/ServiceImplementations/AccountingServiceImp.cs b/Service/ServiceImplementations/AccountingServiceImp.cs index d786d3735..9e4daf50f 100644 --- a/Service/ServiceImplementations/AccountingServiceImp.cs +++ b/Service/ServiceImplementations/AccountingServiceImp.cs @@ -27,6 +27,7 @@ using BS.Shared.DataContracts.GkvAbrechnung; using BS.Shared.Extensions; using BS.Shared.Exceptions; using BS.Shared.AppSender; +using BeWo.Data.Security; namespace BeWo.Service.ServiceImplementations { @@ -819,6 +820,10 @@ namespace BeWo.Service.ServiceImplementations try { + var invoice_bases = DAOFactory.GenericDAO.LoadByIDs(request.SelectedInvoiceBases); + + ValidatorExtended.ValidateGkvAbrechnung(request.GkvAbrechnungDC, invoice_bases); + var gkv_abrechnung = MapperFactory.GkvAbrechnungDC_GkvAbrechnung.MapToNewEntity(request.GkvAbrechnungDC); if (gkv_abrechnung.AbrechnungsZeitraumEnde.Value.Hour == 0) @@ -834,9 +839,6 @@ namespace BeWo.Service.ServiceImplementations foreach (var invoicebase_oid in request.SelectedInvoiceBases) { var service = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoicebase_oid); - var invoicebase = DAOFactory.GenericDAO.GetByID(invoicebase_oid); - - var invoicebase_dc = MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDC(invoicebase); foreach (var peroid in service.ServiceInvoicePeriodList) { @@ -861,10 +863,16 @@ namespace BeWo.Service.ServiceImplementations } catch (GkvException exc) { + MailUtils.SendGkvModuleErrorMail("CreateNewGkvAbrechnung", exc, Tenant); + + if (exc.Title.IsNotNullOrWhiteSpace()) + response.TitleMessage = exc.Title; response.Message = exc.Message; } catch (Exception e) { + MailUtils.SendGkvModuleErrorMail("CreateNewGkvAbrechnung", e, Tenant); + throw Utils.CreateBeWoFaultException(e); } @@ -926,15 +934,15 @@ namespace BeWo.Service.ServiceImplementations GkvAbrechnungOid = entity.Oid.Value }; + if (entity.GkvTransferProtokolle is null) + entity.GkvTransferProtokolle = new List(); + + entity.GkvTransferProtokolle.Add(protokoll); + try { CreateGkvTransferProtokoll(oid, entity, protokoll); - if (entity.GkvTransferProtokolle is null) - entity.GkvTransferProtokolle = new List(); - - entity.GkvTransferProtokolle.Add(protokoll); - // Protokoll braucht Oid DAOFactory.GenericDAO.Update(entity); @@ -1022,6 +1030,8 @@ namespace BeWo.Service.ServiceImplementations { try { + ValidatorExtended.ValidateGkvAbrechnung(gkvAbrechnung, gkvAbrechnung.InvoiceBases); + var manager = new DakotaManager(); var mandatordc = new OperationsServiceImp().GetMandator(); @@ -1039,6 +1049,23 @@ namespace BeWo.Service.ServiceImplementations protokoll.Datenaustauschreferenz = datenaustauschreferenz; protokoll.Transfernummer = transfernummer; + var first_cost = gkvAbrechnung.InvoiceBases.First().CostBearer2SupportConcept.SupportConcept.Customer; + + var plugin = PluginLoader.FindClass(); + var addressInfo = plugin.GetAddressInformation(first_cost.Oid); + + foreach (var invoicebase in gkvAbrechnung.InvoiceBases) + { + var customer = invoicebase.CostBearer2SupportConcept.SupportConcept.Customer; + + var addressInfo2 = plugin.GetAddressInformation(customer.Oid); + + if (addressInfo.IKLeistungserbringer != addressInfo2.IKLeistungserbringer) + { + throw new GkvException($"Klient '{first_cost.Person.LastNameFirstName}' ({addressInfo.IKLeistungserbringer}) und '{customer.Person.LastNameFirstName}' ({addressInfo2.IKLeistungserbringer}) verweisen auf unterschiedliche Leistungserbringer."); + } + } + foreach (var invoicebase in gkvAbrechnung.InvoiceBases) { var service = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoicebase.Oid.Value); @@ -1052,7 +1079,7 @@ namespace BeWo.Service.ServiceImplementations Validator.ValidateCustomer(customerdc); - manager.Add(servicedc, orgadc, customerdc, mandatordc, dat_short, tra_short); + manager.Add(servicedc, orgadc, customerdc, addressInfo, dat_short, tra_short); } manager.Apply(); @@ -1061,8 +1088,6 @@ namespace BeWo.Service.ServiceImplementations { var msg = "Unerwartete Anzahl an Dakota Files berechnet."; - MailUtils.SendGkvModuleErrorMail("CreateGkvTransferProtokoll", msg, Tenant); - throw new GkvException(msg); } @@ -1087,8 +1112,6 @@ namespace BeWo.Service.ServiceImplementations { var msg = $"nutzdatendatei - Länger als 16777215: {nutzdatendatei.Length}"; - MailUtils.SendGkvModuleErrorMail("CreateGkvTransferProtokoll", msg, Tenant); - throw new GkvException(msg); } @@ -1114,6 +1137,8 @@ namespace BeWo.Service.ServiceImplementations if (string.IsNullOrEmpty(de.Title)) de.Title = "Protokoll Erstellung"; + MailUtils.SendGkvModuleErrorMail("CreateGkvTransferProtokoll", de, Tenant); + throw de; } catch (Exception e) diff --git a/Shared/Core/SettingsKeys.cs b/Shared/Core/SettingsKeys.cs index 7823c1fed..6dd7678e6 100644 --- a/Shared/Core/SettingsKeys.cs +++ b/Shared/Core/SettingsKeys.cs @@ -105,5 +105,8 @@ // Keys für das neue Kalendermodul public static string SchedulingViewType => "SchedulingViewType"; + + public static string ShowGkvBzEinzel => "ShowGkvBzEinzel"; + public static string ShowGkvBzUrbelege => "ShowGkvBzUrbelege"; } } diff --git a/Shared/Core/ValidatorExtended.cs b/Shared/Core/ValidatorExtended.cs new file mode 100644 index 000000000..25f3f0ccd --- /dev/null +++ b/Shared/Core/ValidatorExtended.cs @@ -0,0 +1,46 @@ +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.GkvAbrechnung; +using BS.Shared.Exceptions; +using BS.Shared.Extensions; +using BS.Shared.Interface; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.Shared.Core +{ + public static class ValidatorExtended + { + public static void ValidateGkvAbrechnung(IGkvAbrechnung gkvAbrechnung, IEnumerable invoiceBases, bool testInvoicesEmpty = true) + { + string error = null; + + if (testInvoicesEmpty && !invoiceBases.Any()) + error = "Keine Rechnungen gefunden"; + else if (!AreAllAddressSame(invoiceBases)) + error = "Unterschiedliche Rechnungspositionen"; + + if(error is string) + throw new GkvException(error, "Validierung"); + } + + public static bool TryValidateGkvAbrechnung(IGkvAbrechnung gkvAbrechnung, IEnumerable invoiceBases, bool testInvoicesEmpty = true) + { + try + { + ValidateGkvAbrechnung(gkvAbrechnung, invoiceBases, testInvoicesEmpty); + } + catch (Exception) + { + return false; + } + + return true; + } + + public static bool AreAllAddressSame(IEnumerable invoiceBases) + => invoiceBases.Select(x => x.SenderAddressToString()).AreAllTheSame(); + } +} diff --git a/Shared/DataContracts/AppResponseDC.cs b/Shared/DataContracts/AppResponseDC.cs index f088fa02b..90994c38b 100644 --- a/Shared/DataContracts/AppResponseDC.cs +++ b/Shared/DataContracts/AppResponseDC.cs @@ -12,6 +12,7 @@ namespace BS.Shared.DataContracts { [DataMember] public bool Success { get; set; } [DataMember] public string Message { get; set; } + [DataMember] public string TitleMessage { get; set; } public AppResponseDC(bool success) { @@ -22,5 +23,10 @@ namespace BS.Shared.DataContracts { Message = message; } + + public AppResponseDC(bool success, string message, string title) : this(success, message) + { + TitleMessage = title; + } } } diff --git a/Shared/DataContracts/GkvAbrechnung/GkvResponseDC.cs b/Shared/DataContracts/GkvAbrechnung/GkvResponseDC.cs index 123384dc0..8e51ff31d 100644 --- a/Shared/DataContracts/GkvAbrechnung/GkvResponseDC.cs +++ b/Shared/DataContracts/GkvAbrechnung/GkvResponseDC.cs @@ -13,5 +13,6 @@ namespace BS.Shared.DataContracts.GkvAbrechnung public GkvResponseDC() : base(false) { } public GkvResponseDC(bool success) : base(success) { } public GkvResponseDC(bool success, string message) : base(success, message) { } + public GkvResponseDC(bool success, string message, string title) : base(success, message, title) { } } } diff --git a/Shared/DataContracts/InvoiceBaseDC.cs b/Shared/DataContracts/InvoiceBaseDC.cs index c3182508d..ef00aa5b9 100644 --- a/Shared/DataContracts/InvoiceBaseDC.cs +++ b/Shared/DataContracts/InvoiceBaseDC.cs @@ -3,251 +3,134 @@ using System.Collections.Generic; using System.Runtime.Serialization; using BS.Shared.Core; +using BS.Shared.Interface; namespace BS.Shared.DataContracts { - [DataContract] - public partial class InvoiceBaseDC : IDataContract - { - private List _RecipientContactInformations; + [DataContract] + public partial class InvoiceBaseDC : IDataContract, IInvoiceBase + { + private List _RecipientContactInformations; - private List _SenderContactInformations; + private List _SenderContactInformations; - [DataMember] - public DateTime? AccountingPeriodEnd { get; set; } + [DataMember] public DateTime? AccountingPeriodEnd { get; set; } + [DataMember] public DateTime? AccountingPeriodStart { get; set; } + [DataMember] public string CreatorFirstName { get; set; } + [DataMember] public string CreatorLastName { get; set; } + [DataMember] public bool? IsAlreadyInActiveGkvAbrechnung { get; set; } + [DataMember] public bool IsGkvValid { get; set; } + [DataMember] public string IsGkvValidError { get; set; } + [DataMember] public long CustomerOid { get; set; } + [DataMember] public string CustomerFirstName { get; set; } + [DataMember] public string CustomerLastName { get; set; } + [DataMember] public string CustomerReferenceNumber { get; set; } + [DataMember] public DateTime? DueDate { get; set; } + [DataMember] public int? DunningLetterCount { get; set; } + [DataMember] public long? InvoiceBaseOid { get; set; } + [DataMember] public long? InvoiceBaseVersion { get; set; } + [DataMember] public DateTime? InvoiceDate { get; set; } + [DataMember] public List InvoiceItems { get; set; } + [DataMember] public string InvoiceNumber { get; set; } + [DataMember] public string InvoiceTitle { get; set; } + [DataMember] public bool IsReviewed { get; set; } + [DataMember] public bool IsSent { get; set; } + [DataMember] public bool IsExported { get; set; } + [DataMember] public bool IsPaid { get; set; } + [DataMember] public string PartialPayment { get; set; } + [DataMember] public bool NeuErstellen { get; set; } + [DataMember] public bool DiffErstellen { get; set; } + [DataMember] public string Notice { get; set; } + [DataMember] public string Details { get; set; } + [DataMember] public string Hinweise { get; set; } + [DataMember] public string InvoiceId { get; set; } + [DataMember] public string InvoiceTypeText { get; set; } + public string PeriodString + { + get + { + return this.AccountingPeriodStart.Value.ToShortDateString() + " - " + + this.AccountingPeriodEnd.Value.ToShortDateString(); + } + } - [DataMember] - public DateTime? AccountingPeriodStart { get; set; } - - [DataMember] - public string CreatorFirstName { get; set; } - - [DataMember] - public string CreatorLastName { get; set; } - - [DataMember] - public bool? IsAlreadyInActiveGkvAbrechnung { get; set; } - - [DataMember] - public bool IsGkvValid { get; set; } - - [DataMember] - public string IsGkvValidError { get; set; } - - [DataMember] - public string CustomerFirstName { get; set; } - - [DataMember] - public string CustomerLastName { get; set; } - - [DataMember] - public string CustomerReferenceNumber { get; set; } - - [DataMember] - public DateTime? DueDate { get; set; } - - [DataMember] - public int? DunningLetterCount { get; set; } - - [DataMember] - public long? InvoiceBaseOid { get; set; } - - [DataMember] - public long? InvoiceBaseVersion { get; set; } - - [DataMember] - public DateTime? InvoiceDate { get; set; } - - [DataMember] - public List InvoiceItems { get; set; } - - [DataMember] - public string InvoiceNumber { get; set; } - - [DataMember] - public string InvoiceTitle { get; set; } - - [DataMember] - public bool IsReviewed { get; set; } - - [DataMember] - public bool IsSent { get; set; } - - [DataMember] - public bool IsExported { get; set; } - - [DataMember] - public bool IsPaid { get; set; } - - [DataMember] - public string PartialPayment { get; set; } - - [DataMember] - public bool NeuErstellen { get; set; } - - [DataMember] - public bool DiffErstellen { get; set; } - - [DataMember] - public string Notice { get; set; } - - [DataMember] - public string Details { get; set; } - - [DataMember] - public string Hinweise { get; set; } - - [DataMember] - public string InvoiceId { get; set; } + [DataMember] public long? RecipientAddressOid { get; set; } + [DataMember] public long? RecipientAddressVersion { get; set; } + [DataMember] public long? RecipientCostBearerOid { get; set; } + [DataMember] public long? RecipientCustomerOid { get; set; } + [DataMember] public string RecipientDivision { get; set; } + [DataMember] public string RecipientOrganisation { get; set; } + [DataMember] public long? RecipientOrganisationOid { get; set; } + [DataMember] public string RecipientPersonFirstName { get; set; } + [DataMember] public string RecipientPersonLastName { get; set; } + [DataMember] public string RecipientSalutationAddressField { get; set; } + [DataMember] public long? RecipientPersonOid { get; set; } + [DataMember] public string RecipientPostCode { get; set; } + [DataMember] public string RecipientAddressLine1 { get; set; } + [DataMember] public string RecipientStreet { get; set; } + [DataMember] public string RecipientTown { get; set; } + [DataMember] public long? SenderAddressOid { get; set; } + [DataMember] public long? SenderAddressVersion { get; set; } + [DataMember] public string SenderDivision { get; set; } + [DataMember] public string SenderFirstName { get; set; } + [DataMember] public string SenderLastName { get; set; } + [DataMember] public string SenderOrganisation { get; set; } + [DataMember] public string SenderPostCode { get; set; } + [DataMember] public string SenderStreet { get; set; } + [DataMember] public string SenderTown { get; set; } + [DataMember] public SupportConceptCostBearerRelDC SupportConceptCostBearerRelDc { get; set; } + [DataMember] public long? SupportConceptOid { get; set; } + [DataMember] public decimal? TotalAmount { get; set; } + [DataMember] public InvoiceType Type { get; set; } + [DataMember] public long? StornoInvoiceBaseOid { get; set; } + [DataMember] public String BackgroundColor { get; set; } [DataMember] - public string InvoiceTypeText { get; set; } + public List RecipientContactInformations + { + get + { + if (this._RecipientContactInformations == null) + { + this._RecipientContactInformations = new List(); + } - public string PeriodString - { - get - { - return this.AccountingPeriodStart.Value.ToShortDateString() + " - " - + this.AccountingPeriodEnd.Value.ToShortDateString(); - } - } + return this._RecipientContactInformations; + } - [DataMember] - public long? RecipientAddressOid { get; set; } + set + { + this._RecipientContactInformations = value; + } + } - [DataMember] - public long? RecipientAddressVersion { get; set; } + [DataMember] + public List SenderContactInformations + { + get + { + if (this._SenderContactInformations == null) + { + this._SenderContactInformations = new List(); + } - [DataMember] - public List RecipientContactInformations - { - get - { - if (this._RecipientContactInformations == null) - { - this._RecipientContactInformations = new List(); - } + return this._SenderContactInformations; + } - return this._RecipientContactInformations; - } + set + { + this._SenderContactInformations = value; + } + } - set - { - this._RecipientContactInformations = value; - } - } + public bool ContainsRecipientAddressData() + { + return !Utils.AreAllNullOrEmpty(this.RecipientStreet, this.RecipientPostCode, this.RecipientTown); + } - [DataMember] - public long? RecipientCostBearerOid { get; set; } - - [DataMember] - public long? RecipientCustomerOid { get; set; } - - [DataMember] - public string RecipientDivision { get; set; } - - [DataMember] - public string RecipientOrganisation { get; set; } - - [DataMember] - public long? RecipientOrganisationOid { get; set; } - - [DataMember] - public string RecipientPersonFirstName { get; set; } - - [DataMember] - public string RecipientPersonLastName { get; set; } - - [DataMember] - public string RecipientSalutationAddressField { get; set; } - - [DataMember] - public long? RecipientPersonOid { get; set; } - - [DataMember] - public string RecipientPostCode { get; set; } - - [DataMember] - public string RecipientAddressLine1 { get; set; } - - [DataMember] - public string RecipientStreet { get; set; } - - [DataMember] - public string RecipientTown { get; set; } - - [DataMember] - public long? SenderAddressOid { get; set; } - - [DataMember] - public long? SenderAddressVersion { get; set; } - - [DataMember] - public List SenderContactInformations - { - get - { - if (this._SenderContactInformations == null) - { - this._SenderContactInformations = new List(); - } - - return this._SenderContactInformations; - } - - set - { - this._SenderContactInformations = value; - } - } - - [DataMember] - public string SenderDivision { get; set; } - - [DataMember] - public string SenderFirstName { get; set; } - - [DataMember] - public string SenderLastName { get; set; } - - [DataMember] - public string SenderOrganisation { get; set; } - - [DataMember] - public string SenderPostCode { get; set; } - - [DataMember] - public string SenderStreet { get; set; } - - [DataMember] - public string SenderTown { get; set; } - - [DataMember] - public SupportConceptCostBearerRelDC SupportConceptCostBearerRelDc { get; set; } - - [DataMember] - public long? SupportConceptOid { get; set; } - - [DataMember] - public decimal? TotalAmount { get; set; } - - [DataMember] - public InvoiceType Type { get; set; } - - [DataMember] - public long? StornoInvoiceBaseOid { get; set; } - - [DataMember] - public String BackgroundColor { get; set; } - - public bool ContainsRecipientAddressData() - { - return !Utils.AreAllNullOrEmpty(this.RecipientStreet, this.RecipientPostCode, this.RecipientTown); - } - - public bool ContainsSenderAddressData() - { - return !Utils.AreAllNullOrEmpty(this.SenderStreet, this.SenderPostCode, this.SenderTown); - } - } + public bool ContainsSenderAddressData() + { + return !Utils.AreAllNullOrEmpty(this.SenderStreet, this.SenderPostCode, this.SenderTown); + } + } } \ No newline at end of file diff --git a/Shared/DataContracts/MandatorDC.cs b/Shared/DataContracts/MandatorDC.cs index 2cdbbddd6..e914be9ba 100644 --- a/Shared/DataContracts/MandatorDC.cs +++ b/Shared/DataContracts/MandatorDC.cs @@ -1,6 +1,7 @@ using BS.Shared.DataContracts.Compact; using BS.Shared.DataContracts.Invoicing; using System.Runtime.Serialization; +using System.Windows.Media; namespace BS.Shared.DataContracts { @@ -31,5 +32,9 @@ namespace BS.Shared.DataContracts [DataMember] public string CanEditIKLeistungserbringerTooltip { get; set; } [DataMember] public CompactEmployeeDC SoziotherapieAnsprechpartner { get; set; } [DataMember] public ImageDC Logo { get; set; } + [DataMember] public string ColorWaitTooLong { get; set; } + [DataMember] public string ColorSendUrbelege { get; set; } + [DataMember] public bool ShowGkvBzEinzel { get; set; } + [DataMember] public bool ShowGkvBzUrbelege { get; set; } } } \ No newline at end of file diff --git a/Shared/Extensions/ColorExtensions.cs b/Shared/Extensions/ColorExtensions.cs index e3d4795af..010b59a4a 100644 --- a/Shared/Extensions/ColorExtensions.cs +++ b/Shared/Extensions/ColorExtensions.cs @@ -78,5 +78,18 @@ namespace BS.Shared.Extensions } public static bool IsBrighter(this Color c, double threshold) => c.GetBrightness() > threshold; + + public static Color Parse(string str) + { + return (Color)ColorConverter.ConvertFromString(str); + } + + public static SolidColorBrush ParseSolidColorBrush(string str) + { + if (str is null) + return null; + + return (SolidColorBrush)new BrushConverter().ConvertFrom(str); + } } } \ No newline at end of file diff --git a/Shared/Extensions/StringExtensions.cs b/Shared/Extensions/StringExtensions.cs index cb8fa89e2..802851889 100644 --- a/Shared/Extensions/StringExtensions.cs +++ b/Shared/Extensions/StringExtensions.cs @@ -1,4 +1,5 @@ -using System; +using BS.Shared.Interface; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; @@ -88,10 +89,12 @@ namespace BS.Shared.Extensions return pString?.Replace("ẞ", "ß"); } + public static bool IsNotNullOrWhiteSpace(this string pString) + => !pString.IsNullOrWhiteSpace(); + public static bool IsNullOrWhiteSpace(this string str) + => string.IsNullOrEmpty(str); public static string ToNullIfEmpty(this string str) - { - return string.IsNullOrWhiteSpace(str) ? null : str; - } + => str.IsNullOrWhiteSpace() ? null : str; public static string ToFormatFollows(this string str1, string str2, char seperator = ' ') { @@ -110,5 +113,23 @@ namespace BS.Shared.Extensions return rtn; } + + public static bool AreAllTheSame(this IEnumerable list) + { + if (list is null || !list.Any()) + return true; + + string init = list.First(); + foreach (var str in list) + { + if (str != init) + return false; + } + + return true; + } + + public static string SenderAddressToString(this IInvoiceBase invoiceBase) + => $"{invoiceBase.SenderStreet}, {invoiceBase.SenderTown}, {invoiceBase.SenderPostCode}"; } } \ No newline at end of file diff --git a/Shared/Interface/IInvoiceBase.cs b/Shared/Interface/IInvoiceBase.cs new file mode 100644 index 000000000..01d69f634 --- /dev/null +++ b/Shared/Interface/IInvoiceBase.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.Shared.Interface +{ + public interface IInvoiceBase + { + string SenderStreet { get; } + string SenderTown { get; } + string SenderPostCode { get; } + } +} diff --git a/Shared/ReportRequests/GkvAbrechnungReportRequest.cs b/Shared/ReportRequests/GkvAbrechnungReportRequest.cs index 13678b14a..6652a4969 100644 --- a/Shared/ReportRequests/GkvAbrechnungReportRequest.cs +++ b/Shared/ReportRequests/GkvAbrechnungReportRequest.cs @@ -11,23 +11,27 @@ namespace BS.Shared.ReportRequests public class GkvAbrechnungReportRequest : AbstractReportRequest { public const string PropertyStringOid = "oid"; + public const string PropertyStringUrbelege = "urb"; public long Oid { get; set; } + public bool AddUrbelege { get; set; } private GkvAbrechnungReportRequest() : base(ReportTypes.GkvAbrechnung) { } - public GkvAbrechnungReportRequest(long poid) : this() + public GkvAbrechnungReportRequest(long poid, bool urbelege) : this() { Oid = poid; + AddUrbelege = urbelege; } internal override NameValueCollection GetParameters() => new NameValueCollection() { - {PropertyStringOid, Oid.ToString() } + {PropertyStringOid, Oid.ToString() }, + {PropertyStringUrbelege, AddUrbelege.ToString() }, }; public static GkvAbrechnungReportRequest Parse(NameValueCollection collection) @@ -43,6 +47,9 @@ namespace BS.Shared.ReportRequests case PropertyStringOid: rtn.Oid = long.Parse(value); break; + case PropertyStringUrbelege: + rtn.AddUrbelege = bool.Parse(value); + break; default: break; } diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index 1d57c9864..8285ee89e 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -165,6 +165,7 @@ + @@ -364,6 +365,7 @@ +