142 lines
4.9 KiB
C#
142 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
|
|
|
|
|
|
namespace PerspektivenEV.Service
|
|
{
|
|
public class CustomAccountingService : AccountingService
|
|
{
|
|
public override ServiceInvoice ErstelleStornoRechnung(InvoiceBaseDC ibdc)
|
|
{
|
|
var i = base.ErstelleStornoRechnung(ibdc);
|
|
|
|
SetzeRechnungsnummer(i.InvoiceBase, ibdc);
|
|
DAOFactory.GenericDAO.Insert(i);
|
|
return i;
|
|
}
|
|
|
|
public override InvoiceBase ErstelleStornoAllgemeineRechnung(InvoiceBaseDC ibdc)
|
|
{
|
|
var i = base.ErstelleStornoAllgemeineRechnung(ibdc);
|
|
|
|
SetzeRechnungsnummer(i, ibdc);
|
|
DAOFactory.GenericDAO.Insert(i);
|
|
return i;
|
|
}
|
|
|
|
//public override InvoiceBase ErstelleStornoSpitzabrechnung(InvoiceBaseDC ibdc)
|
|
//{
|
|
// var i = base.ErstelleStornoSpitzabrechnung(ibdc);
|
|
|
|
// SetzeRechnungsnummer(i, ibdc);
|
|
// DAOFactory.GenericDAO.Insert(i);
|
|
// return i;
|
|
//}
|
|
|
|
private void SetzeRechnungsnummer(InvoiceBase neu, InvoiceBaseDC alt)
|
|
{
|
|
if (!String.IsNullOrEmpty(neu.InvoiceNumber))
|
|
{
|
|
neu.InvoiceNumber = alt.InvoiceNumber + " Storno";
|
|
}
|
|
|
|
if (String.IsNullOrEmpty(neu.InvoiceTypeText))
|
|
{
|
|
neu.InvoiceTypeText = "Storno";
|
|
}
|
|
else
|
|
{
|
|
neu.InvoiceTypeText += " Storno";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//public override void StorniereInvoiceBases(List<InvoiceBaseDC> invoices)
|
|
//{
|
|
// foreach (var item in invoices)
|
|
// {
|
|
// if (item.Type.ToString() == "General" || item.Type.ToString() == "CustomerEquity" || item.RecipientOrganisation.Contains("LWV"))
|
|
// MessageBox.Show("Rechnungen vom Typ Allgemein oder Eigenanteil oder an den LWV können nicht automatisch storniert werden", "Rechnung stornieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
// else
|
|
// ErstelleStornoRechnung(item);
|
|
// }
|
|
//}
|
|
|
|
//public override List<InvoiceBaseDC> GetInvoiceBases(DateTime? startDate, DateTime? endDate)
|
|
//{
|
|
// DateTime? end = endDate;
|
|
// if (end.HasValue)
|
|
// {
|
|
// end = end.Value.Date.AddDays(1).AddTicks(-1);
|
|
// }
|
|
// var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end, false);
|
|
|
|
// var returnlist = new List<InvoiceBaseDC>();
|
|
// foreach (var ib in list)
|
|
// {
|
|
// var dc = MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDC(ib);
|
|
|
|
// if (String.IsNullOrEmpty(dc.CustomerFirstName) && String.IsNullOrEmpty(dc.CustomerLastName) && ib.Type == InvoiceType.Service && (ib.InvoiceTypeText == "Tagesstruktur" || ib.InvoiceTypeText == "Tagesstruktur Storno"))
|
|
// {
|
|
// var si = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(ib.Oid.Value);
|
|
// if (si != null)
|
|
// {
|
|
// var names = new List<String>();
|
|
|
|
// foreach (var sip in si.ServiceInvoicePeriodList)
|
|
// {
|
|
// if (sip.Customer != null)
|
|
// {
|
|
// names.Add(sip.Customer.Person.LastNameFirstName);
|
|
// }
|
|
// }
|
|
|
|
// dc.CustomerLastName = "";
|
|
// foreach (var name in names.OrderBy(n => n))
|
|
// {
|
|
// if (dc.CustomerLastName.Length > 0)
|
|
// {
|
|
// dc.CustomerLastName += "\n";
|
|
// }
|
|
|
|
// dc.CustomerLastName += name;
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// else if (ib.InvoiceId == "RechnungHort" || ib.InvoiceId == "RechnungHortPrivat")
|
|
// {
|
|
// dc.CustomerFirstName = "";
|
|
// dc.CustomerLastName = "";
|
|
|
|
// var si = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(ib.Oid.Value);
|
|
// if (si != null)
|
|
// {
|
|
// foreach (var sip in si.ServiceInvoicePeriodList)
|
|
// {
|
|
// if (!String.IsNullOrEmpty(sip.Notice))
|
|
// {
|
|
// dc.CustomerLastName = sip.Notice;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// returnlist.Add(dc);
|
|
// }
|
|
// return returnlist;
|
|
|
|
|
|
//}
|
|
}
|
|
} |