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

# Conflicts:
#	BeWoAllReports.sln
#	Service/Plugins/PluginLoader.cs
This commit is contained in:
Christian
2025-01-29 01:16:13 +01:00
185 changed files with 25333 additions and 11480 deletions

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using ChristopherusHausFamilienhilfe.Export;
using BeWo.Service.Plugins;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using Utils = BS.Shared.Core.Utils;
namespace ChristopherusHausMID.Export
{
public class CustomDataExporter : DataExporter
{
public override QueryDC CreateQuery(QueryDC query)
{
QueryDC q = FibuExport.CreateQuery(query);
CreateBuchungsExportProtokollEintrag(q);
return q;
}
}
}

View File

@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
using BS.Shared.DataContracts;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
namespace ChristopherusHausMID.Export
{
public class FibuExport
{
List<FileAttachmentDC> liste = new List<FileAttachmentDC>();
public static QueryDC CreateQuery(QueryDC query)
{
DateTime dt = DateTime.Now;
DateTime.TryParse(query.Parameter[0].Value.ToString(), out 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);
return query;
}
public static String GetAbrechnungenString(DateTime dt, DataTable table)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("\"MND\";500");
sb.AppendLine(String.Format("\"BZR\";{0:MMyyyy}", dt));
var s = GetMonatlicheRechnungenString(dt, table);
if (!String.IsNullOrWhiteSpace(s))
{
sb.Append(s);
}
return sb.ToString();
}
public static String GetMonatlicheRechnungenString(DateTime date, DataTable dt)
{
/* '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();
}
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]));
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(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 ISB{0}.pdf\"", row[3]));
}
return sb.ToString();
}
private static List<FileAttachmentDC> CreateInvoiceFiles(DataTable dt)
{
// Rückfrage steht noch aus, ob die Sammelrechnung an jede Einzelbuchung gehangen wird oder nicht
// dementsprechend hier noch splitten
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,
'8106' as 'Gegenkonto',
ib.invoicenumber,
ib.InvoiceDate,
org.DebitorNumber,
'3170',
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
UNION SELECT
'BCH',
sip.Claim,
'8106' as 'Gegenkonto',
ib.invoicenumber,
ib.InvoiceDate,
org.DebitorNumber,
'3170',
org.Name,
p.FirstName,
p.LastName,
ib.Oid
FROM
invoicebase ib
JOIN serviceinvoice si ON si.invoicebaseoid = ib.oid
JOIN serviceinvoiceperiod sip ON sip.serviceinvoiceoid = si.oid
JOIN invoiceitem ii ON ii.serviceinvoiceperiodoid = sip.oid
inner join costbearer cb on ib.recipientcostbeareroid = cb.oid
inner join organisation org on org.costbeareroid = cb.oid
inner join customer c on sip.customeroid = c.oid
inner join person p on c.PersonOid = p.oid
WHERE ib.`AccountingPeriodEnd` >= ':Monat_Start' AND ib.`AccountingPeriodEnd` < ':Monat_End' and ib.IsActive = 1
";
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];
}
}
}