HPHBersenbrueck/RechnungSelbstzahler mit MicosExporter

This commit is contained in:
2023-06-12 17:26:16 +02:00
parent e6f5c3f04c
commit 7fe36f66a2
3 changed files with 113 additions and 632 deletions

View File

@@ -253,335 +253,66 @@ CONCAT(p.`LastName`, ', ', p.`FirstName`, ' ', IF(cb2sc.CustomerRefenrenceNumber
{
/*
*
* folgende Kostenstellen gehören zu den Leistungsarten:
35701 Betreuungseinheiten FUD KST: 35700
35702 Kostenbeteiligung Betreuung KST: 35700
* folgende Kostenstellen gehören zu den Teams:
* Team Tagesstätte Brückenort: Kostenstelle 34650
* (Hier soll zunächst einmal nichts über den BeWo-Planer abgerechnet werden.)
35703 Kilometerpauschale KST 35700
Team WA Bersenbrück: Kostenstelle 35550
35801 Niedrigschwellige Betreuung KST: 35800
Team WA Bramsche und Team WA GGW nutzen die gemeinsame Kostenstelle 35540
35831 Verhinderungspflege nach § 39 KST: 35800
35901 Sachkosten Reise KST 35900
35904 Betreuungskosten o. Pflegegrad KST: 35900
35911 Betreuungskosten mit Pflegegrad KST: 35900
35956 Sachkosten Kurzurlaub KST: 35955
Team WA Psych: Kostenstelle 35530
*/
if (row[6] != null)
if (row[9] != null)
{
String verwendungszweck = row[6].ToString();
String team = row[9].ToString();
if (verwendungszweck.Contains("Niederschwellig"))
{
return "35800";
}
if (verwendungszweck.Contains("Verhinderungspflege"))
{
return "35800";
}
if (verwendungszweck.Contains("Kurzurlaub"))
{
return "35955";
}
if (verwendungszweck.Contains("Reise"))
if (team.Contains("Bersenbrück"))
{
return "35550";
}
if (team.Contains("Bramsche"))
{
return "35540";
}
if (team.Contains("GGW"))
{
return "35955";
}
if (team.Contains("Psych"))
{
return "35530";
}
if (team.Contains("Brückenort"))
{
return "34650";
}
}
return "35540";
return "00000";
}
private static Dictionary<long, decimal> CreateDictionary(DataTable dt)
{
Dictionary<long, decimal> dict = new Dictionary<long, decimal>();
if (dt != null)
{
foreach (DataRow row in dt.Rows)
{
long? oid = row.ItemArray[0] as long?;
decimal? betrag = row.ItemArray[4] as decimal?;
if (oid.HasValue && betrag.HasValue)
{
dict.Add(oid.Value, betrag.Value);
}
}
}
return dict;
}
//private static void ErstelleKostenstellenZeilenAlt(DataRow row, StringBuilder sb)
//private static Dictionary<long, decimal> CreateDictionary(DataTable dt)
//{
// if (row.ItemArray.Length > 14)
// Dictionary<long, decimal> dict = new Dictionary<long, decimal>();
// if (dt != null)
// {
// var betragObj = row[14];
// decimal gesamtbetrag = 0;
// if (betragObj != null)
// foreach (DataRow row in dt.Rows)
// {
// Decimal.TryParse(betragObj.ToString().Replace(".", ","), out gesamtbetrag);
// }
// decimal betrag1 = Math.Round(gesamtbetrag * 0.1643m, 2, MidpointRounding.AwayFromZero);
// decimal betrag2 = Math.Round(gesamtbetrag * 0.8213m, 2, MidpointRounding.AwayFromZero);
// decimal betrag3 = gesamtbetrag - betrag1 - betrag2;
// long? oid = row.ItemArray[0] as long?;
// decimal? betrag = row.ItemArray[4] as decimal?;
// sb.AppendLine();
// sb.Append("K;0;610900;;;;;;");
// sb.Append(String.Format("{0:0.##}", betrag1 * -1).Replace(",", "."));
// sb.AppendLine(";");
// sb.Append("K;0;610901;;;;;;");
// sb.Append(String.Format("{0:0.##}", betrag2 * -1).Replace(",", "."));
// sb.AppendLine(";");
// sb.Append("K;0;610902;;;;;;");
// sb.Append(String.Format("{0:0.##}", betrag3 * -1).Replace(",", "."));
// sb.Append(";");
// }
//}
//private static void ErstelleKostenstellenZeilenNeu(DataRow row, StringBuilder sb, Dictionary<long, decimal> c2sOid2AssiBetrag, Dictionary<long, decimal> c2sOid2OtBetrag, Dictionary<long, decimal> c2sOid2SoziBetrag)
//{
// if (row.ItemArray.Length > 15)
// {
// long? oid = row[0] as long?;
// var betragObj = row[15];
// decimal gesamtbetrag = 0;
// if (betragObj != null)
// {
// Decimal.TryParse(betragObj.ToString().Replace(".", ","), out gesamtbetrag);
// }
// decimal betragBewo = Math.Round(gesamtbetrag, 2, MidpointRounding.AwayFromZero);
// decimal betragGruppen = 0;//Math.Round(gesamtbetrag, 2, MidpointRounding.AwayFromZero);
// decimal betragAssistenz = 0;//Math.Round(gesamtbetrag, 2, MidpointRounding.AwayFromZero);
// decimal betragSozi = 0;
// if (oid.HasValue && c2sOid2AssiBetrag.ContainsKey(oid.Value))
// {
// betragAssistenz = c2sOid2AssiBetrag[oid.Value];
// betragAssistenz = Math.Round(betragAssistenz, 2, MidpointRounding.AwayFromZero);
// betragBewo -= betragAssistenz;
// }
// if (oid.HasValue && c2sOid2OtBetrag.ContainsKey(oid.Value))
// {
// betragGruppen = c2sOid2OtBetrag[oid.Value];
// betragGruppen = Math.Round(betragGruppen, 2, MidpointRounding.AwayFromZero);
// betragBewo -= betragGruppen;
// }
// if (oid.HasValue && c2sOid2SoziBetrag.ContainsKey(oid.Value))
// {
// betragSozi = c2sOid2SoziBetrag[oid.Value];
// betragSozi = Math.Round(betragSozi, 2, MidpointRounding.AwayFromZero);
// betragBewo -= betragSozi;
// }
// //bewo 610900
// //offener Treff 610910 Leistungskategorie Gruppenbuchung
// //Assistenzleistungen 610915 Leistungskategorien Assistenz (Kategorie Assistenzleistungen)
// //Bei Finanzauswertungen nach diesen drei Kategorien trennen
// //Rechnungen als AWO Vorlage
// if (betragBewo != 0)
// {
// sb.AppendLine();
// sb.Append("K;0;610900;;;;;;");
// sb.Append(String.Format("{0:0.##}", betragBewo * -1).Replace(",", "."));
// sb.Append(";");
// }
// if (betragGruppen > 0)
// {
// sb.AppendLine();
// sb.Append("K;0;610910;;;;;;");
// sb.Append(String.Format("{0:0.##}", betragGruppen * -1).Replace(",", "."));
// sb.Append(";");
// }
// if (betragAssistenz > 0)
// {
// sb.AppendLine();
// sb.Append("K;0;610915;;;;;;");
// sb.Append(String.Format("{0:0.##}", betragAssistenz * -1).Replace(",", "."));
// sb.Append(";");
// }
// if (betragSozi > 0)
// {
// sb.AppendLine();
// sb.Append("K;0;610905;;;;;;");
// sb.Append(String.Format("{0:0.##}", betragSozi * -1).Replace(",", "."));
// sb.Append(";");
// if (oid.HasValue && betrag.HasValue)
// {
// dict.Add(oid.Value, betrag.Value);
// }
// }
// }
// return dict;
//}
//public static String GetAbschlagszahlungenString(DateTime date)
//{
// var dt = ExecuteQuery(GetAbschlagszahlungenSql(date), date);
// StringBuilder sb = new StringBuilder();
// foreach (DataRow row in dt.Rows)
// {
// if (sb.Length > 0)
// {
// sb.AppendLine();
// }
// for (int i = 0; i < row.ItemArray.Length; i++)
// {
// if (i > 0)
// {
// sb.Append(";");
// }
// if (i == 32)
// {
// sb.AppendLine();
// }
// var item = row[i];
// bool quote = i == 15 || i == 38;
// if (quote)
// {
// sb.Append('"');
// sb.Append(item);
// sb.Append('"');
// }
// else
// {
// sb.Append(item);
// }
// }
// }
// //F,0,050,,BEWO,DA,02012016,012016,iBelegNr2,Belegnr2,220001,,,,-888.88, "Name AZ Abschlagszahlung LVR 01/2016",,,EUR,,,,,,,,,,,R,,,
// //G,0,4473,,,888.88,"Name AZ Abschlagszahlung LVR 05/2016",
// return sb.ToString();
//}
//public static String GetSelbstzahlerString(DateTime date)
//{
// var dt = ExecuteQuery(GetSelbstzahlerSql(date), date);
// StringBuilder sb = new StringBuilder();
// foreach (DataRow row in dt.Rows)
// {
// if (sb.Length > 0)
// {
// sb.AppendLine();
// }
// for (int i = 0; i < row.ItemArray.Length; i++)
// {
// if (i > 0)
// {
// sb.Append(";");
// }
// if (i == 32)
// {
// sb.AppendLine();
// }
// var item = row[i];
// bool quote = i == 15 || i == 38;
// if (quote)
// {
// sb.Append('"');
// sb.Append(item);
// sb.Append('"');
// }
// else
// {
// sb.Append(item);
// }
// }
// }
// return sb.ToString();
//}
// private static String GetMonatlicheAbrechnungLvrSqlAlt(DateTime date)
// {
// String sql = @"
//SELECT
//'F',
//'0',
//'114',
//null,
//'BEWO',
//'AR',
//':Abrechnungsmonat',
//':Periode',
//null,
//GetNextBelegnr(1),
//c.DebitorNumber,
//null,
//null,
//null,
//REPLACE(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',
//CONCAT(p.`LastName`, ', ', p.`FirstName`, ' ', IF(cb2sc.CustomerRefenrenceNumber is null, '', cb2sc.CustomerRefenrenceNumber), ' Abrechnung :PeriodeSlash ', org.Name) as 'Verwendung',
//null,
//null,
//'EUR',
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//'G',
//'0',
//'49100000',
//null,
//null,
//REPLACE(-1 * 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 'Betrag2',
//CONCAT(p.`LastName`, ', ', p.`FirstName`, ' ', IF(cb2sc.CustomerRefenrenceNumber is null, '', cb2sc.CustomerRefenrenceNumber), ' Abrechnung :PeriodeSlash ', org.Name) as 'Verwendung2',
//null
//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)
//ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`
//";
// return sql;
// }
private static String GetRechnungenSql(DateTime date, DateTime rechnungsDatumVon, DateTime rechnungsDatumBis)
{
if (rechnungsDatumVon <= new DateTime(1900, 1, 1))
@@ -608,7 +339,8 @@ ib.InvoiceDate,
CONCAT(p.`LastName`, ', ', p.`FirstName`, ' ', org.Name) as 'Verwendung',
ii.ItemDescription,
ib.Oid,
ib.AccountingPeriodEnd
ib.AccountingPeriodEnd,
(select t.name from team t inner join team2customer t2c on t2c.teamoid = t.oid where t2c.customeroid = c.Oid limit 1)
FROM `supportconcept` sc
INNER JOIN `costbearer2supportconcept` cb2sc ON sc.`Oid` = cb2sc.`SupportConceptOid`
INNER JOIN `costbearer` cb ON cb2sc.`CostBearerOid` = cb.`Oid`
@@ -629,232 +361,6 @@ ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`
return sql;
}
// private static String GetAbschlagszahlungenSql(DateTime date)
// {
// String sql = @"
//SELECT
//'F',
//'0',
//'114',
//null,
//'BEWO',
//'AR',
//':Abrechnungsmonat',
//':Periode',
//GetNextBelegnr(0),
//GetNextBelegnr(1),
//c.DebitorNumber,
//null,
//null,
//null,
//REPLACE(-1 * ROUND(at.`GesamtBetrag`, 2), ',', '.') as 'Abschlagszahlungen',
//CONCAT(p.`LastName`, ', ', p.`FirstName`, ' ', IF(cb2sc.CustomerRefenrenceNumber is null, '', cb2sc.CustomerRefenrenceNumber), ' Abschlagszahlung :PeriodeSlash ', org.Name) as 'Verwendung',
//null,
//null,
//'EUR',
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//'G',
//'0',
//'48301000',
//null,
//null,
//REPLACE(ROUND(at.`GesamtBetrag`, 2), ',', '.') as 'Abschlagszahlungen2',
//CONCAT(p.`LastName`, ', ', p.`FirstName`, ' ', IF(cb2sc.CustomerRefenrenceNumber is null, '', cb2sc.CustomerRefenrenceNumber), ' Abschlagszahlung :PeriodeSlash ', org.Name) as 'Verwendung2',
//null
//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 at2.`CostBearer2SupportConceptOid`, SUM(at2.`Amount`) AS GesamtBetrag FROM `accountingtransaction` at2
// WHERE at2.`BookingDate` >= ':Monat_Start' AND at2.`BookingDate` < ':Monat_End' GROUP BY at2.`CostBearer2SupportConceptOid`)
// AS at ON at.`CostBearer2SupportConceptOid` = cb2sc.`Oid`
//WHERE c.`IsActive` = 1 AND sc.`IsActive` = 1
//and (at.`GesamtBetrag` is not null)
//ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`
//";
// return sql;
// }
// private static String GetSelbstzahlerSql(DateTime date)
// {
// String sql = @"
//SELECT
//'F',
//'0',
//'114',
//null,
//'BEWO',
//'AR',
//':Abrechnungsmonat',
//':Periode',
//GetNextBelegnr(0),
//GetNextBelegnr(1),
//c.DebitorNumber,
//null,
//null,
//null,
//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',
//CONCAT(p.`LastName`, ', ', p.`FirstName`, ' ', IF(cb2sc.CustomerRefenrenceNumber is null, '', cb2sc.CustomerRefenrenceNumber), ' Abrechnung :PeriodeSlash ', org.Name) as 'Verwendung',
//null,
//null,
//'EUR',
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//null,
//'G',
//'0',
//'xxxx',
//null,
//null,
//-1 * 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 'Betrag2',
//CONCAT(p.`LastName`, ', ', p.`FirstName`, ' ', IF(cb2sc.CustomerRefenrenceNumber is null, '', cb2sc.CustomerRefenrenceNumber), ' Abrechnung :PeriodeSlash ', org.Name) as 'Verwendung2',
//null
//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)
//ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`
//";
// return sql;
// }
// private static String GetMonatlicheAbrechnungStringForCatsSql(DateTime date, IList<long> includeCatOids, IList<long> excludeOids)
// {
// String sql = @"
//SELECT distinct
//cb2sc.oid,
//c.oid,
//sc.oid,
//c.DebitorNumber,
//IF(crpRateFactor.`CostRateValue` is null, ROUND((sr.`GeleisteteFLM` / 60) * crpHourlyRate.`CostRateValue`, 2),ROUND(ROUND((sr.`GeleisteteFLM` / 60), 2) * crpHourlyRate.`CostRateValue` * ((100 + crpRateFactor.`CostRateValue`)/100), 2)) AS 'Forderung',
//ROUND(crpHourlyRate.`CostRateValue`,2) as 'Stundensatz', ROUND(crpRateFactor.`CostRateValue`,2) as 'PauschalerFaktor',
//sr.`GeleisteteFLM`
//FROM `supportconcept` sc
//INNER JOIN `costbearer2supportconcept` cb2sc ON sc.`Oid` = cb2sc.`SupportConceptOid`
//INNER JOIN `costbearer` cb ON cb2sc.`CostBearerOid` = cb.`Oid`
//INNER JOIN
// (SELECT crp.`ObjectOid`, crp.costratetype, crp.`CostRateValue`, If(crp.Enddate is null, '9999-01-01', crp.enddate) as aenddatum, crptemp.enddatum FROM `costrateperiod` crp
// inner join (SELECT crpi.`ObjectOid`, Min(If(crpi.Enddate is null, '9999-01-01', crpi.enddate)) as enddatum FROM `costrateperiod` crpi
// WHERE crpi.`ObjectTid` = 22 AND crpi.`CostRateType` = 0 AND (crpi.`EndDate` is null or crpi.`EndDate` > ':Monat_Start')
// group by crpi.objectoid) as crptemp on crptemp.objectoid = crp.objectoid
// WHERE crp.`ObjectTid` = 22 and crp.costratetype = 0
// having aenddatum = crptemp.enddatum)
// AS crpHourlyRate ON crpHourlyRate.`ObjectOid` = cb.`Oid`
//LEFT JOIN
// (SELECT crp.`ObjectOid`, crp.costratetype, crp.`CostRateValue`, If(crp.Enddate is null, '9999-01-01', crp.enddate) as aenddatum, crptemp.enddatum FROM `costrateperiod` crp
// inner join (SELECT crpi.`ObjectOid`, Min(If(crpi.Enddate is null, '9999-01-01', crpi.enddate)) as enddatum FROM `costrateperiod` crpi
// WHERE crpi.`ObjectTid` = 22 AND crpi.`CostRateType` = 2 AND (crpi.`EndDate` is null or crpi.`EndDate` > ':Monat_Start')
// group by crpi.objectoid) as crptemp on crptemp.objectoid = crp.objectoid
// WHERE crp.`ObjectTid` = 22 and crp.costratetype = 2
// having aenddatum = crptemp.enddatum)
// 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`
//INNER 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:IncludeCatOidList:ExcludeCatOidList GROUP BY sr2.`CostBearer2SupportConceptOid`)
// AS sr ON sr.`CostBearer2SupportConceptOid` = cb2sc.`Oid`
//WHERE c.`IsActive` <> 0 AND sc.`IsActive` <> 0 and (sr.`GeleisteteFLM` is not null)
//ORDER BY p.`LastName`
//";
// String includeString = "";
// String excludeString = "";
// if (includeCatOids != null && includeCatOids.Count > 0)
// {
// StringBuilder oidList = new StringBuilder();
// foreach (var catOid in includeCatOids)
// {
// if (oidList.Length > 0)
// oidList.Append(",");
// oidList.Append(catOid);
// }
// includeString = String.Format(" AND sc.oid in ({0})", oidList.ToString());
// }
// if (excludeOids != null && excludeOids.Count > 0)
// {
// StringBuilder notoidList = new StringBuilder();
// foreach (var catOid in excludeOids)
// {
// if (notoidList.Length > 0)
// notoidList.Append(",");
// notoidList.Append(catOid);
// }
// excludeString = String.Format(" AND sc.oid not in ({0})", notoidList.ToString());
// }
// String gruppenfilter = "";
// //if (!holeEinzel || !holeGruppen)
// //{
// // if (holeGruppen)
// // {
// // gruppenfilter = "AND sr2.GroupOid is not null";
// // }
// // else
// // {
// // gruppenfilter = "AND sr2.GroupOid is null";
// // }
// //}
// sql = sql.Replace(":Gruppenfilter", gruppenfilter);
// sql = sql.Replace(":IncludeCatOidList", includeString);
// sql = sql.Replace(":ExcludeCatOidList", excludeString);
// return sql;
// }
public static DataTable ExecuteQuery(String sql, DateTime dt)
{
@@ -871,31 +377,6 @@ ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`
return DAOFactory.AdoDAO.ExecuteQuery(newsql).Tables[0];
}
//Buchung Abrechnung Stundenzettel
//F,0,050,, BEWO, DA,01012016,012016, iBelegNr1, Belegnr1,220001,,,,999.99, "Name AZ Abrechnung 01/2016 LVR",,, EUR,,,,,,,,,,, R,,,
//G,0,1695,,,-999.99,"Name AZ Abrechnung 01/2016 LVR",
//Buchung Abschlagszahlung
//F,0,050,, BEWO, DA,02012016,012016, iBelegNr2, Belegnr2,220001,,,,-888.88, "Name AZ Abschlagszahlung LVR 01/2016",,, EUR,,,,,,,,,,, R,,,
//G,0,4473,,,888.88,"Name AZ Abschlagszahlung LVR 05/2016",
//Buchung Abrechnung LVR / Selbstzahler
//F,0,050,, BEWO, DA,01022016,022016, iBelegNr3, Belegnr3,220001,,,,900.00, "Name AZ Abrechnung LVR + SZ 02/2016",,, EUR,,,,,,,,,,, R,,,
//G,0,1695,,,-800.00,"Name AZ Abrechnung 05/2016 LVR",
//G,0,1695,,,-100.00,"Name AZ Abrechnung 05/2016 SZ",
//schwarz = konstant
//rot = variabel
}
class MicosDatensatz
{

View File

@@ -1,77 +1,77 @@
using BeWo.Data.Entities;
using BeWo.Service.Invoicing;
using BS.Shared.Core;
using BS.Shared.DataContracts.Compact;
using System;
using System.Collections.Generic;
using System.Linq;
namespace HPHBersenbrueck.Invoicing
{
public class SelbstzahlerInvoiceCreation : InvoiceCreation
{
private DateTime? accountingPeriodStart = null;
using BeWo.Data.Entities;
using BeWo.Service.Invoicing;
using BS.Shared.Core;
using BS.Shared.DataContracts.Compact;
using System;
using System.Collections.Generic;
using System.Linq;
namespace HPHBersenbrueck.Invoicing
{
public class SelbstzahlerInvoiceCreation : InvoiceCreation
{
private DateTime? accountingPeriodStart = null;
private DateTime? accountingPeriodEnd = null;
public override void SetInvoiceId(ServiceInvoice invoice)
{
invoice.InvoiceBase.InvoiceId = "Selbstzahler";
invoice.InvoiceBase.InvoiceTypeText = "Selbstzahler";
}
public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod,
IList<CompactSupportConceptDC> supportConceptList)
{
if (invoicePeriod != null)
{
accountingPeriodStart = invoicePeriod.StartDate;
accountingPeriodEnd = invoicePeriod.EndDate;
}
base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList);
}
public override void SetRecipientInformation(ServiceInvoice serviceInvoice, CostBearer costBearer)
{
serviceInvoice.InvoiceBase.RecipientDivision = costBearer.Organisation.Name2;
serviceInvoice.InvoiceBase.RecipientOrganisationOid = costBearer.Organisation.Oid;
serviceInvoice.InvoiceBase.RecipientOrganisation = costBearer.Organisation.Name;
serviceInvoice.InvoiceBase.RecipientContacts = costBearer.Organisation.Contacts.Select(i => i.CopyToNew()).ToList();
serviceInvoice.InvoiceBase.RecipientCostBearerOid = costBearer.Oid;
if (serviceInvoice.InvoiceBase.CostBearer2SupportConcept != null)
{
var cust = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.SupportConcept.Customer;
if (cust.Person.InvoiceAddress != null)
{
serviceInvoice.InvoiceBase.RecipientAddress = cust.Person.InvoiceAddress.CopyToNew();
}
else if (cust.Person.Address != null)
{
serviceInvoice.InvoiceBase.RecipientAddress = cust.Person.Address.CopyToNew();
}
if (cust.Person.InvoiceAddress != null && cust.Person.InvoiceAddress.AddressLine1 != null)
{
serviceInvoice.InvoiceBase.RecipientPersonFirstName = cust.Person.InvoiceAddress.AddressLine1;
serviceInvoice.InvoiceBase.RecipientPersonLastName = "";
}
else
{
serviceInvoice.InvoiceBase.RecipientPersonFirstName = cust.Person.FirstName;
serviceInvoice.InvoiceBase.RecipientPersonLastName = cust.Person.LastName;
}
return;
}
if (costBearer.Organisation.InvoiceAddress != null)
{
serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.InvoiceAddress.CopyToNew();
}
else if (costBearer.Organisation.Address != null)
{
serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.Address.CopyToNew();
}
}
}
invoice.InvoiceBase.InvoiceTypeText = "Selbstzahler";
}
public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod,
IList<CompactSupportConceptDC> supportConceptList)
{
if (invoicePeriod != null)
{
accountingPeriodStart = invoicePeriod.StartDate;
accountingPeriodEnd = invoicePeriod.EndDate;
}
base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList);
}
public override void SetRecipientInformation(ServiceInvoice serviceInvoice, CostBearer costBearer)
{
serviceInvoice.InvoiceBase.RecipientDivision = costBearer.Organisation.Name2;
serviceInvoice.InvoiceBase.RecipientOrganisationOid = costBearer.Organisation.Oid;
serviceInvoice.InvoiceBase.RecipientOrganisation = costBearer.Organisation.Name;
serviceInvoice.InvoiceBase.RecipientContacts = costBearer.Organisation.Contacts.Select(i => i.CopyToNew()).ToList();
serviceInvoice.InvoiceBase.RecipientCostBearerOid = costBearer.Oid;
if (serviceInvoice.InvoiceBase.CostBearer2SupportConcept != null)
{
var cust = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.SupportConcept.Customer;
if (cust.Person.InvoiceAddress != null)
{
serviceInvoice.InvoiceBase.RecipientAddress = cust.Person.InvoiceAddress.CopyToNew();
}
else if (cust.Person.Address != null)
{
serviceInvoice.InvoiceBase.RecipientAddress = cust.Person.Address.CopyToNew();
}
if (cust.Person.InvoiceAddress != null && cust.Person.InvoiceAddress.AddressLine1 != null)
{
serviceInvoice.InvoiceBase.RecipientPersonFirstName = cust.Person.InvoiceAddress.AddressLine1;
serviceInvoice.InvoiceBase.RecipientPersonLastName = "";
}
else
{
serviceInvoice.InvoiceBase.RecipientPersonFirstName = cust.Person.FirstName;
serviceInvoice.InvoiceBase.RecipientPersonLastName = cust.Person.LastName;
}
return;
}
if (costBearer.Organisation.InvoiceAddress != null)
{
serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.InvoiceAddress.CopyToNew();
}
else if (costBearer.Organisation.Address != null)
{
serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.Address.CopyToNew();
}
}
}
}

View File

@@ -23,9 +23,9 @@ namespace HPHBersenbrueck
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.CustomerFirstName) && !String.IsNullOrEmpty(pRO.CustomerLastName))
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
{
sb.AppendLine(pRO.CustomerFirstName + " " + pRO.CustomerLastName);
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{