LebenshilfeBadKreuznachWohnstaette/Service/CustomAccountingService Abrechnung auch abgelaufener HPs und SageExporter mit Allg Rechnung
SupportOID=160611
This commit is contained in:
@@ -82,10 +82,10 @@ ib.AccountingPeriodEnd,
|
||||
String buchungstext = String.Format("AR {0} {1:MM}/{1:yyyy} {2}", row[5], row[11], row[6]);
|
||||
sb.Append(buchungstext);
|
||||
sb.Append(";");
|
||||
sb.Append(String.Format("{0}", row[2])); // Sollkonto - Debitornr. Klient
|
||||
sb.Append(String.Format("{0}", row[2])); // Sollkonto - Debitornr. Klient bzw. bei Allgemeiner Rechnung Dummy
|
||||
sb.Append(";");
|
||||
String hbnKto = " S82004"; // Habenkonto für BG1 und BG"
|
||||
if (row[8].ToString().Contains("Wegevergütung"))
|
||||
String hbnKto = " S82004"; // Habenkonto für TODO "
|
||||
if (row[8].ToString().Contains(""))
|
||||
{
|
||||
hbnKto = " S82010";
|
||||
}
|
||||
@@ -95,7 +95,7 @@ ib.AccountingPeriodEnd,
|
||||
sb.Append(";EUR;;;");
|
||||
sb.Append(String.Format("{0}", row[9]));
|
||||
sb.Append(";;;;;");
|
||||
String kreis = "4"; // Buchungskreis für Team Inklusionsdienst oder KEIN Team = 12 sonst 11
|
||||
String kreis = "4"; // Buchungskreis TODO
|
||||
if (row[12].ToString().Contains("Inklusionsdienst") || row[12].ToString() == null)
|
||||
{
|
||||
kreis = "5";
|
||||
@@ -110,31 +110,51 @@ ib.AccountingPeriodEnd,
|
||||
{
|
||||
|
||||
String sql = @"
|
||||
SELECT
|
||||
cb2sc.Oid,
|
||||
ib.InvoiceNumber,
|
||||
c.DebitorNumber,
|
||||
Round(ii.GrossAmountTotal, 2) AS 'Betrag',
|
||||
ib.InvoiceDate,
|
||||
org.Name AS 'VerwendungOrg',
|
||||
CONCAT(p.`LastName`, ', ', p.`FirstName`) as 'VerwendungPerson',
|
||||
org.DebitorNumber,
|
||||
ii.ItemDescription,
|
||||
c.CostCenter,
|
||||
ib.Oid,
|
||||
ib.AccountingPeriodEnd,
|
||||
(select t.name from team t inner join team2customer t2c on t2c.teamoid = t.oid where t2c.customeroid = c.Oid limit 1) AS Team
|
||||
FROM `supportconcept` sc
|
||||
INNER JOIN `costbearer2supportconcept` cb2sc ON sc.`Oid` = cb2sc.`SupportConceptOid`
|
||||
INNER JOIN `costbearer` cb ON cb2sc.`CostBearerOid` = 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 invoicebase ib on ib.costbearer2supportconceptoid = cb2sc.oid
|
||||
inner join serviceinvoice si on si.invoicebaseoid = ib.oid
|
||||
inner join serviceinvoiceperiod sip on sip.serviceinvoiceoid = si.oid
|
||||
inner join invoiceitem ii on ii.serviceinvoiceperiodoid = sip.oid
|
||||
WHERE ib.`AccountingPeriodEnd` >= ':Monat_Start' AND ib.`AccountingPeriodEnd` < ':Monat_End' and ib.IsActive = 1
|
||||
SELECT
|
||||
cb2sc.Oid,
|
||||
ib.InvoiceNumber,
|
||||
c.DebitorNumber,
|
||||
Round(ii.GrossAmountTotal, 2) AS 'Betrag',
|
||||
ib.InvoiceDate,
|
||||
org.Name AS 'VerwendungOrg',
|
||||
CONCAT(p.`LastName`, ', ', p.`FirstName`) as 'VerwendungPerson',
|
||||
org.DebitorNumber,
|
||||
ii.ItemDescription,
|
||||
c.CostCenter,
|
||||
ib.Oid,
|
||||
ib.AccountingPeriodEnd,
|
||||
(select t.name from team t inner join team2customer t2c on t2c.teamoid = t.oid where t2c.customeroid = c.Oid limit 1) AS Team
|
||||
FROM `supportconcept` sc
|
||||
INNER JOIN `costbearer2supportconcept` cb2sc ON sc.`Oid` = cb2sc.`SupportConceptOid`
|
||||
INNER JOIN `costbearer` cb ON cb2sc.`CostBearerOid` = 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 invoicebase ib on ib.costbearer2supportconceptoid = cb2sc.oid
|
||||
inner join serviceinvoice si on si.invoicebaseoid = ib.oid
|
||||
inner join serviceinvoiceperiod sip on sip.serviceinvoiceoid = si.oid
|
||||
inner join invoiceitem ii on ii.serviceinvoiceperiodoid = sip.oid
|
||||
WHERE ib.`AccountingPeriodEnd` >= ':Monat_Start' AND ib.`AccountingPeriodEnd` < ':Monat_End' and ib.IsActive = 1
|
||||
UNION
|
||||
SELECT DISTINCT
|
||||
'' AS Oid,
|
||||
ib.invoicenumber,
|
||||
'D222222' AS DebitorNumber
|
||||
(select ii.AmountTotal from invoiceitem ii where ii.invoicebaseoid = ib.oid),
|
||||
ib.InvoiceDate,
|
||||
ib.RecipientOrganisation AS 'VerwendungOrg',
|
||||
CONCAT(ib.'RecipientPersonLastName`, ', ', ib.'RecipientPersonFirstName`) as 'VerwendungPerson',
|
||||
'S99999' AS DebitorNumber,
|
||||
ii.ItemDescription,
|
||||
'T60000',
|
||||
ib.Oid,
|
||||
ib.AccountingPeriodEnd,
|
||||
'Allgemeine Rechnung' AS Team
|
||||
from invoicebase ib
|
||||
inner join organisation org on org.costbeareroid = ib.RecipientOrganisationOid
|
||||
WHERE ib.`AccountingPeriodEnd` >= ':Monat_Start' AND ib.`AccountingPeriodEnd` < ':Monat_End' and ib.IsActive = 1
|
||||
and ib.Type = 2 AND ib.`IsExported` = 0
|
||||
-- order by ib.invoicenumber
|
||||
ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`
|
||||
";
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@
|
||||
<Compile Include="AdditionalServiceBookingReport.Designer.cs">
|
||||
<DependentUpon>AdditionalServiceBookingReport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Export\CustomDataExporter.cs" />
|
||||
<Compile Include="Export\SageExporter.cs" />
|
||||
<Compile Include="InvoiceCustomerReport.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -96,6 +98,7 @@
|
||||
<Compile Include="ServiceInvoiceReport.Designer.cs">
|
||||
<DependentUpon>ServiceInvoiceReport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Service\CustomAccountingService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Data\Data.csproj">
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Windows;
|
||||
using BeWo.Data;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.Invoicing;
|
||||
using BeWo.Service.Plugins;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
|
||||
namespace LebenshilfeBadKreuznachWohnstaette.Service
|
||||
{
|
||||
public class CustomAccountingService : AccountingService
|
||||
{
|
||||
// entspricht dem Original, außer dass die Bewilligung des Hilfeplans abgelaufen sein kann
|
||||
public override List<ServiceInvoiceDC> GenerateInitialServiceInvoices(long costBearerOid, long? supportConceptOid, DateTimeSpan invoicePeriod)
|
||||
{
|
||||
var cs = PluginLoader.FindClass<CustomerService>();
|
||||
IEnumerable<CompactSupportConceptDC> supportConcepts;
|
||||
// GetAllActiveSupportConceptCostbearer returns a "Flat" SupportConcept List, one for each CostBearer2SupportConcept!
|
||||
if (!supportConceptOid.HasValue)
|
||||
{
|
||||
supportConcepts = cs.GetAllActiveSupportConceptCostbearer(false, true, 0)
|
||||
.Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid));
|
||||
}
|
||||
else
|
||||
{
|
||||
supportConcepts = cs.GetCompactSupportConcepts(supportConceptOid.Value, null)
|
||||
.Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid));
|
||||
}
|
||||
|
||||
DateTimeSpan newSpan = null;
|
||||
if (invoicePeriod != null)
|
||||
{
|
||||
//invoicePeriod.StartDateTime = invoicePeriod.StartDateTime.Date;
|
||||
//invoicePeriod.EndDateTime = invoicePeriod.EndDateTime.Date;
|
||||
newSpan = new DateTimeSpan();
|
||||
newSpan.StartDateTime = invoicePeriod.StartDateTime.Date;
|
||||
newSpan.EndDateTime = invoicePeriod.EndDateTime.Date.AddDays(1).AddTicks(-1);
|
||||
//if (!supportConceptOid.HasValue)
|
||||
//{
|
||||
// supportConcepts =
|
||||
// supportConcepts.Where(sc => sc.StartDate < newSpan.EndDateTime && sc.EndDate >= newSpan.StartDate);
|
||||
//}
|
||||
}
|
||||
var supportConcepts2ServiceRecords = supportConcepts.ToDictionary(
|
||||
i => i,
|
||||
i => MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(
|
||||
DAOFactory.SearchDAO.FindServiceRecordsInSpan(i.CostBearerRelOids[0], newSpan)));
|
||||
var cb = DAOFactory.GenericDAO.LoadByID<CostBearer>(costBearerOid);
|
||||
String tenant = PluginLoader.Tenant;
|
||||
var factory = PluginLoader.FindClass<InvoiceFactory>(cb.ID);
|
||||
if (factory == null)
|
||||
{
|
||||
factory = InvoiceFactory.GetInstance(cb.ID, tenant);
|
||||
}
|
||||
|
||||
var creator = factory.CreateInvoiceCreator(cb.ID, tenant, supportConcepts2ServiceRecords);
|
||||
var newInvoices = creator.GenerateServiceInvoices(costBearerOid, invoicePeriod, supportConcepts2ServiceRecords);
|
||||
|
||||
|
||||
//Prüfe ob Rechnungen neu sind oder Diff vorhanden
|
||||
var differenzRechnungChecks = GetNewInvoices(newInvoices, invoicePeriod?.StartDate, invoicePeriod?.EndDate);
|
||||
var resultList = ErstelleNeueRechnungen(differenzRechnungChecks);
|
||||
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user