From 829c3e82e414ad43cb6aa7d2a54ecdf420c79c6f Mon Sep 17 00:00:00 2001 From: Alexandra Date: Tue, 27 Feb 2024 15:30:11 +0100 Subject: [PATCH] BeWoWalzPaiva/Service/CustomAccountingService - Storno --- .../Service/CustomAccountingService.cs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 ReportImp/BeWoWalzPaiva/Service/CustomAccountingService.cs 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