ChristopherusHaus/Export/SimbaExporter.cs - Neu

This commit is contained in:
2024-09-17 16:32:26 +02:00
parent 8cb58849fb
commit 55573c3898
6 changed files with 723 additions and 7971 deletions

View File

@@ -94,6 +94,12 @@
<DependentUpon>MitarbeiterstundenkontoJahr.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServiceInvoiceReport.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ServiceInvoiceReport.Designer.cs">
<DependentUpon>ServiceInvoiceReport.cs</DependentUpon>
</Compile>
<Compile Include="ServicesOverviewReport.cs">
<SubType>Component</SubType>
</Compile>
@@ -137,6 +143,10 @@
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\licenses.licx" />
<EmbeddedResource Include="ServiceInvoiceReport.resx">
<DependentUpon>ServiceInvoiceReport.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ServicesOverviewReport.resx">
<DependentUpon>ServicesOverviewReport.cs</DependentUpon>
<SubType>Designer</SubType>

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Bewo.ChristopherusHaus.Export;
using BeWo.Service.Plugins;
using BS.Shared.Core;
using BS.Shared.DataContracts;
@@ -31,7 +30,7 @@ namespace BeWo.ChristopherusHaus.Export
{
if (pHeaderCaption != null && pHeaderCaption.Length > 0 && pHeaderCaption[0].Contains("Buchhaltungsexport"))
{
return FibuExport.CreateExportString(pHeaderCaption, pContent);
//return FibuExport.CreateExportString(pHeaderCaption, pContent);
}
return base.CreateExportString(pFileID, pHeaderCaption, pContent);
}

View File

