ChristopherusHausFamilienhilfe/Export/SimbaExporter.cs
This commit is contained in:
@@ -67,6 +67,8 @@
|
||||
<Compile Include="Einsatzzeiten.Designer.cs">
|
||||
<DependentUpon>Einsatzzeiten.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Export\CustomDataExporter.cs" />
|
||||
<Compile Include="Export\SimbaExporter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServiceInvoiceReport.cs">
|
||||
<SubType>Component</SubType>
|
||||
|
||||
@@ -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 ChristopherusHausFamilienhilfe.Export
|
||||
{
|
||||
public class CustomDataExporter : DataExporter
|
||||
{
|
||||
|
||||
public override QueryDC CreateQuery(QueryDC query)
|
||||
{
|
||||
QueryDC q = FibuExport.CreateQuery(query);
|
||||
CreateBuchungsExportProtokollEintrag(q);
|
||||
return q;
|
||||
}
|
||||
}
|
||||
}
|
||||
162
ReportImp/ChristopherusHausFamilienhilfe/Export/SimbaExporter.cs
Normal file
162
ReportImp/ChristopherusHausFamilienhilfe/Export/SimbaExporter.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
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;
|
||||
|
||||
namespace ChristopherusHausFamilienhilfe.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);
|
||||
string folder = String.Format("BUCH_BO_{0:yyyyMM}", dt);
|
||||
query.QueryResult = GetAbrechnungenString(dt, folder);
|
||||
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, String folder)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("\"MND\";500");
|
||||
sb.AppendLine(String.Format("\"BZR\";{0:MMyyyy}", dt));
|
||||
|
||||
var s = GetMonatlicheRechnungenString(dt, folder);
|
||||
if (!String.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
sb.Append(s);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static String GetMonatlicheRechnungenString(DateTime date, String folder)
|
||||
{
|
||||
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("ISB{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("ISB{0}", row[3]));
|
||||
sb.Append(";;;;");
|
||||
sb.Append(String.Format("\"Rechnung ISB{0}.pdf\"", row[3]));
|
||||
}
|
||||
SaveInvoicesToFolder(dt, folder);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static void SaveInvoicesToFolder(DataTable dt, String folder)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
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();
|
||||
string name = anhang.PrintingSystem.Document.Name;
|
||||
string path = @"C:\Temp\FiBuExport\";
|
||||
anhang.ExportToPdf(path + name + ".pdf");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// continue - auch wenn gar nichts stimmt
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ namespace ChristopherusHausFamilienhilfe
|
||||
{
|
||||
DateTime start = pRO.AccountingPeriodStart;
|
||||
DateTime end = pRO.AccountingPeriodEnd;
|
||||
lblRechnungsnummer.Text = pRO.InvoiceNumber;
|
||||
|
||||
// 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
|
||||
|
||||
@@ -78,7 +79,7 @@ namespace ChristopherusHausFamilienhilfe
|
||||
// Die Rechnungsnummer muss für den FiBu-Export gleich dem PDF-Namen sein!
|
||||
private void ChangeName(object sender, EventArgs e)
|
||||
{
|
||||
PrintingSystem.Document.Name = lblRechnungsnummer.Text;
|
||||
PrintingSystem.Document.Name = String.Format("Rechnung ISB{0}", lblRechnungsnummer.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user