diff --git a/ReportImp/BzhEssenGGmbH/BzhEssenGGmbH.csproj b/ReportImp/BzhEssenGGmbH/BzhEssenGGmbH.csproj
index 0a9d958d0..0fa425c9a 100644
--- a/ReportImp/BzhEssenGGmbH/BzhEssenGGmbH.csproj
+++ b/ReportImp/BzhEssenGGmbH/BzhEssenGGmbH.csproj
@@ -53,6 +53,9 @@
+
+
+
Component
diff --git a/ReportImp/BzhEssenGGmbH/Import/Abschlagszahlung.cs b/ReportImp/BzhEssenGGmbH/Import/Abschlagszahlung.cs
new file mode 100644
index 000000000..b329e658c
--- /dev/null
+++ b/ReportImp/BzhEssenGGmbH/Import/Abschlagszahlung.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BzhEssenGGmbH.Import
+{
+ public class Abschlagszahlung
+ {
+ //Auftragskonto; Buchungstag; Valutadatum; Buchungstext; Verwendungszweck; Glaeubiger ID; Mandatsreferenz; Kundenreferenz(End - to - End); Sammlerreferenz; Lastschrift Ursprungsbetrag; Auslagenersatz Ruecklastschrift;
+ //Beguenstigter / Zahlungspflichtiger; Kontonummer / IBAN; BIC(SWIFT - Code); Betrag; Waehrung; Info
+
+ //Umsatz (ohne Soll/Haben-Kz);Soll/Haben-Kennzeichen;WKZ Umsatz;Kurs;Basis-Umsatz;WKZ Basis-Umsatz;Konto;Gegenkonto (ohne BU-Schlüssel);BU-Schlüssel;Belegdatum;Belegfeld 1;Belegfeld 2;
+ //Skonto;Buchungstext;Postensperre;Diverse Adressnummer;Geschäftspartnerbank;Sachverhalt;Zinssperre;Beleglink;Beleginfo - Art 1;Beleginfo - Inhalt 1;Beleginfo - Art 2;Beleginfo - Inhalt 2;
+ //Beleginfo - Art 3;Beleginfo - Inhalt 3;Beleginfo - Art 4;Beleginfo - Inhalt 4;Beleginfo - Art 5;Beleginfo - Inhalt 5;Beleginfo - Art 6;Beleginfo - Inhalt 6;Beleginfo - Art 7;
+ //Beleginfo - Inhalt 7;Beleginfo - Art 8;Beleginfo - Inhalt 8;KOST1 - Kostenstelle;KOST2 - Kostenstelle;Kost-Menge;EU-Land u. UStID (Bestimmung);EU-Steuersatz (Bestimmung);
+ //Abw. Versteuerungsart;Sachverhalt L+L;Funktionsergänzung L+L;BU 49 Hauptfunktionstyp;BU 49 Hauptfunktionsnummer;BU 49 Funktionsergänzung;Zusatzinformation - Art 1;Zusatzinformation- Inhalt 1;
+ //Zusatzinformation - Art 2;Zusatzinformation- Inhalt 2;Zusatzinformation - Art 3;Zusatzinformation- Inhalt 3;Zusatzinformation - Art 4;Zusatzinformation- Inhalt 4;Zusatzinformation - Art 5;
+ //Zusatzinformation- Inhalt 5;Zusatzinformation - Art 6;Zusatzinformation- Inhalt 6;Zusatzinformation - Art 7;Zusatzinformation- Inhalt 7;Zusatzinformation - Art 8;Zusatzinformation- Inhalt 8;
+ //Zusatzinformation - Art 9;Zusatzinformation- Inhalt 9;Zusatzinformation - Art 10;Zusatzinformation- Inhalt 10;Zusatzinformation - Art 11;Zusatzinformation- Inhalt 11;Zusatzinformation - Art 12;
+ //Zusatzinformation- Inhalt 12;Zusatzinformation - Art 13;Zusatzinformation- Inhalt 13;Zusatzinformation - Art 14;Zusatzinformation- Inhalt 14;Zusatzinformation - Art 15;Zusatzinformation- Inhalt 15;
+ //Zusatzinformation - Art 16;Zusatzinformation- Inhalt 16;Zusatzinformation - Art 17;Zusatzinformation- Inhalt 17;Zusatzinformation - Art 18;Zusatzinformation- Inhalt 18;Zusatzinformation - Art 19;
+ //Zusatzinformation- Inhalt 19;Zusatzinformation - Art 20;Zusatzinformation- Inhalt 20;Stück;Gewicht;Zahlweise;Forderungsart;Veranlagungsjahr;Zugeordnete Fälligkeit;Skontotyp;Auftragsnummer;
+ //Buchungstyp (Anzahlungen);USt-Schlüssel (Anzahlungen);EU-Land (Anzahlungen);Sachverhalt L+L (Anzahlungen);EU-Steuersatz (Anzahlungen);Erlöskonto (Anzahlungen);Herkunft-Kz;Buchungs GUID;
+ //KOST-Datum;SEPA-Mandatsreferenz;Skontosperre;Gesellschaftername;Beteiligtennummer;Identifikationsnummer;Zeichnernummer;Postensperre bis;Bezeichnung SoBil-Sachverhalt;Kennzeichen SoBil-Buchung;
+ //Festschreibung;Leistungsdatum;Datum Zuord. Steuerperiode;Fälligkeit;Generalumkehr (GU);Steuersatz;Land;Abrechnungsreferenz;BVV-Position;EU-Land u. UStID (Ursprung);EU-Steuersatz (Ursprung)
+
+ public long Auftragskonto { get; set; }
+ public String Gegenkonto { get; set; }
+ public DateTime? Buchungstag { get; set; }
+ public DateTime? Valutadatum { get; set; }
+ public String Buchungstext { get; set; }
+ public String Verwendungszweck { get; set; }
+ public String GlaeubigerId { get; set; }
+ public String Mandatsreferenz { get; set; }
+ public String Kundenreferenz { get; set; }
+ public String Sammlerreferenz { get; set; }
+ public decimal LastschriftUrsprungsbetrag { get; set; }
+ public String AuslagenersatzRuecklastschrift { get; set; }
+ public String BeguenstigterZahlungspflichtiger { get; set; }
+ public String Iban { get; set; }
+ public String Bic { get; set; }
+ public decimal Betrag { get; set; }
+ public String Waehrung { get; set; }
+ public String Info { get; set; }
+
+
+ public String CustomerName { get; set; }
+ public String Aktenzeichen { get; set; }
+ public DateTime? DatumAnfang { get; set; }
+ public DateTime? DatumEnde { get; set; }
+ public DateTime? BescheidVom { get; set; }
+
+ }
+}
diff --git a/ReportImp/BzhEssenGGmbH/Import/AbschlagszahlungImport.cs b/ReportImp/BzhEssenGGmbH/Import/AbschlagszahlungImport.cs
new file mode 100644
index 000000000..219e7271a
--- /dev/null
+++ b/ReportImp/BzhEssenGGmbH/Import/AbschlagszahlungImport.cs
@@ -0,0 +1,252 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BeWo.Data.Access;
+using BeWo.Data.Entities;
+using BeWo.Service.MessageContracts;
+using BeWo.Service.Plugins;
+using DevExpress.XtraPrinting.Native;
+
+namespace BzhEssenGGmbH.Import
+{
+ public class AbschlagszahlungImport : DataImporter
+ {
+ private int bereitsVorhandenCount = 0;
+ private int importiertCount = 0;
+ private int keinDebitorCount = 0;
+ private string Debitornr;
+
+ public override UploadImportFileResult ImportData(string filename, byte[] daten)
+ {
+
+ String str = System.Text.Encoding.Default.GetString(daten);
+
+ var abschlagszahlungen = CreateAbschlagszahlungen(str);
+ var hilfeplaene = CreateHilfeplanInfos();
+
+ var importresult = ImportAbschlagszahlungen(abschlagszahlungen, hilfeplaene);
+
+
+ var result = new UploadImportFileResult();
+ result.Success = false;
+
+ String importDaten = "1 Datensatz";
+ String vorhandenDaten = "1 Datensatz";
+ String nichtImport = "";
+
+ if (importiertCount != 1)
+ {
+ importDaten = String.Format("{0} Datensätze", importiertCount);
+ }
+
+ if (bereitsVorhandenCount != 1)
+ {
+ vorhandenDaten = String.Format("{0} Datensätze", bereitsVorhandenCount);
+ }
+
+ if (String.IsNullOrEmpty(importresult))
+ {
+ result.ResultMessage = String.Format(
+ "Die Daten wurden erfolgreich importiert.\nEs wurden {0} neu importiert. {1} waren bereits vorhanden.",
+ importDaten, vorhandenDaten);
+ }
+ else
+ {
+ result.ResultMessage = String.Format("Die Daten wurden erfolgreich importiert.\nEs wurden {0} neu importiert. {1} waren bereits vorhanden.\n\nFolgende Zahlungen konnten nicht importiert werden:\n{2}", importDaten, vorhandenDaten, importresult);
+ }
+
+ return result;
+ }
+
+ private String ImportAbschlagszahlungen(List abschlagszahlungen, List hilfeplaene)
+ {
+ StringBuilder ergebnis = new StringBuilder();
+
+ foreach (var az in abschlagszahlungen)
+ {
+ bool importiert = false;
+ foreach (var hilfeplanInfo in hilfeplaene)
+ {
+ importiert = ImportAbschlagszahlung(az, hilfeplanInfo, ergebnis);
+ if (importiert)
+ break;
+ }
+
+ if (!importiert)
+ {
+ if (ergebnis.Length > 0)
+ ergebnis.Append("\n");
+ ergebnis.Append("Debitor " + az.Gegenkonto + " " + az.Verwendungszweck);
+ }
+ }
+
+ return ergebnis.ToString();
+ }
+
+ private bool ImportAbschlagszahlung(Abschlagszahlung az, HilfeplanInfo hp, StringBuilder log)
+ {
+ if (az.Buchungstag >= hp.Start && az.Buchungstag <= hp.Ende)
+ {
+ if (!String.IsNullOrEmpty(az.Gegenkonto) && !String.IsNullOrEmpty(hp.CustomerDebitorNummer))
+ {
+ var azDebitor = az.Gegenkonto.ToLower().Trim();
+ var debitor = hp.CustomerDebitorNummer.ToLower().Trim();
+
+ if (azDebitor == debitor)
+ {
+ if (!CheckAbschlagszahlung(az, hp))
+ {
+ CreateAbschlagszahlung(az, hp);
+ importiertCount++;
+ }
+ else
+ {
+ bereitsVorhandenCount++;
+ }
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private void CreateAbschlagszahlung(Abschlagszahlung az, HilfeplanInfo hp)
+ {
+ var newAz = new AccountingTransaction();
+
+ newAz.CostBearer2SupportConcept = hp.CostBearer2SupportConcept;
+ newAz.Amount = az.Betrag;
+ newAz.BookingDate = az.Buchungstag;
+ newAz.ImportNotice = az.Verwendungszweck;
+ if (az.Valutadatum.HasValue)
+ {
+ newAz.ValidityDate = az.Valutadatum;
+ }
+ else
+ {
+ newAz.ValidityDate = az.Buchungstag;
+ }
+
+ newAz.Notice = "Automatischer Import " + az.Verwendungszweck;
+ DAOFactory.GenericDAO.Insert(newAz);
+ }
+
+ private bool CheckAbschlagszahlung(Abschlagszahlung az, HilfeplanInfo hp)
+ {
+ var azAltList = DAOFactory.SearchDAO.FindAccountingTransactionsWithImportNotice(az.Verwendungszweck);
+ return azAltList != null && azAltList.Any();
+ }
+
+ private List CreateAbschlagszahlungen(String importfile)
+ {
+ List liste = new List();
+ String[] lines = importfile.Split('\n');
+ DateTime month = DateTime.Now;
+ int jahr = 0;
+ int monat = 0;
+
+ for (int i = 0; i < lines.Count(); i++)
+ {
+ string line = lines[i];
+ var fields = line.Split(';');
+
+ if (i == 0)
+ {
+ int.TryParse(fields[15].Substring(0, 4), out jahr);
+ int.TryParse(fields[15].Substring(4, 2), out monat);
+ if (jahr != 0 && monat != 0)
+ {
+ month = new DateTime(jahr, monat, 01);
+ }
+ }
+
+ if (i > 1)
+ {
+ if (fields.Length >= 9)
+ {
+ int tag;
+ if (int.TryParse(fields[9].Substring(0, fields[9].Length - 2), out tag) && !String.IsNullOrEmpty(fields[23]))
+ {
+ try
+ {
+ DateTime buchungstag = new DateTime(month.Year, month.Month, tag);
+
+ Abschlagszahlung az = new Abschlagszahlung();
+ int abschlagsjahr;
+ int abschlagsmonat;
+ az.Buchungstag = buchungstag;
+ if (fields[10].Length > 6)
+ {
+ int.TryParse(fields[10].Trim().Substring(fields[10].Length - 4, 4), out abschlagsjahr);
+ int.TryParse(fields[10].Trim().Substring(fields[10].Length - 7, 2), out abschlagsmonat);
+ if (abschlagsjahr != 0 && abschlagsmonat != 0)
+ {
+ az.Buchungstag = new DateTime(jahr, monat, 15);
+ }
+ }
+ az.Valutadatum = buchungstag;
+ az.Gegenkonto = fields[7];
+ if (!String.IsNullOrEmpty(fields[13]))
+ {
+ az.Verwendungszweck = fields[13];
+ }
+ else
+ {
+ az.Verwendungszweck = fields[10];
+ }
+
+ decimal betrag = 0;
+ if (Decimal.TryParse(fields[0], out betrag))
+ {
+ az.Betrag = betrag;
+ }
+
+ //ParseVerwendungszweck(az);
+ liste.Add(az);
+ }
+ catch (Exception e)
+ {
+ //ignore
+ }
+ }
+ }
+ }
+ }
+ return liste;
+ }
+
+ private List CreateHilfeplanInfos()
+ {
+ List liste = new List();
+ var scList = DAOFactory.GenericDAO.GetAllActiveAndArchived();
+
+ foreach (var supportConcept in scList)
+ {
+ foreach (var cb2sc in supportConcept.CostBearer2SupportConceptList)
+ {
+ HilfeplanInfo hi = new HilfeplanInfo();
+
+ hi.Start = cb2sc.StartDate;
+ hi.Ende = cb2sc.EndDate;
+
+ hi.CostBearer2SupportConcept = cb2sc;
+ hi.CustomerFirstName = cb2sc.SupportConcept.Customer.Person.FirstName;
+ hi.CustomerLastName = cb2sc.SupportConcept.Customer.Person.LastName;
+ hi.CustomerBirthday = cb2sc.SupportConcept.Customer.Person.DateOfBirth;
+ hi.CustomerDebitorNummer = cb2sc.SupportConcept.Customer.DebitorNumber;
+ hi.Aktenzeichen = cb2sc.CustomerReferenceNumber;
+
+ if (hi.Start.HasValue && hi.Ende.HasValue && !String.IsNullOrEmpty(hi.CustomerDebitorNummer))
+ {
+ liste.Add(hi);
+ }
+ }
+ }
+
+ return liste;
+ }
+ }
+}
diff --git a/ReportImp/BzhEssenGGmbH/Import/HilfeplanInfo.cs b/ReportImp/BzhEssenGGmbH/Import/HilfeplanInfo.cs
new file mode 100644
index 000000000..ad182a843
--- /dev/null
+++ b/ReportImp/BzhEssenGGmbH/Import/HilfeplanInfo.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BeWo.Data.Entities;
+
+namespace BzhEssenGGmbH.Import
+{
+ public class HilfeplanInfo
+ {
+ //Auftragskonto; Buchungstag; Valutadatum; Buchungstext; Verwendungszweck; Glaeubiger ID; Mandatsreferenz; Kundenreferenz(End - to - End); Sammlerreferenz; Lastschrift Ursprungsbetrag; Auslagenersatz Ruecklastschrift;
+ //Beguenstigter / Zahlungspflichtiger; Kontonummer / IBAN; BIC(SWIFT - Code); Betrag; Waehrung; Info
+
+ public String CustomerFirstName { get; set; }
+ public String CustomerLastName { get; set; }
+ public DateTime? CustomerBirthday { get; set; }
+ public String CustomerDebitorNummer { get; set; }
+ public DateTime? Start { get; set; }
+ public DateTime? Ende { get; set; }
+ public DateTime? BescheidVom { get; set; }
+ public String Aktenzeichen { get; set; }
+
+ public CostBearer2SupportConcept CostBearer2SupportConcept { get; set; }
+ }
+}
diff --git a/ReportImp/LebenshilfeBadKreuznach/LebenshilfeBadKreuznach.csproj b/ReportImp/LebenshilfeBadKreuznach/LebenshilfeBadKreuznach.csproj
index 330043339..8f6443462 100644
--- a/ReportImp/LebenshilfeBadKreuznach/LebenshilfeBadKreuznach.csproj
+++ b/ReportImp/LebenshilfeBadKreuznach/LebenshilfeBadKreuznach.csproj
@@ -46,6 +46,7 @@
+
@@ -70,6 +71,10 @@
+
+ {3FEBB560-9275-413A-9767-BB68C44EEBC3}
+ BeWo
+
{B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}
Data
diff --git a/ReportImp/LebenshilfeBadKreuznach/Quittierungsbeleg.cs b/ReportImp/LebenshilfeBadKreuznach/Quittierungsbeleg.cs
index b82b13990..c6cae5bbc 100644
--- a/ReportImp/LebenshilfeBadKreuznach/Quittierungsbeleg.cs
+++ b/ReportImp/LebenshilfeBadKreuznach/Quittierungsbeleg.cs
@@ -4,12 +4,16 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using System.Windows.Threading;
+using BeWo.Core.Service;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
+using BeWo.ServiceProxy;
+using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
@@ -82,13 +86,13 @@ namespace LebenshilfeBadKreuznach
public static void CreateGoalList(ServicesOverviewRO.ServiceDetail sd)
{
var serviceRecord = DAOFactory.GenericDAO.LoadByID(sd.ServiceRecordOid);
-
var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord);
sd.GoalList = String.Empty;
if (srDc.Goals != null && srDc.Goals.Count > 0)
{
Dictionary key2Value = new Dictionary();
+ var masnahmen = srDc.Goals.Where(g => g.Type == BS.Shared.ValueListEntryType.SupportConceptIndividualGoalType || g.Type == BS.Shared.ValueListEntryType.SupportConceptGoalType).OrderBy(g => g.ParentOid).ToList();
srDc.Goals = srDc.Goals.Where(g => g.Type == BS.Shared.ValueListEntryType.SupportConceptIndividualGoalCategoryType || g.Type == BS.Shared.ValueListEntryType.SupportConceptGoalCategoryType).OrderBy(g => g.ParentOid).ToList();
foreach (var goal in srDc.Goals)
{
@@ -112,13 +116,31 @@ namespace LebenshilfeBadKreuznach
key2Value.Add(key, value);
}
}
+ foreach (var m in masnahmen)
+ {
+ if (m.ParentOid.HasValue && !key2Value.ContainsKey(m.ParentOid.Value))
+ {
+ var goalParent = DAOFactory.GenericDAO.LoadByID(m.ParentOid.Value);
+ var parent = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDC(goalParent);
+ string value = null;
+ if (!string.IsNullOrEmpty(parent.TypeDescription))
+ {
+ value = parent.TypeDescription;
+ }
+ else
+ {
+ value = parent.Abbreviation;
+ }
+ key2Value.Add(m.ParentOid.Value, value);
+ }
+ }
+
foreach (var item in key2Value.Keys)
{
if (sd.GoalList.Length > 0)
{
sd.GoalList += ", ";
}
-
sd.GoalList += key2Value[item];
}
}