@@ -8,10 +8,11 @@ using BeWo.Data.Entities;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
using BS.Shared.DataContracts;
using ChristopherusHaus;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
namespace ChristopherusHausFamilienhilfe.Export
namespace BeWo.ChristopherusHaus.Export
{
public class FibuExport
{
@@ -21,11 +22,11 @@ namespace ChristopherusHausFamilienhilfe.Export
DateTime dt = DateTime.Now;
DateTime.TryParse(query.Parameter[0].Value.ToString(), out dt);
var table = ExecuteQuery(GetMonatlicheBetraegeLvrLwlSql(dt), dt);
var table = ExecuteQuery(GetMonatlicheRechnungenSql(dt), dt);
query.FileName = String.Format("BUCH_BO_{0:yyyyMM}.scs", dt);
query.QueryResult = GetAbrechnungenString(dt, table);
//query.Attachments = CreateInvoiceFiles(table);
query.Attachments = CreateInvoiceFiles(table);
return query;
}
@@ -34,11 +35,20 @@ namespace ChristopherusHausFamilienhilfe.Export
StringBuilder sb = new StringBuilder();
sb.AppendLine("\"MND\";500");
sb.AppendLine(String.Format("\"BZR\";{0:MMyyyy}", dt));
var s = GetMonatlicheBetraegeString(dt, table);
var tableLL = ExecuteQuery(GetMonatlicheBetraegeLvrLwlSql(dt), dt);
var s = GetMonatlicheBetraegeString(dt, tableLL);
if (!String.IsNullOrWhiteSpace(s))
{
sb.Append(s);
}
s = GetMonatlicheRechnungenString(dt, table);
if (!String.IsNullOrWhiteSpace(s))
{
if (sb.Length > 0)
sb.AppendLine();
sb.Append(s);
}
return sb.ToString();
}
@@ -46,8 +56,7 @@ namespace ChristopherusHausFamilienhilfe.Export
public static String GetMonatlicheBetraegeString(DateTime date, DataTable dt)
{
/* 'BCH', sip.Claim, '8106' as 'Gegenkonto', ib.invoicenumber, ib.InvoiceDate, org.DebitorNumber, '3170', org.Name, p.FirstName, p.LastName*/
/*'BCH', sum(qry.Betrag) AS Betrag, '8017' as 'Gegenkonto', qry.DebitorNumber, qry.CostCenter, org.Name, qry.Verwendung, qry.Oid*/
/*'BCH', sum(qry.Betrag) AS Betrag, '8017' as 'Gegenkonto', qry.DebitorNumber, qry.CostCenter, org.Name, qry.Verwendung, qry.Oid*/
StringBuilder sb = new StringBuilder();
foreach (DataRow row in dt.Rows)
{
@@ -69,15 +78,15 @@ namespace ChristopherusHausFamilienhilfe.Export
string gKonto = GetErlöskonto(orgaName);
sb.Append(String.Format("{0}", gKonto)); //Gegenkonto
sb.Append(";");
sb.Append(String.Format("{0:ddMMyyyy}", lastDate)); // Belegnummer???
sb.Append(String.Format("{0:yyyyMM}", lastDate)); // Belegnummer JJJJMM
sb.Append(";;");
sb.Append(String.Format("{0:ddMMyyyy}", lastDate)); //Simba nimmt nur Buchungen an, ReDatum = Abrechnungszeitraum
sb.Append(";;");
sb.Append(String.Format("{0}", row[3])); // Debitornummer Kostenträger
sb.Append(String.Format("{0}", row[3])); // Debitornummer Klient
sb.Append(";");
sb.Append(String.Format("{0}", row[4])); // Kostenstelle Klient (TEAM)
sb.Append(";;;");
sb.Append(String.Format("\"ABW {0}, {1} {2}\"", row[7], row[8], row[9]));
sb.Append(String.Format("\"ABW {0}\"", row[6]));
sb.Append(";\"EUR\";;;;;;;;;;");
sb.Append(String.Format("{0}", row[3]));
sb.Append(";;;;;"); // bei SPFH kommt hier noch der Beleg als PDF
@@ -110,7 +119,7 @@ namespace ChristopherusHausFamilienhilfe.Export
'8017' as 'Gegenkonto',
qry.DebitorNumber,
qry.CostCenter,
org.Name,
qry.Name,
qry.Verwendung,
qry.Oid
FROM
@@ -118,8 +127,9 @@ namespace ChristopherusHausFamilienhilfe.Export
(SELECT
IF(crpRateFactor.`CostRateValue` is null, ROUND((sr.`GeleisteteFLM` / 60) * (SELECT crp.`CostRateValue` FROM `costrateperiod` crp WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 0 AND crp.`ObjectOid` = cb2sc.`CostBearerOid` AND (crp.`EndDate` is null or crp.`EndDate` > ':Monat_Start') order by IF(crp.`EndDate` is null, MAKEDATE(9999,365),crp.`EndDate`) LIMIT 1 )),
ROUND(ROUND((sr.`GeleisteteFLM` / 60), 2) * (SELECT crp.`CostRateValue` FROM `costrateperiod` crp WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 0 AND crp.`ObjectOid` = cb2sc.`CostBearerOid` AND (crp.`EndDate` is null or crp.`EndDate` > ':Monat_Start') order by IF(crp.`EndDate` is null, MAKEDATE(9999,365),crp.`EndDate`) LIMIT 1 ) * ((100 + crpRateFactor.`CostRateValue`)/100), 2)) AS 'Betrag',
org.DebitorNumber,
c.DebitorNumber,
c.CostCenter,
org.Name,
CONCAT(org.Name,', ', p.`LastName`, ', ', p.`FirstName`) as 'Verwendung',
cb2sc.Oid
FROM `supportconcept` sc
@@ -138,13 +148,13 @@ namespace ChristopherusHausFamilienhilfe.Export
INNER JOIN `servicecategory` sc ON sd.`ServiceCategoryOid` = sc.`Oid`
WHERE sr2.`StartDate` >= ':Monat_Start' AND sr2.`StartDate` < ':Monat_End' AND sc.`Billable` = 1 and sd.Name <> 'Fehlkontakt' GROUP BY sr2.`CostBearer2SupportConceptOid`)
AS sr ON sr.`CostBearer2SupportConceptOid` = cb2sc.`Oid`
WHERE c.`IsActive` = 1 AND sc.`IsActive` = 1
and (sr.`GeleisteteFLM` is not null))
WHERE c.`IsActive` = 1 AND sc.`IsActive` = 1 and (sr.`GeleisteteFLM` is not null) and (org.Name = 'LVR' OR org.Name = 'LWL'))
UNION
(SELECT
ROUND(0.8 * (sr.`GeleisteteFLM` / 60) * (SELECT crp.`CostRateValue` FROM `costrateperiod` crp WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 0 AND crp.`ObjectOid` = cb2sc.`CostBearerOid` AND (crp.`EndDate` is null or crp.`EndDate` > ':Monat_Start') order by IF(crp.`EndDate` is null, MAKEDATE(9999,365),crp.`EndDate`) LIMIT 1 )) AS 'Betrag',
org.DebitorNumber,
c.DebitorNumber,
c.CostCenter,
org.Name,
CONCAT(org.Name,', ', p.`LastName`, ', ', p.`FirstName`) as 'Verwendung',
cb2sc.Oid
FROM `supportconcept` sc
@@ -159,8 +169,7 @@ namespace ChristopherusHausFamilienhilfe.Export
INNER JOIN `servicecategory` sc ON sd.`ServiceCategoryOid` = sc.`Oid`
WHERE sr2.`StartDate` >= ':Monat_Start' AND sr2.`StartDate` < ':Monat_End' AND sc.`Billable` = 1 and sd.Name = 'Fehlkontakt' GROUP BY sr2.`CostBearer2SupportConceptOid`)
AS sr ON sr.`CostBearer2SupportConceptOid` = cb2sc.`Oid`
WHERE c.`IsActive` = 1 AND sc.`IsActive` = 1
and (sr.`GeleisteteFLM` is not null))
WHERE c.`IsActive` = 1 AND sc.`IsActive` = 1 and (sr.`GeleisteteFLM` is not null) and (org.Name = 'LVR' OR org.Name = 'LWL'))
)qry
GROUP BY qry.OID
ORDER BY qry.Verwendung
@@ -169,6 +178,117 @@ namespace ChristopherusHausFamilienhilfe.Export
return sql;
}
public static String GetMonatlicheRechnungenString(DateTime date, DataTable dt)
{
/* 'BCH', sip.Claim, '8106' as 'Gegenkonto', ib.invoicenumber, ib.InvoiceDate, c.DebitorNumber, c.CostCenter, org.Name, p.FirstName, p.LastName*/
StringBuilder sb = new StringBuilder();
foreach (DataRow row in dt.Rows)
{
if (sb.Length > 0)
{
sb.AppendLine();
}
DateTime lastDate = new DateTime(date.Year, date.Month, 1);
lastDate = lastDate.AddMonths(1).AddDays(-1);
sb.Append(String.Format("\"{0}\"", row[0]));
sb.Append(";");
sb.Append(String.Format("{0:0.00}", row[1]));
sb.Append(";;;");
sb.Append(String.Format("{0}", row[2])); // derzeit ist das Erlöskonto fix, weil alle außer LWL/LVR auf 8017 kommunale Erlöse gehen
sb.Append(";");
sb.Append(String.Format("{0}", row[3]));
sb.Append(";;");
sb.Append(String.Format("{0:ddMMyyyy}", lastDate)); //Simba nimmt nur Buchungen an, ReDatum = Abrechnungszeitraum
sb.Append(";;");
sb.Append(String.Format("{0}", row[5])); //Debitor
sb.Append(";");
sb.Append(String.Format("{0}", row[6])); // Kostenstelle Klient (TEAM)
sb.Append(";;;");
sb.Append(String.Format("\"ABW {0}, {1} {2}\"", row[7], row[8], row[9]));
sb.Append(";\"EUR\";;;;;;;;;;");
sb.Append(String.Format("{0}", row[3]));
sb.Append(";;;;");
sb.Append(String.Format("\"Rechnung ABW{0}.pdf\"", row[3]));
}
return sb.ToString();
}
private static List<FileAttachmentDC> CreateInvoiceFiles(DataTable dt)
{
try
{
List<FileAttachmentDC> liste = new List<FileAttachmentDC>();
foreach (DataRow row in dt.Rows)
{
var pdf = new FileAttachmentDC();
var invoiceOid = row[10].ToString();
if (!String.IsNullOrEmpty(invoiceOid))
{
var oid = long.Parse(invoiceOid);
var invoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(oid);
//var invoice = DAOFactory.GenericDAO.LoadByID<ServiceInvoice>(oid);
var idc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(invoice);
var anhang = new ServiceInvoiceReport();
var ro = ServiceInvoiceRO.Create(idc);
anhang.SetReportDataSource(ro);
anhang.CreateDocument();
pdf.FileName = anhang.PrintingSystem.Document.Name + ".pdf";
using (var ms = new MemoryStream())
{
anhang.ExportToPdf(ms);
pdf.BinaryData = ms.ToArray();
}
liste.Add(pdf);
//string name = anhang.PrintingSystem.Document.Name;
//string path = @"C:\Temp\FiBuExport\";
//anhang.ExportToPdf(path + name + ".pdf");
}
}
return liste;
}
catch (Exception)
{
// continue - auch wenn gar nichts stimmt
}
return null;
}
private static String GetMonatlicheRechnungenSql(DateTime date)
{
String sql = @"
select
'BCH',
sip.Claim,
'8017' as 'Gegenkonto',
ib.invoicenumber,
ib.InvoiceDate,
c.DebitorNumber,
c.CostCenter,
org.Name,
p.FirstName,
p.LastName,
ib.Oid
from
person p
inner join customer c on c.personoid = p.oid
inner join supportconcept sc on sc.customeroid = c.oid
inner join costbearer2supportconcept c2s on c2s.supportconceptoid = sc.oid
inner join costbearer cb on c2s.costbeareroid = cb.oid
inner join organisation org on org.costbeareroid = cb.oid
inner join invoicebase ib on ib.costbearer2supportconceptoid = c2s.oid
inner join serviceinvoice si on si.invoicebaseoid = ib.oid
inner join serviceinvoiceperiod sip on sip.serviceinvoiceoid = si.oid
WHERE ib.`AccountingPeriodEnd` >= ':Monat_Start' AND ib.`AccountingPeriodEnd` < ':Monat_End' and ib.IsActive = 1
order by ib.invoicenumber
";
return sql;
}
public static DataTable ExecuteQuery(String sql, DateTime dt)
{
var newsql = sql;

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,11 @@
using System;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using System.Text;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
namespace ChristopherusHausFamilienhilfe
namespace ChristopherusHaus
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
@@ -19,68 +18,59 @@ namespace ChristopherusHausFamilienhilfe
{
DateTime start = pRO.AccountingPeriodStart;
DateTime end = pRO.AccountingPeriodEnd;
lblRechnungsnummer.Text = pRO.InvoiceNumber;
lblRechnungsnummer.Text = "Rechnung " + pRO.InvoiceNumber;
if (start.Month == end.Month && start.Year == end.Year)
{
lblAbrechnungszeitraum.Text = String.Format("hiermit berechnen wir für den Monat {0:MMMM yyyy} folgende erbrachte Tätigkeiten:", start);
}
else
{
lblAbrechnungszeitraum.Text = String.Format("hiermit berechnen wir für den Zeitraum {0:MMMM yyyy} - {1:MMMM yyyy} folgende erbrachte Tätigkeiten:", start, end);
}
// Klientin Maren Völpert wird noch bis Juli 23 betreut und bekommt unabhängig vom KT einen anderen Paragrafen. Daher frage ich jetzt speziell nach ihrem Namen ab und setze dafür dann den Paragrafen
SetzeAdresse(pRO);
if (pRO.CustomerLastName.ToLower() == "völpert" && pRO.CustomerFirstName.ToLower() == "maren")
{
lblLeistung.Text = "Nach § 41 i.V.m. § 35 SGB VIII";
}
else if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
if (pRO.RecipientOrganisation == "Stadt Herne")
lblLeistung.Text = "Nach § 113 SGB IX in Verbindung mit § 78 SGB IX";
else if (pRO.RecipientOrganisation.Contains("FUD"))
{
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace("(FUD)", "");
lblLeistung.Text = "Nach § 27 SGB VIII Familienunterstützender Dienst";
}
else
{
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace("(SPFH)", "");
lblLeistung.Text = "Nach § 31 SGB VIII Sozialpädagogische Familienhilfe";
}
}
if (pRO.ServiceInvoicePeriods != null)
{
var sip = pRO.ServiceInvoicePeriods[0];
String alleSorgeDingens = "";
var customer = DAOFactory.GenericDAO.LoadByID<Customer>(sip.Customer.CustomerOid);
foreach (var c2p in customer.Customer2PersonList)
{
foreach (var v2o in c2p.ValueList)
{
if (v2o.Entry.Type == BS.Shared.ValueListEntryType.RoleInFamily || v2o.Entry.Type == BS.Shared.ValueListEntryType.EnvironmentPersonType)
{
if (v2o.Entry.Value.Contains("Sorgeberechtigt") || v2o.Entry.Value.Contains("Vormund") || v2o.Entry.Value.Contains("Gesetzlicher Vertreter"))
{
if (alleSorgeDingens != "")
alleSorgeDingens += ", " + c2p.Person.FirstNameLastName;
else
alleSorgeDingens += c2p.Person.FirstNameLastName;
}
}
}
}
lblSorgeBerechtigter.Text = alleSorgeDingens;
lblGebDatum.Text = String.Format("{0:dd/MM/yyyy}", sip.Customer.DateOfBirth);
lblHilfeBeginn.Text = String.Format("{0:dd/MM/yyyy}", sip.Customer.AssistanceBegin);
lblHPG.Text = String.Format("{0:dd/MM/yyyy}", sip.CostBearer2SupportConcept.SupportConcept.ConferenceDate);
lblBewZeitraum.Text = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", pRO.InvoiceBase.SupportConceptCostBearerRelDc.StartDate, pRO.InvoiceBase.SupportConceptCostBearerRelDc.EndDate);
}
this.bindingSource1.DataSource = pRO;
}
// Die Rechnungsnummer muss für den FiBu-Export gleich dem PDF-Namen sein!
private void ChangeName(object sender, EventArgs e)
private void SetzeAdresse(ServiceInvoiceRO pRO)
{
PrintingSystem.Document.Name = lblRechnungsnummer.Text;
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler")
{
sb.AppendLine(pRO.RecipientOrganisation);
}
//if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1))
//{
// sb.AppendLine(pRO.RecipientAddressLine1);
//}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler")
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientPoBox))
{
sb.AppendLine(pRO.RecipientPoBox);
}
else if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
}
private void ChangeName(object sender, System.ComponentModel.CancelEventArgs e)
{
PrintingSystem.Document.Name = String.Format("Rechnung ABW{0}", lblRechnungsnummer.Text);
}
}
}

File diff suppressed because it is too large Load Diff