diff --git a/ReportImp/BeWoWalzPaiva/Service/CustomAccountingService.cs b/ReportImp/BeWoWalzPaiva/Service/CustomAccountingService.cs new file mode 100644 index 000000000..6a0f1116a --- /dev/null +++ b/ReportImp/BeWoWalzPaiva/Service/CustomAccountingService.cs @@ -0,0 +1,51 @@ +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 BeWoWalzPaiva.Service +{ + public class CustomAccountingService : AccountingService + { + + public override ServiceInvoice ErstelleStornoRechnung(InvoiceBaseDC ibdc) + { + var i = base.ErstelleStornoRechnung(ibdc); + + SetzeRechnungsnummer(i.InvoiceBase, ibdc); + i.InvoiceBase.StornoInvoiceBaseOid = ibdc.InvoiceBaseOid.Value; + DAOFactory.GenericDAO.Insert(i); + + var original = DAOFactory.GenericDAO.LoadByID(ibdc.InvoiceBaseOid.Value); + original.StornoInvoiceBaseOid = i.Oid; + DAOFactory.GenericDAO.Update(original); + + 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"; + } + } + } +} \ No newline at end of file