Merge branch 'master' of ssh://float.ownsoft.de/git/beyondSoft/BeWo into master
This commit is contained in:
@@ -31,8 +31,6 @@ namespace CaritasGuenzburgNeuUlm
|
||||
dd.BreakMinutes = 30;
|
||||
dd.MaxHoursUntilBreak = 6;
|
||||
}
|
||||
|
||||
|
||||
return dd;
|
||||
}
|
||||
|
||||
@@ -49,7 +47,7 @@ namespace CaritasGuenzburgNeuUlm
|
||||
}
|
||||
|
||||
protected override ServiceRecordSummary BerechneStunden(MitarbeiterstundenkontoRO.EmployeeDetail empDetail, IList<ServiceRecord> groupFilteredRecords, DateTime berichtsAnfang,
|
||||
DateTime berichtsEnde)
|
||||
DateTime berichtsEnde)
|
||||
{
|
||||
decimal flsGesamt = 0;
|
||||
decimal arbeitszeit = 0;
|
||||
@@ -64,10 +62,7 @@ namespace CaritasGuenzburgNeuUlm
|
||||
{
|
||||
if (item.Start.Value >= berichtsAnfang && item.Start.Value < berichtsEnde)
|
||||
{
|
||||
//if (AddServiceRecordToDuration(item))
|
||||
//{
|
||||
decimal duration = 0;
|
||||
|
||||
if (item.GroupRoundedDuration.HasValue)
|
||||
{
|
||||
duration = item.GroupRoundedDuration.Value;
|
||||
@@ -88,7 +83,6 @@ namespace CaritasGuenzburgNeuUlm
|
||||
{
|
||||
flsGesamt += duration;
|
||||
}
|
||||
|
||||
}
|
||||
sum.RecordsImBerichtszeitraum.Add(item);
|
||||
}
|
||||
@@ -134,7 +128,26 @@ namespace CaritasGuenzburgNeuUlm
|
||||
|
||||
if (fak == 0.5m) // die haben eine ganz komische Regel, am Faschingsdienst muss jeder 4 Stunden arbeiten!!!
|
||||
{
|
||||
soll += 4;
|
||||
|
||||
if (emp.Arbeitszeiten != null)
|
||||
{
|
||||
foreach (var az in emp.Arbeitszeiten)
|
||||
{
|
||||
if ((!az.GueltigVon.HasValue || az.GueltigVon.Value <= tag) &&
|
||||
(!az.GueltigBis.HasValue || az.GueltigBis.Value >= tag))
|
||||
{
|
||||
var std = GetArbeitszeitStundenFuerTag(az, tag);
|
||||
if (std > 4)
|
||||
{
|
||||
soll += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
soll += std;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (fak < 1)
|
||||
|
||||
@@ -70,6 +70,8 @@
|
||||
<Reference Include="WindowsFormsIntegration" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Export\CustomDataExporter.cs" />
|
||||
<Compile Include="Export\WilkenExporter.cs" />
|
||||
<Compile Include="Forderungen.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
||||
18
ReportImp/DiakonieLennepReports/Export/CustomDataExporter.cs
Normal file
18
ReportImp/DiakonieLennepReports/Export/CustomDataExporter.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BeWo.Service.Core;
|
||||
using BeWo.Service.Plugins;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using Utils = BS.Shared.Core.Utils;
|
||||
|
||||
namespace DiakonieLennepReports.Export
|
||||
{
|
||||
public class CustomDataExporter : DataExporter
|
||||
{
|
||||
public override QueryDC CreateQuery(QueryDC query)
|
||||
{
|
||||
return WilkenExporter.CreateQuery(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
230
ReportImp/DiakonieLennepReports/Export/WilkenExporter.cs
Normal file
230
ReportImp/DiakonieLennepReports/Export/WilkenExporter.cs
Normal file
@@ -0,0 +1,230 @@
|
||||
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.Service.DCEntityMapper;
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
namespace DiakonieLennepReports.Export
|
||||
{
|
||||
public class WilkenExporter
|
||||
{
|
||||
public static QueryDC CreateQuery(QueryDC query)
|
||||
{
|
||||
DateTime dt = DateTime.Now;
|
||||
DateTime.TryParse(query.Parameter[0].Value.ToString(), out dt);
|
||||
|
||||
query.FileName = String.Format("Wilken Export {0:yyyyMM}.csv", dt);
|
||||
query.QueryResult = GetAbrechnungenString(dt);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public static String GetAbrechnungenString(DateTime date)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
//SCHLUESSEL;OBJEKTTYP;SATZKENNUNG;DATENHERKUNFT;KONZERN;MANDANT;WERK;BELEGNUMMER;BELEGDATUM;BUCHUNGSDATUM;GRUPPE;HAUPTKONTO;UNTERKONTO;BUCHUNGSSCHLUESSEL;SOLLHABEN;BETRAG;STEUERSCHLUESSEL;STEUERLAND;STEUERFUNKTION;BELEGTEXT;MITAUTOMATISCHERGEGENBUCHUNG
|
||||
//BeWoPlaner240403121530; BGR; STD; BeWoPlaner; E; 290; 0; ; ; ; BuchungsdatumBelegnummer; D; 000; BeW; S; 99,00; 000; DE; 0; ; 0
|
||||
|
||||
sb.Append("SCHLUESSEL;OBJEKTTYP;SATZKENNUNG;DATENHERKUNFT;KONZERN;MANDANT;WERK;BELEGNUMMER;BELEGDATUM;BUCHUNGSDATUM;GRUPPE;HAUPTKONTO;UNTERKONTO;BUCHUNGSSCHLUESSEL;SOLLHABEN;BETRAG;STEUERSCHLUESSEL;STEUERLAND;STEUERFUNKTION;BELEGTEXT;MITAUTOMATISCHERGEGENBUCHUNG");
|
||||
var s = GetMonatlicheBetraegeString(date);
|
||||
if (!String.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
//if (sb.Length > 0)
|
||||
// sb.AppendLine();
|
||||
|
||||
sb.Append(s);
|
||||
}
|
||||
|
||||
//s = GetMonatlicheRechnungenString(date);
|
||||
//if (!String.IsNullOrWhiteSpace(s))
|
||||
//{
|
||||
// sb.Append(s);
|
||||
//}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static String GetMonatlicheBetraegeString(DateTime date)
|
||||
{
|
||||
//SCHLUESSEL;OBJEKTTYP;SATZKENNUNG;DATENHERKUNFT;KONZERN;MANDANT;WERK;BELEGNUMMER;BELEGDATUM;BUCHUNGSDATUM;GRUPPE;HAUPTKONTO;UNTERKONTO;BUCHUNGSSCHLUESSEL;SOLLHABEN;BETRAG;STEUERSCHLUESSEL;STEUERLAND;STEUERFUNKTION;BELEGTEXT;MITAUTOMATISCHERGEGENBUCHUNG
|
||||
//BeWoPlaner240403121530; BGR; STD; BeWoPlaner; E; 290; 0; ; ; ; BuchungsdatumBelegnummer; D; 000; BeW; S; 99,00; 000; DE; 0; ; 0
|
||||
|
||||
var sql = GetMonatlicheBetraegeSql(date);
|
||||
var dt = ExecuteQuery(sql, date);
|
||||
DateTime creationDate = DateTime.Now;
|
||||
DateTime lastDate = new DateTime(date.Year, date.Month, 1);
|
||||
lastDate = lastDate.AddMonths(1).AddDays(-1);
|
||||
int counter = 10000;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
counter += 1;
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
sb.AppendLine();
|
||||
}
|
||||
// Schnittstellentyp - Wert aus Feld Datenherkunft, Datum (YYMMDD HHMMSS), Mandant, Laufende Nummer Übergabesatz (5 Stellig)
|
||||
sb.Append(String.Format("BeWoPlaner{0:yyMMddhhmmss}290{1};", creationDate, counter));
|
||||
sb.Append("BGR;STD;BeWoPlaner;E;290;0;");
|
||||
sb.Append(String.Format("B0{0:MM}{1};",lastDate, counter)); //Belegnummer
|
||||
sb.Append(String.Format("{0:dd.MM.yyyy};", lastDate)); //Belegdatum
|
||||
sb.Append(String.Format("{0:dd.MM.yyyy};", lastDate)); //Buchungsdatum
|
||||
sb.Append(String.Format("{0:dd.MM.yyyy}B0{0:MM}{1};", lastDate, counter)); // Gruppe = BuchungsdatumBelegnummer
|
||||
sb.Append(String.Format("{0};", row[1])); //DebitorNumber - Hauptkonto
|
||||
sb.Append("000;"); // Unterkonto
|
||||
sb.Append("BeW;"); // Buchungsschlüssel - erste 3 Buchstaben Datenherkunft
|
||||
sb.Append("S;"); //SollHaben
|
||||
sb.Append(String.Format("{0:0.00};", row[0]));
|
||||
sb.Append("000;"); // Steuerschlüssel
|
||||
sb.Append("DE;");
|
||||
sb.Append("0;");
|
||||
sb.Append(String.Format("FLSTD {0:MM/yyyy} {1};", date, row[3])); //Belegtext
|
||||
sb.Append("0;");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static String GetMonatlicheBetraegeSql(DateTime date)
|
||||
{
|
||||
String sql = @"
|
||||
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',
|
||||
c.DebitorNumber,
|
||||
c.CostCenter,
|
||||
p.`LastName` as 'Klient',
|
||||
cb2sc.Oid
|
||||
FROM `supportconcept` sc
|
||||
INNER JOIN `costbearer2supportconcept` cb2sc ON sc.`Oid` = cb2sc.`SupportConceptOid`
|
||||
INNER JOIN `costbearer` cb ON cb2sc.`CostBearerOid` = cb.`Oid`
|
||||
LEFT JOIN
|
||||
(SELECT crp.`ObjectOid`, crp.`CostRateValue` FROM `costrateperiod` crp
|
||||
WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 2 AND (crp.`EndDate` is null or crp.`EndDate` > NOW()))
|
||||
AS crpRateFactor ON crpRateFactor.`ObjectOid` = cb.`Oid`
|
||||
INNER JOIN `organisation` org ON org.`CostBearerOid` = cb.`Oid`
|
||||
INNER JOIN `customer` c ON sc.`CustomerOid` = c.`Oid`
|
||||
INNER JOIN `person` p on c.`PersonOid` = p.`Oid`
|
||||
LEFT JOIN
|
||||
(SELECT sr2.`CostBearer2SupportConceptOid`, SUM(sr2.`roundedduration` / IF(sr2.`GroupEmployeeCount` is null, 1, sr2.`GroupEmployeeCount`)) AS GeleisteteFLM FROM `servicerecord` sr2
|
||||
INNER JOIN `servicedescription` sd ON sr2.`ServiceDescriptionOid` = sd.`Oid`
|
||||
INNER JOIN `servicecategory` sc ON sd.`ServiceCategoryOid` = sc.`Oid`
|
||||
WHERE sr2.`StartDate` >= ':Monat_Start' AND sr2.`StartDate` < ':Monat_End' AND sc.`Billable` = 1 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)
|
||||
HAVING Betrag > 0
|
||||
ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`
|
||||
";
|
||||
|
||||
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_MM", String.Format("{0:MM}", 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];
|
||||
}
|
||||
|
||||
//public static String GetMonatlicheRechnungenString(DateTime date)
|
||||
//{
|
||||
// var sql = GetMonatlicheRechnungenSql(date);
|
||||
|
||||
// /*
|
||||
// sip.Claim,
|
||||
// c.DebitorNumber,
|
||||
// ib.InvoiceDate,
|
||||
// ib.invoicenumber,
|
||||
// c.CostCenter,
|
||||
// c2s.Oid,
|
||||
// ib.InvoiceId,
|
||||
// org.DebitorNumber
|
||||
// */
|
||||
|
||||
//"Datum;Konto;Gegenkonto;Buchungstext;Belegfeld1;Umsatz Soll;Kostenstelle"
|
||||
// var dt = ExecuteQuery(sql, date);
|
||||
|
||||
// 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:ddMM}", lastDate));
|
||||
// sb.Append(";");
|
||||
// sb.Append(String.Format("{0}", row[1]));
|
||||
// sb.Append(";");
|
||||
// sb.Append(String.Format("{0}", row[7]));
|
||||
// sb.Append(";");
|
||||
// String buchungstext = "";
|
||||
// long? c2sOid = (long?)row[5];
|
||||
|
||||
// if (c2sOid.HasValue)
|
||||
// {
|
||||
// var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(c2sOid.Value);
|
||||
|
||||
// var c = c2s.SupportConcept.Customer;
|
||||
|
||||
// buchungstext = String.Format("{0}, {1}", c.Person.LastName, c.Person.FirstName);
|
||||
// }
|
||||
|
||||
// sb.Append(buchungstext);
|
||||
// sb.Append(";");
|
||||
// sb.Append(String.Format("{0}", row[3]));
|
||||
// sb.Append(";");
|
||||
// sb.Append(String.Format("{0:0.00}", row[0]));
|
||||
// sb.Append(";");
|
||||
// sb.Append(String.Format("{0}", row[4]));
|
||||
// }
|
||||
|
||||
// return sb.ToString();
|
||||
//}
|
||||
//private static String GetMonatlicheRechnungenSql(DateTime date)
|
||||
//{
|
||||
// String sql = @"
|
||||
// select
|
||||
// sip.Claim,
|
||||
// c.DebitorNumber,
|
||||
// ib.InvoiceDate,
|
||||
// ib.invoicenumber,
|
||||
// c.CostCenter,
|
||||
// c2s.Oid,
|
||||
// ib.InvoiceId,
|
||||
// org.DebitorNumber
|
||||
// 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;
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user