Ansatz calculate
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using BeWo.Data.Access;
|
||||||
using BS.Shared;
|
using BS.Shared;
|
||||||
using BS.Shared.Interface;
|
using BS.Shared.Interface;
|
||||||
|
|
||||||
@@ -833,5 +834,49 @@ namespace BeWo.Data.Entities
|
|||||||
public virtual IList<IInvoiceItem> IInvoiceItems => InvoiceItems.Select(x => x as IInvoiceItem).ToList();
|
public virtual IList<IInvoiceItem> IInvoiceItems => InvoiceItems.Select(x => x as IInvoiceItem).ToList();
|
||||||
|
|
||||||
public virtual StoredFile XRechnungStoredFile { get; set; }
|
public virtual StoredFile XRechnungStoredFile { get; set; }
|
||||||
|
|
||||||
|
public virtual IEnumerable<InvoiceItem> GetInvoiceItems()
|
||||||
|
{
|
||||||
|
IEnumerable < InvoiceItem > ret = null;
|
||||||
|
|
||||||
|
if (Type == InvoiceType.Service && Oid.HasValue)
|
||||||
|
{
|
||||||
|
var inv = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(Oid.Value);
|
||||||
|
if (inv != null)
|
||||||
|
{
|
||||||
|
ret = inv.GetInvoiceItems();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//pDataContract.TotalAmount = -99999999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Type == InvoiceType.Settlement)
|
||||||
|
{
|
||||||
|
//Ist eigentlich ein Fehler. Bei Spitzabrechnungen muss immer ein InvoiceItem vorhanden sein.
|
||||||
|
//Durch einen mittlerweile behobenen Programmfehler gibt es einzelen ältere Rechnungen, bei denen das nicht so ist.
|
||||||
|
if (!string.IsNullOrEmpty(XMLData))
|
||||||
|
{
|
||||||
|
//var settlementdc = BS.Shared.Core.Utils.XMLDeserializeFromString<SettlementDC>(invoiceBase.XMLData);
|
||||||
|
//pDataContract.TotalAmount = settlementdc.Claim;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = InvoiceItems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = InvoiceItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ret == null)
|
||||||
|
throw new NotImplementedException($"GetInvoiceItems: {Type} unbekannt.");
|
||||||
|
|
||||||
|
if (!ret.Any())
|
||||||
|
throw new NotImplementedException($"Keine InvoiceItems gefunden. InvoiceBaseOid: {Oid}");
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,5 +127,10 @@ namespace BeWo.Data.Entities
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual IEnumerable<InvoiceItem> GetInvoiceItems()
|
||||||
|
{
|
||||||
|
return ServiceInvoicePeriodList.SelectMany(x => x.InvoiceItemList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,6 @@ namespace BeWo.Service.DCEntityMapper
|
|||||||
{
|
{
|
||||||
//ignore
|
//ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (pEntity.SenderAddress != null)
|
if (pEntity.SenderAddress != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using BeWo.Data.Access;
|
using BeWo.Data.Access;
|
||||||
using BeWo.Data.Entities;
|
using BeWo.Data.Entities;
|
||||||
|
using BeWo.Data.Models.XRechnung;
|
||||||
using BeWo.Service.Core;
|
using BeWo.Service.Core;
|
||||||
using BeWo.Service.DCEntityMapper;
|
using BeWo.Service.DCEntityMapper;
|
||||||
using BeWo.Service.ServiceImplementations;
|
using BeWo.Service.ServiceImplementations;
|
||||||
@@ -12,6 +13,7 @@ using BS.Shared.DataContracts.MikePHPContracts;
|
|||||||
using BS.Shared.Interface;
|
using BS.Shared.Interface;
|
||||||
using DevExpress.Export;
|
using DevExpress.Export;
|
||||||
using DevExpress.Utils.Filtering.Internal;
|
using DevExpress.Utils.Filtering.Internal;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -24,29 +26,40 @@ namespace BeWo.Service.Plugins
|
|||||||
{
|
{
|
||||||
public class XRechnungService : AbstractIDSpecificDefaultClass<XRechnungService>
|
public class XRechnungService : AbstractIDSpecificDefaultClass<XRechnungService>
|
||||||
{
|
{
|
||||||
|
private readonly LocalTenantFileStorageDAO _storage;
|
||||||
|
private readonly GenericDAO _genericDAO;
|
||||||
|
private readonly FileLogger _logger;
|
||||||
|
|
||||||
|
public XRechnungService()
|
||||||
|
{
|
||||||
|
// Hole Storage
|
||||||
|
var lStoragePath = MergedConfig.GetSetting(WebConfigSetting.StoredTenantFilesFolderPath);
|
||||||
|
_storage = DAOFactory.GetLocalTenantFileStorage(lStoragePath);
|
||||||
|
|
||||||
|
_genericDAO = DAOFactory.GenericDAO;
|
||||||
|
_logger = ServiceHelper.CoreLogger;
|
||||||
|
}
|
||||||
|
|
||||||
public ApiResponse<Tuple<StoredFileDC, byte[]>> GetXRechnung(long invoice_base_oid, int report_type, string report_url)
|
public ApiResponse<Tuple<StoredFileDC, byte[]>> GetXRechnung(long invoice_base_oid, int report_type, string report_url)
|
||||||
{
|
{
|
||||||
// Hole Parameter
|
var invoice_base = _genericDAO.LoadByID<InvoiceBase>(invoice_base_oid);
|
||||||
var lStoragePath = MergedConfig.GetSetting(WebConfigSetting.StoredTenantFilesFolderPath);
|
|
||||||
var lStorage = DAOFactory.GetLocalTenantFileStorage(lStoragePath);
|
|
||||||
|
|
||||||
var invoice_base = DAOFactory.GenericDAO.LoadByID<InvoiceBase>(invoice_base_oid);
|
|
||||||
var stored_file = invoice_base.XRechnungStoredFile;
|
var stored_file = invoice_base.XRechnungStoredFile;
|
||||||
|
|
||||||
// Falls Lokal vorhanden, gebe lokale Version zurück
|
// Falls Lokal vorhanden, gebe lokale Version zurück
|
||||||
if (stored_file?.FileName is string lFileName && tryGetXRechnungLocal(lStorage, lFileName, out var bytes))
|
if (stored_file?.FileName is string lFileName && tryGetXRechnungLocal(_storage, lFileName, out var bytes))
|
||||||
{
|
{
|
||||||
var stored_file_dc = MapperFactory.StoredFile.MapToNewDC(stored_file);
|
var stored_file_dc = MapperFactory.StoredFile.MapToNewDC(stored_file);
|
||||||
return ApiResponse<Tuple<StoredFileDC, byte[]>>.SuccessResponse(new Tuple<StoredFileDC, byte[]>(stored_file_dc, bytes));
|
return ApiResponse<Tuple<StoredFileDC, byte[]>>.SuccessResponse(new Tuple<StoredFileDC, byte[]>(stored_file_dc, bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lokal nicht vorhanden, berechne XRechnung
|
// Lokal nicht vorhanden, berechne XRechnung
|
||||||
var str = ServiceConfigReader.GetInvoiceTestJsonString();
|
var str = //ServiceConfigReader.GetInvoiceTestJsonString();
|
||||||
|
calculate(invoice_base);
|
||||||
|
|
||||||
// Erstelle Url ohne weitere Authentifizierung
|
// Erstelle Url ohne weitere Authentifizierung
|
||||||
var token_url = GetTokenUrl(report_url);
|
var token_url = GetTokenUrl(report_url);
|
||||||
|
|
||||||
return requestXRechnung(lStorage, invoice_base, str, token_url);
|
return requestXRechnung(_storage, invoice_base, str, token_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiResponse<Tuple<StoredFileDC, byte[]>> requestXRechnung(LocalTenantFileStorageDAO pStorage, InvoiceBase invoice_base, object obj, string token_url)
|
private ApiResponse<Tuple<StoredFileDC, byte[]>> requestXRechnung(LocalTenantFileStorageDAO pStorage, InvoiceBase invoice_base, object obj, string token_url)
|
||||||
@@ -70,7 +83,7 @@ namespace BeWo.Service.Plugins
|
|||||||
|
|
||||||
invoice_base.XRechnungStoredFile = stored_file;
|
invoice_base.XRechnungStoredFile = stored_file;
|
||||||
|
|
||||||
DAOFactory.GenericDAO.Update(invoice_base);
|
_genericDAO.Update(invoice_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
var stored_file_dc = MapperFactory.StoredFile.MapToNewDC(stored_file);
|
var stored_file_dc = MapperFactory.StoredFile.MapToNewDC(stored_file);
|
||||||
@@ -80,11 +93,11 @@ namespace BeWo.Service.Plugins
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServiceHelper.CoreLogger.LogError(ex, nameof(GetXRechnung));
|
_logger.LogError(ex, nameof(GetXRechnung));
|
||||||
}
|
}
|
||||||
catch (Exception ex2)
|
catch (Exception ex2)
|
||||||
{
|
{
|
||||||
response.ErrorStrings.Add("AccountingEnhancedServiceImp: " + ex2.ToString());
|
response.ErrorStrings.Add("AccountingEnhancedServiceImp - CoreLogger: " + ex2.ToString());
|
||||||
}
|
}
|
||||||
response.ErrorStrings.Add("AccountingEnhancedServiceImp: " + ex.ToString());
|
response.ErrorStrings.Add("AccountingEnhancedServiceImp: " + ex.ToString());
|
||||||
}
|
}
|
||||||
@@ -96,15 +109,11 @@ namespace BeWo.Service.Plugins
|
|||||||
private string GetTokenUrl(string report_url)
|
private string GetTokenUrl(string report_url)
|
||||||
{
|
{
|
||||||
string download_url;
|
string download_url;
|
||||||
|
|
||||||
if (report_url.IndexOf("localhost") < 0)
|
if (report_url.IndexOf("localhost") < 0)
|
||||||
download_url = report_url + "&mode=pdf";
|
download_url = report_url + "&mode=pdf";
|
||||||
else
|
else
|
||||||
download_url = "https://app5.bewoplaner.de/service/ApiStreamService.svc/GetPdf";
|
download_url = "https://app5.bewoplaner.de/service/ApiStreamService.svc/GetPdf";
|
||||||
|
return new DownloadServiceImp().CreateTemporaryUrl(download_url, false);
|
||||||
var token_url = new DownloadServiceImp().CreateTemporaryUrl(download_url, false);
|
|
||||||
|
|
||||||
return token_url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -112,21 +121,95 @@ namespace BeWo.Service.Plugins
|
|||||||
{
|
{
|
||||||
bytes = null;
|
bytes = null;
|
||||||
|
|
||||||
|
// Hole StoredFile aus DB
|
||||||
var lFile = pStorage.GetStoredFile(BWPFeature.XRechnung, pFileName);
|
var lFile = pStorage.GetStoredFile(BWPFeature.XRechnung, pFileName);
|
||||||
|
|
||||||
if (lFile is null)
|
if (lFile is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
using (Stream file_stream = pStorage.GetFileContent(lFile))
|
using (Stream file_stream = pStorage.GetFileContent(lFile))
|
||||||
{
|
{
|
||||||
|
if (file_stream is null) return false;
|
||||||
|
|
||||||
using (MemoryStream ms = new MemoryStream())
|
using (MemoryStream ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
file_stream.CopyTo(ms);
|
file_stream.CopyTo(ms);
|
||||||
bytes = ms.ToArray();
|
bytes = ms.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string calculate(InvoiceBase invoice)
|
||||||
|
{
|
||||||
|
var undefinded = "??undefinded??";
|
||||||
|
var undefinded_num = -1;
|
||||||
|
var undefinded_num2 = 1001;
|
||||||
|
var undefinded_num3 = 58;
|
||||||
|
|
||||||
|
XRechnung xRechnung = new XRechnung();
|
||||||
|
|
||||||
|
xRechnung.Invoice.Type = (invoice.InvoiceTypeText?.StartsWith("storno", StringComparison.OrdinalIgnoreCase) ?? false) ? "384" : "380";
|
||||||
|
xRechnung.Invoice.Number = invoice.InvoiceNumber;
|
||||||
|
xRechnung.Invoice.Date = invoice.InvoiceDate?.ToString("yyyyMMdd") ?? undefinded;
|
||||||
|
xRechnung.Invoice.Currency = "EUR";
|
||||||
|
xRechnung.Invoice.Notice = undefinded;
|
||||||
|
xRechnung.Invoice.Period.Start = invoice.AccountingPeriodStart?.ToString("yyyyMMdd") ?? undefinded;
|
||||||
|
xRechnung.Invoice.Period.End = invoice.AccountingPeriodEnd?.ToString("yyyyMMdd") ?? undefinded;
|
||||||
|
xRechnung.Invoice.Period.Description = undefinded;
|
||||||
|
xRechnung.Invoice.Payment.Type = undefinded_num;
|
||||||
|
xRechnung.Invoice.Payment.Type = undefinded_num3;
|
||||||
|
xRechnung.Invoice.Payment.Term = undefinded;
|
||||||
|
xRechnung.Invoice.Payment.DueDate = undefinded;
|
||||||
|
|
||||||
|
xRechnung.Seller.Name = undefinded;
|
||||||
|
xRechnung.Seller.ID = undefinded;
|
||||||
|
xRechnung.Seller.TaxID = undefinded;
|
||||||
|
xRechnung.Seller.VatID = undefinded;
|
||||||
|
xRechnung.Seller.Street = undefinded;
|
||||||
|
xRechnung.Seller.ZipCode = undefinded;
|
||||||
|
xRechnung.Seller.City = undefinded;
|
||||||
|
xRechnung.Seller.EMail = undefinded;
|
||||||
|
xRechnung.Seller.CountryCode = "DE";
|
||||||
|
xRechnung.Seller.Contact.Name = undefinded;
|
||||||
|
xRechnung.Seller.Contact.Department = undefinded;
|
||||||
|
xRechnung.Seller.Contact.Phone = undefinded;
|
||||||
|
xRechnung.Seller.Contact.EMail = undefinded;
|
||||||
|
xRechnung.Seller.BankAccount.IBAN = undefinded;
|
||||||
|
xRechnung.Seller.BankAccount.BIC = undefinded;
|
||||||
|
xRechnung.Seller.BankAccount.Owner = undefinded;
|
||||||
|
xRechnung.Seller.BankAccount.Reference = undefinded;
|
||||||
|
xRechnung.Seller.BankAccount.ReferenceID = undefinded;
|
||||||
|
|
||||||
|
xRechnung.Buyer.Name = undefinded;
|
||||||
|
xRechnung.Buyer.ID = undefinded;
|
||||||
|
xRechnung.Buyer.Street = undefinded;
|
||||||
|
xRechnung.Buyer.ZipCode = undefinded;
|
||||||
|
xRechnung.Buyer.City = undefinded;
|
||||||
|
xRechnung.Buyer.EMail = undefinded;
|
||||||
|
xRechnung.Buyer.CountryCode = undefinded;
|
||||||
|
xRechnung.Buyer.Reference = undefinded;
|
||||||
|
xRechnung.Buyer.BankAccount.IBAN = undefinded;
|
||||||
|
xRechnung.Buyer.BankAccount.BIC = undefinded;
|
||||||
|
xRechnung.Buyer.BankAccount.Owner = undefinded;
|
||||||
|
xRechnung.Buyer.BankAccount.MandateID = undefinded;
|
||||||
|
|
||||||
|
foreach (var item in invoice.GetInvoiceItems())
|
||||||
|
{
|
||||||
|
var position = new XRPosition();
|
||||||
|
|
||||||
|
position.Quantity = undefinded_num;
|
||||||
|
position.QuantityType = undefinded;
|
||||||
|
position.Text = undefinded;
|
||||||
|
position.Net = undefinded_num;
|
||||||
|
position.NetTotal = undefinded_num;
|
||||||
|
position.Tax = undefinded_num2;
|
||||||
|
position.TaxSum = undefinded_num2;
|
||||||
|
position.TaxType = undefinded;
|
||||||
|
|
||||||
|
xRechnung.Position.Add(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(xRechnung);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,9 +130,14 @@ namespace BS.Shared.Core
|
|||||||
public static string ShowServicesOverviewHalfOrWholeMonth => "ShowServicesOverviewHalfOrWholeMonth";
|
public static string ShowServicesOverviewHalfOrWholeMonth => "ShowServicesOverviewHalfOrWholeMonth";
|
||||||
public static string OpenReportInNewWindow => "OpenReportInNewWindow";
|
public static string OpenReportInNewWindow => "OpenReportInNewWindow";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Aktiviert AI Module
|
||||||
|
/// </summary>
|
||||||
|
public const string ModuleAiEnabled = "ModuleAiEnabled";
|
||||||
|
|
||||||
// Module Ai
|
/// <summary>
|
||||||
public static string ModuleAiEnabled => "ModuleAiEnabled";
|
/// Aktiviert AI Einstellungen (Modell, ...)
|
||||||
public static string ModuleAiSettingsEnabled => "ModuleAiSettingsEnabled";
|
/// </summary>
|
||||||
|
public const string ModuleAiSettingsEnabled = "ModuleAiSettingsEnabled";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ namespace BS.Shared.DataContracts.MikePHPContracts
|
|||||||
{
|
{
|
||||||
public T Data { get; set; }
|
public T Data { get; set; }
|
||||||
|
|
||||||
public List<AppError> Errors { get; set; }
|
public List<AppError> Errors { get; set; } = new List<AppError>();
|
||||||
|
|
||||||
public List<string> ErrorStrings { get; set; }
|
public List<string> ErrorStrings { get; set; } = new List<string>();
|
||||||
|
|
||||||
public List<string> Messages { get; set; }
|
public List<string> Messages { get; set; } = new List<string>();
|
||||||
|
|
||||||
public Dictionary<string, object> Meta { get; set; }
|
public Dictionary<string, object> Meta { get; set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user