ChristopherusHaus/Export/SimbaExporter FibuExport

This commit is contained in:
2024-01-03 13:13:55 +01:00
parent 453a8398d3
commit e8587840e8
3 changed files with 150 additions and 1 deletions

View File

@@ -64,6 +64,7 @@
<Compile Include="CHMitarbeiterstundenkontoBerechnungMonate.cs" />
<Compile Include="CHMitarbeiterstundenkontoBerechnung.cs" />
<Compile Include="Export\CustomDataExporter.cs" />
<Compile Include="Export\SimbaExporter.cs" />
<Compile Include="Export\LohnExporter.cs" />
<Compile Include="Mitarbeiterarbeitszeitkonto.cs">
<SubType>Component</SubType>

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Bewo.ChristopherusHaus.Export;
using BeWo.Service.Plugins;
using BS.Shared.Core;
using BS.Shared.DataContracts;
@@ -12,7 +13,27 @@ namespace BeWo.ChristopherusHaus.Export
public override QueryDC CreateQuery(QueryDC query)
{
return LohnExporter.CreateQuery(query);
QueryDC q = null;
if (query.Oid == 100)
{
return LohnExporter.CreateQuery(query);
}
else if (query.Oid == 200)
{
q = FibuExport.CreateQuery(query);
}
CreateBuchungsExportProtokollEintrag(q);
return q;
}
public override string CreateExportString(string pFileID, string[] pHeaderCaption, string[][] pContent)
{
if (pHeaderCaption != null && pHeaderCaption.Length > 0 && pHeaderCaption[0].Contains("Buchhaltungsexport"))
{
return FibuExport.CreateExportString(pHeaderCaption, pContent);
}
return base.CreateExportString(pFileID, pHeaderCaption, pContent);
}
}
}

View File

@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace Bewo.ChristopherusHaus.Export
{
public class FibuExport
{
public static QueryDC CreateQuery(QueryDC query)
{
DateTime dt = DateTime.Now;
DateTime.TryParse(query.Parameter[0].Value.ToString(), out dt);
query.FileName = String.Format("BUCH_BO_{0:yyyyMM}.scs", dt);
query.QueryResult = GetAbrechnungenString(dt);
return query;
}
public static string CreateExportString(string[] pHeaderCaption, string[][] pContent)
{
if (pHeaderCaption != null && pHeaderCaption.Length > 1 && pHeaderCaption[0].Contains("Fibu"))
{
DateTime dt = DateTime.Now;
DateTime.TryParse(pHeaderCaption[1], out dt);
return GetAbrechnungenString(dt);
}
return null;
}
public static String GetAbrechnungenString(DateTime dt)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("\"MND\";500");
sb.AppendLine(String.Format("\"BZR\";{0:yyyyMM}", dt));
var s = GetMonatlicheRechnungenString(dt);
if (!String.IsNullOrWhiteSpace(s))
{
sb.Append(s);
}
return sb.ToString();
}
public static String GetMonatlicheRechnungenString(DateTime date)
{
var dt = ExecuteQuery(GetMonatlicheRechnungenSql(date), date);
/* 'BCH', sip.Claim, '8106' as 'Gegenkonto', ib.invoicenumber, ib.InvoiceDate, org.DebitorNumber, '3170', org.Name, p.FirstName, p.LastName*/
StringBuilder sb = new StringBuilder();
foreach (DataRow row in dt.Rows)
{
if (sb.Length > 0)
{
sb.AppendLine();
}
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]));
sb.Append(";");
sb.Append(String.Format("{0}", row[3]));
sb.Append(";;");
sb.Append(String.Format("{0:ddMMyyyy}", row[4]));
sb.Append(";;");
sb.Append(String.Format("{0}", row[5]));
sb.Append(";");
sb.Append(String.Format("{0}", row[6]));
sb.Append(";;;");
sb.Append(String.Format("\"ISB {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 {0}.pdf\"", row[3]));
}
return sb.ToString();
}
private static String GetMonatlicheRechnungenSql(DateTime date)
{
String sql = @"
select
'BCH',
sip.Claim,
'8106' as 'Gegenkonto',
ib.invoicenumber,
ib.InvoiceDate,
org.DebitorNumber,
'3170',
org.Name,
p.FirstName,
p.LastName
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;
newsql = newsql.Replace(":Abrechnungsmonat", String.Format("{0:dd.MM.yyyy}", dt));
newsql = newsql.Replace(":Belegnr", String.Format("{0:yyMM}", dt));
newsql = newsql.Replace(":Monat_Start", String.Format("{0:yyyy-MM}-01", dt));
dt = dt.AddMonths(1);
newsql = newsql.Replace(":Monat_End", String.Format("{0:yyyy-MM}-01", dt));
return DAOFactory.AdoDAO.ExecuteQuery(newsql).Tables[0];
}
}
}