Merge branch 'master' of ssh://float.ownsoft.de/git/beyondSoft/BeWo into master

This commit is contained in:
2023-08-31 15:29:29 +02:00
6 changed files with 364 additions and 2 deletions

View File

@@ -53,6 +53,9 @@
<ItemGroup>
<Compile Include="Export\CustomDataExporter.cs" />
<Compile Include="Export\DatevExporter.cs" />
<Compile Include="Import\Abschlagszahlung.cs" />
<Compile Include="Import\AbschlagszahlungImport.cs" />
<Compile Include="Import\HilfeplanInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Quittierungsbeleg.cs">
<SubType>Component</SubType>

View File

@@ -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; }
}
}

View File

@@ -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<Abschlagszahlung> abschlagszahlungen, List<HilfeplanInfo> 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<Abschlagszahlung> CreateAbschlagszahlungen(String importfile)
{
List<Abschlagszahlung> liste = new List<Abschlagszahlung>();
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<HilfeplanInfo> CreateHilfeplanInfos()
{
List<HilfeplanInfo> liste = new List<HilfeplanInfo>();
var scList = DAOFactory.GenericDAO.GetAllActiveAndArchived<SupportConcept>();
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;
}
}
}

View File

@@ -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; }
}
}

View File

@@ -46,6 +46,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Export\CustomDataExporter.cs" />
@@ -70,6 +71,10 @@
<Compile Include="Validation\ServiceRecordValidator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BeWo\BeWo.csproj">
<Project>{3FEBB560-9275-413A-9767-BB68C44EEBC3}</Project>
<Name>BeWo</Name>
</ProjectReference>
<ProjectReference Include="..\..\Data\Data.csproj">
<Project>{B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE}</Project>
<Name>Data</Name>

View File

@@ -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<ServiceRecord>(sd.ServiceRecordOid);
var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord);
sd.GoalList = String.Empty;
if (srDc.Goals != null && srDc.Goals.Count > 0)
{
Dictionary<long, string> key2Value = new Dictionary<long, string>();
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<ValueListEntry>(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];
}
}