DifferenzRechnung in Sammelrechnung
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
HorizontalAlignment="Stretch" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:r="clr-namespace:BeWo.Security"
|
||||
VerticalAlignment="Stretch" Focusable="True"
|
||||
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">
|
||||
<GroupBox Width="850" Style="{StaticResource PopUpWindowStyle}">
|
||||
<GroupBox Width="1100" Style="{StaticResource PopUpWindowStyle}">
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,0,0">
|
||||
<Image Source="..\..\Ressources\Icons\CoinsDisabled.png" Height="28" />
|
||||
@@ -22,6 +22,10 @@
|
||||
<Grid Background="{StaticResource ObjectEditBackgroundBrush}">
|
||||
<GroupBox Margin="10" Header="Rechnung(en) erstellen" Style="{StaticResource ObjectEditGroupBox}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
@@ -34,7 +38,9 @@
|
||||
<AccessText Margin="2">Klicken Sie anschließend auf "Erstellen".</AccessText>
|
||||
</StackPanel>
|
||||
</Label>
|
||||
<dxg:GridControl x:Name="grid_newInvoices" Margin="3" Grid.Row="1" MinHeight="200">
|
||||
<TextBlock x:Name="txtWarnhinweis" Foreground="Red" Grid.Column="1" ></TextBlock>
|
||||
|
||||
<dxg:GridControl x:Name="grid_newInvoices" Margin="3" Grid.Row="1" Grid.ColumnSpan="2" MinHeight="200">
|
||||
<dxg:GridControl.Columns>
|
||||
<dxg:GridColumn FieldName="Notice" Header="" FixedWidth="True" Width="24" ReadOnly="True">
|
||||
<dxg:GridColumn.CellTemplate>
|
||||
@@ -52,12 +58,16 @@
|
||||
<dxe:TextEditSettings DisplayFormat="c" Mask="c" MaskType="Numeric"></dxe:TextEditSettings>
|
||||
</dxg:GridColumn.EditSettings>
|
||||
</dxg:GridColumn>
|
||||
<dxg:GridColumn FieldName="InvoiceBase.Details" Header="Details"></dxg:GridColumn>
|
||||
<dxg:GridColumn FieldName="InvoiceBase.NeuErstellen" Header="Neu erstellen" ></dxg:GridColumn>
|
||||
<dxg:GridColumn FieldName="InvoiceBase.DiffErstellen" Header="{markup:Translate Diff.-Rg erstellen}"></dxg:GridColumn>
|
||||
<dxg:GridColumn FieldName="InvoiceBase.Hinweise" Header="Hinweise"></dxg:GridColumn>
|
||||
</dxg:GridControl.Columns>
|
||||
<dxg:GridControl.View>
|
||||
<dxg:TableView ShowGroupPanel="False" />
|
||||
<dxg:TableView ShowGroupPanel="False" CellValueChanging="TableView_CellValueChanging"/>
|
||||
</dxg:GridControl.View>
|
||||
</dxg:GridControl>
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Row="2">
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="2">
|
||||
<Button Content="Erstellen" x:Name="btn_create" Click="btn_create_Click" Padding="5 0" Margin="3" />
|
||||
<Button Content="Abbrechen" x:Name="btn_cancel" Click="btn_cancel_Click" Margin="3" Padding="5 0" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Windows.Input;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
using BS.Shared.Translation;
|
||||
using DevExpress.Xpf.Grid;
|
||||
|
||||
namespace BeWo.View.Detail.Accounting
|
||||
@@ -42,6 +42,16 @@ namespace BeWo.View.Detail.Accounting
|
||||
this._InvoiceNumbers = value.Select(i => i.InvoiceBase.InvoiceNumber).ToList();
|
||||
this._Dcs = new BindingList<ServiceInvoiceDC>(value);
|
||||
this.grid_newInvoices.ItemsSource = this._Dcs;
|
||||
|
||||
SetzeWarnhinweis();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetzeWarnhinweis()
|
||||
{
|
||||
if (_Dcs.Any(s => s.InvoiceBase.DiffErstellen))
|
||||
{
|
||||
txtWarnhinweis.Text = Translator.Translate("Es wurden bereits Rechnungen im gewählten Zeitraum erstellt.\nWenn Sie keine Differenzrechnungen erstellen möchten,\nentfernen Sie bitte die entsprechenden Häkchen.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,5 +83,26 @@ namespace BeWo.View.Detail.Accounting
|
||||
{
|
||||
this._Dcs.Remove(this.grid_newInvoices.GetCurrentValue<ServiceInvoiceDC>());
|
||||
}
|
||||
|
||||
private void TableView_CellValueChanging(object sender, CellValueChangedEventArgs e)
|
||||
{
|
||||
var si = e.Row as ServiceInvoiceDC;
|
||||
if (e.Column.FieldName.Contains("NeuErstellen") && ((bool)e.Value))
|
||||
{
|
||||
if (si.InvoiceBase.DiffErstellen)
|
||||
{
|
||||
si.InvoiceBase.DiffErstellen = false;
|
||||
grid_newInvoices.RefreshData();
|
||||
}
|
||||
}
|
||||
else if (e.Column.FieldName.Contains("DiffErstellen") && ((bool)e.Value))
|
||||
{
|
||||
if (si.InvoiceBase.NeuErstellen)
|
||||
{
|
||||
si.InvoiceBase.NeuErstellen = false;
|
||||
grid_newInvoices.RefreshData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,10 @@ namespace BeWo.ViewModel
|
||||
|
||||
public static string PropertyName_InvoiceTitle = "InvoiceTitle";
|
||||
|
||||
public static string PropertyName_NeuErstellen = "NeuErstellen";
|
||||
|
||||
public static string PropertyName_DiffErstellen = "DiffErstellen";
|
||||
|
||||
public static string PropertyName_IsPaid = "IsPaid";
|
||||
|
||||
public static string PropertyName_Notice = "Notice";
|
||||
@@ -128,6 +132,10 @@ namespace BeWo.ViewModel
|
||||
private string _InvoiceTitle = string.Empty;
|
||||
internal bool _IsPaid;
|
||||
|
||||
internal bool _NeuErstellen;
|
||||
|
||||
internal bool _DiffErstellen;
|
||||
|
||||
internal bool _IsChecked;
|
||||
|
||||
private string _Notice = string.Empty;
|
||||
@@ -406,6 +414,50 @@ namespace BeWo.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public string Details
|
||||
{
|
||||
get { return DataContract.Details ; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string Hinweise
|
||||
{
|
||||
get { return DataContract.Hinweise; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public bool NeuErstellen
|
||||
{
|
||||
get { return _NeuErstellen; }
|
||||
|
||||
set
|
||||
{
|
||||
if (AreDifferent(_NeuErstellen, value))
|
||||
{
|
||||
_NeuErstellen = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.NeuErstellen, value), PropertyName_NeuErstellen);
|
||||
FirePropertyChanged(PropertyName_NeuErstellen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool DiffErstellen
|
||||
{
|
||||
get { return _DiffErstellen; }
|
||||
|
||||
set
|
||||
{
|
||||
if (AreDifferent(_DiffErstellen, value))
|
||||
{
|
||||
_DiffErstellen = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.DiffErstellen, value), PropertyName_DiffErstellen);
|
||||
FirePropertyChanged(PropertyName_DiffErstellen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPaid
|
||||
{
|
||||
get { return _IsPaid; }
|
||||
@@ -847,10 +899,12 @@ namespace BeWo.ViewModel
|
||||
_RecipientCustomerOid = pDataContract.RecipientCustomerOid;
|
||||
_RecipientCostBearerOid = pDataContract.RecipientCostBearerOid;
|
||||
_RecipientStreet = pDataContract.RecipientStreet;
|
||||
_RecipientAddressLine1 = pDataContract.RecipientAddressLine1;
|
||||
_RecipientAddressLine1 = pDataContract.RecipientAddressLine1;
|
||||
_RecipientTown = pDataContract.RecipientTown;
|
||||
_RecipientPostCode = pDataContract.RecipientPostCode;
|
||||
_IsPaid = pDataContract.IsPaid;
|
||||
_NeuErstellen = pDataContract.NeuErstellen;
|
||||
_DiffErstellen = pDataContract.DiffErstellen;
|
||||
_InvoiceTitle = pDataContract.InvoiceTitle;
|
||||
_InvoiceNumber = pDataContract.InvoiceNumber;
|
||||
_InvoiceDate = pDataContract.InvoiceDate;
|
||||
@@ -862,8 +916,8 @@ namespace BeWo.ViewModel
|
||||
_Notice = pDataContract.Notice;
|
||||
_DunningLetterCount = pDataContract.DunningLetterCount;
|
||||
_TotalAmount = pDataContract.TotalAmount;
|
||||
_CustomerReferenceNumber = pDataContract.CustomerReferenceNumber;
|
||||
BackgroundColor = pDataContract.BackgroundColor;
|
||||
_CustomerReferenceNumber = pDataContract.CustomerReferenceNumber;
|
||||
BackgroundColor = pDataContract.BackgroundColor;
|
||||
|
||||
foreach (var iContactDC in pDataContract.SenderContactInformations)
|
||||
{
|
||||
@@ -906,9 +960,11 @@ namespace BeWo.ViewModel
|
||||
pDataContract.RecipientCostBearerOid = _RecipientCostBearerOid;
|
||||
pDataContract.RecipientPostCode = _RecipientPostCode;
|
||||
pDataContract.RecipientStreet = _RecipientStreet;
|
||||
pDataContract.RecipientAddressLine1 = _RecipientAddressLine1;
|
||||
pDataContract.RecipientAddressLine1 = _RecipientAddressLine1;
|
||||
pDataContract.RecipientTown = _RecipientTown;
|
||||
pDataContract.IsPaid = _IsPaid;
|
||||
pDataContract.NeuErstellen = _NeuErstellen;
|
||||
pDataContract.DiffErstellen = _DiffErstellen;
|
||||
pDataContract.InvoiceTitle = _InvoiceTitle;
|
||||
pDataContract.InvoiceNumber = _InvoiceNumber;
|
||||
pDataContract.InvoiceDate = _InvoiceDate;
|
||||
@@ -920,7 +976,7 @@ namespace BeWo.ViewModel
|
||||
pDataContract.Notice = _Notice;
|
||||
pDataContract.DunningLetterCount = _DunningLetterCount;
|
||||
pDataContract.TotalAmount = _TotalAmount;
|
||||
pDataContract.CustomerReferenceNumber = _CustomerReferenceNumber;
|
||||
pDataContract.CustomerReferenceNumber = _CustomerReferenceNumber;
|
||||
|
||||
CommitSenderContact(_SenderFax, ContactType.business_Fax);
|
||||
CommitSenderContact(_SenderPhone, ContactType.business_Phone);
|
||||
|
||||
@@ -6,17 +6,178 @@ using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.Core;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.Invoicing;
|
||||
using BeWo.Service.ServiceContracts;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
namespace BeWo.Service.Plugins
|
||||
{
|
||||
public class AccountingService : AbstractIDSpecificDefaultClass<AccountingService>
|
||||
{
|
||||
public virtual List<long> UpdateServiceInvoices(List<ServiceInvoiceDC> invoices)
|
||||
public virtual 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.EndDate && 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;
|
||||
}
|
||||
|
||||
protected virtual List<ServiceInvoiceDC> ErstelleNeueRechnungen(List<DifferenzRechnungCheck> differenzRechnungChecks)
|
||||
{
|
||||
var rechnungen = new List<ServiceInvoiceDC>();
|
||||
foreach (var item in differenzRechnungChecks)
|
||||
{
|
||||
if (item.VorhandeneRechungen.Count == 0)
|
||||
{
|
||||
item.NeueRechnung.InvoiceBase.NeuErstellen = true;
|
||||
rechnungen.Add(item.NeueRechnung);
|
||||
}
|
||||
else
|
||||
{
|
||||
rechnungen.Add(ErstelleDifferenzRechnung(item));
|
||||
}
|
||||
}
|
||||
|
||||
return rechnungen;
|
||||
}
|
||||
|
||||
protected virtual ServiceInvoiceDC ErstelleDifferenzRechnung(DifferenzRechnungCheck item)
|
||||
{
|
||||
ServiceInvoiceDC diffRechnung = null;
|
||||
var alterBetrag = item.VorhandeneRechungen.Sum(i => i.ClaimSum ?? 0);
|
||||
|
||||
if (item.NeueRechnung.ClaimSum == alterBetrag)
|
||||
{
|
||||
diffRechnung = item.NeueRechnung;
|
||||
diffRechnung.InvoiceBase.NeuErstellen = false;
|
||||
diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnung wurde bereits erstellt");
|
||||
}
|
||||
else
|
||||
{
|
||||
diffRechnung = new ServiceInvoiceDC();
|
||||
diffRechnung.OriginalZurDifferenz = item.NeueRechnung;
|
||||
diffRechnung.InvoiceBase = new InvoiceBaseDC();
|
||||
CopyInvoiceBaseDC(item.NeueRechnung.InvoiceBase, diffRechnung);
|
||||
|
||||
var newItem = new InvoiceItemDC();
|
||||
newItem.ItemPeriodStart = item.NeueRechnung.InvoiceBase.AccountingPeriodStart;
|
||||
newItem.ItemPeriodEnd = item.NeueRechnung.InvoiceBase.AccountingPeriodEnd;
|
||||
newItem.UnitCount = 1;
|
||||
newItem.AmountPerUnit = item.NeueRechnung.ClaimSum - alterBetrag;
|
||||
newItem.AmountTotal = newItem.AmountPerUnit;
|
||||
newItem.GrossAmountTotal = newItem.AmountTotal;
|
||||
newItem.ItemDescription = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber, alterBetrag);
|
||||
diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber, alterBetrag);
|
||||
|
||||
var newSip = new ServiceInvoicePeriodDC();
|
||||
newSip.Claim = newItem.AmountTotal;
|
||||
newSip.Start = item.NeueRechnung.InvoiceBase.AccountingPeriodStart;
|
||||
newSip.End = item.NeueRechnung.InvoiceBase.AccountingPeriodEnd;
|
||||
diffRechnung.ServiceInvoicePeriods = new List<ServiceInvoicePeriodDC>();
|
||||
diffRechnung.ServiceInvoicePeriods.Add(newSip);
|
||||
newSip.InvoiceItems = new List<InvoiceItemDC>();
|
||||
newSip.InvoiceItems.Add(newItem);
|
||||
}
|
||||
return diffRechnung;
|
||||
}
|
||||
|
||||
protected virtual List<DifferenzRechnungCheck> GetNewInvoices(List<ServiceInvoiceDC> invoices, DateTime start, DateTime end)
|
||||
{
|
||||
List<DifferenzRechnungCheck> result = new List<DifferenzRechnungCheck>();
|
||||
var existingInvoices = DAOFactory.SearchDAO.GetInvoiceBases(start, end, false);
|
||||
|
||||
foreach (var si in invoices)
|
||||
{
|
||||
var checkResult = new DifferenzRechnungCheck();
|
||||
result.Add(checkResult);
|
||||
checkResult.NeueRechnung = si;
|
||||
checkResult.VorhandeneRechungen = new List<ServiceInvoiceDC>();
|
||||
|
||||
foreach (var i2 in existingInvoices.Where(i => i.Type == InvoiceType.Service))
|
||||
{
|
||||
if (si.InvoiceBase.SupportConceptCostBearerRelDc != null && si.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer2SupportConceptOid == i2.CostBearer2SupportConceptOid)
|
||||
{
|
||||
var siAlt = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(i2.Oid.Value);
|
||||
var siDCAlt = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(siAlt);
|
||||
|
||||
//InvoiceItems vergleichen?
|
||||
//foreach (var sip in si.ServiceInvoicePeriods)
|
||||
//{
|
||||
// foreach (var ii in sip.InvoiceItems)
|
||||
// {
|
||||
// typNeu = ii.ItemDescription;
|
||||
// }
|
||||
//}
|
||||
|
||||
//foreach (var sip in siAlt.ServiceInvoicePeriodList)
|
||||
//{
|
||||
// foreach (var ii in sip.InvoiceItemList)
|
||||
// {
|
||||
// typAlt = ii.ItemDescription;
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (typAlt == typNeu)
|
||||
//{
|
||||
// exist = true;
|
||||
//}
|
||||
|
||||
checkResult.VorhandeneRechungen.Add(siDCAlt);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual List<long> UpdateServiceInvoices(List<ServiceInvoiceDC> invoices)
|
||||
{
|
||||
//if (!Data.Security.UserRightHelper.LoggedInUserHasRight(UserRightType.AccountingTransactionView_Create))
|
||||
//{
|
||||
@@ -79,9 +240,6 @@ namespace BeWo.Service.Plugins
|
||||
{
|
||||
ErstelleStornoAllgemeineRechnung(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +358,7 @@ namespace BeWo.Service.Plugins
|
||||
CopyServiceInvoicePeriod(sip, copySip);
|
||||
}
|
||||
}
|
||||
|
||||
//private void CopySettlementInvoice(SettlementInvoice existingInvoice, SettlementInvoice copyInvoice)
|
||||
// {
|
||||
|
||||
@@ -280,7 +439,53 @@ namespace BeWo.Service.Plugins
|
||||
|
||||
}
|
||||
|
||||
private Contact CreateCopyContact(Contact existingContact)
|
||||
public void CopyInvoiceBaseDC(InvoiceBaseDC orgRechnung, ServiceInvoiceDC diffRechnung)
|
||||
{
|
||||
diffRechnung.InvoiceBase.DiffErstellen = true;
|
||||
diffRechnung.InvoiceBase.AccountingPeriodStart = orgRechnung.AccountingPeriodStart;
|
||||
diffRechnung.InvoiceBase.AccountingPeriodEnd = orgRechnung.AccountingPeriodEnd;
|
||||
diffRechnung.InvoiceBase.CustomerLastName = orgRechnung.CustomerLastName;
|
||||
diffRechnung.InvoiceBase.CustomerFirstName = orgRechnung.CustomerFirstName;
|
||||
diffRechnung.InvoiceBase.CustomerReferenceNumber = orgRechnung.CustomerReferenceNumber;
|
||||
diffRechnung.InvoiceBase.InvoiceBaseOid = orgRechnung.InvoiceBaseOid;
|
||||
diffRechnung.InvoiceBase.InvoiceDate = orgRechnung.InvoiceDate;
|
||||
diffRechnung.InvoiceBase.InvoiceId = orgRechnung.InvoiceId;
|
||||
diffRechnung.InvoiceBase.InvoiceNumber = orgRechnung.InvoiceNumber;
|
||||
diffRechnung.InvoiceBase.InvoiceTitle = orgRechnung.InvoiceTitle;
|
||||
diffRechnung.InvoiceBase.InvoiceTypeText = orgRechnung.InvoiceTypeText;
|
||||
diffRechnung.InvoiceBase.RecipientAddressLine1 = orgRechnung.RecipientAddressLine1;
|
||||
diffRechnung.InvoiceBase.RecipientAddressOid = orgRechnung.RecipientAddressOid;
|
||||
diffRechnung.InvoiceBase.RecipientAddressVersion = orgRechnung.RecipientAddressVersion;
|
||||
diffRechnung.InvoiceBase.RecipientContactInformations = orgRechnung.RecipientContactInformations;
|
||||
diffRechnung.InvoiceBase.RecipientCostBearerOid = orgRechnung.RecipientCostBearerOid;
|
||||
diffRechnung.InvoiceBase.RecipientCustomerOid = orgRechnung.RecipientCustomerOid;
|
||||
diffRechnung.InvoiceBase.RecipientDivision = orgRechnung.RecipientDivision;
|
||||
diffRechnung.InvoiceBase.RecipientOrganisation = orgRechnung.RecipientOrganisation;
|
||||
diffRechnung.InvoiceBase.RecipientOrganisationOid = orgRechnung.RecipientOrganisationOid;
|
||||
diffRechnung.InvoiceBase.RecipientPersonFirstName = orgRechnung.RecipientPersonFirstName;
|
||||
diffRechnung.InvoiceBase.RecipientPersonLastName = orgRechnung.RecipientPersonLastName;
|
||||
diffRechnung.InvoiceBase.RecipientPersonOid = orgRechnung.RecipientPersonOid;
|
||||
diffRechnung.InvoiceBase.RecipientPostCode = orgRechnung.RecipientPostCode;
|
||||
diffRechnung.InvoiceBase.RecipientSalutationAddressField = orgRechnung.RecipientSalutationAddressField;
|
||||
diffRechnung.InvoiceBase.RecipientStreet = orgRechnung.RecipientStreet;
|
||||
diffRechnung.InvoiceBase.RecipientTown = orgRechnung.RecipientTown;
|
||||
diffRechnung.InvoiceBase.SenderAddressOid = orgRechnung.SenderAddressOid;
|
||||
diffRechnung.InvoiceBase.SenderAddressVersion = orgRechnung.SenderAddressVersion;
|
||||
diffRechnung.InvoiceBase.SenderContactInformations = orgRechnung.SenderContactInformations;
|
||||
diffRechnung.InvoiceBase.SenderDivision = orgRechnung.SenderDivision;
|
||||
diffRechnung.InvoiceBase.SenderFirstName = orgRechnung.SenderFirstName;
|
||||
diffRechnung.InvoiceBase.SenderLastName = orgRechnung.SenderLastName;
|
||||
diffRechnung.InvoiceBase.SenderOrganisation = orgRechnung.SenderOrganisation;
|
||||
diffRechnung.InvoiceBase.SenderPostCode = orgRechnung.SenderPostCode;
|
||||
diffRechnung.InvoiceBase.SenderStreet = orgRechnung.SenderStreet;
|
||||
diffRechnung.InvoiceBase.SenderTown = orgRechnung.SenderTown;
|
||||
diffRechnung.InvoiceBase.SupportConceptCostBearerRelDc = orgRechnung.SupportConceptCostBearerRelDc;
|
||||
diffRechnung.InvoiceBase.SupportConceptOid = orgRechnung.SupportConceptOid;
|
||||
diffRechnung.InvoiceBase.TotalAmount = orgRechnung.TotalAmount;
|
||||
diffRechnung.InvoiceBase.Type = orgRechnung.Type;
|
||||
}
|
||||
|
||||
private Contact CreateCopyContact(Contact existingContact)
|
||||
{
|
||||
Contact newContact = new Contact();
|
||||
newContact.Value = existingContact.Value;
|
||||
@@ -317,7 +522,6 @@ namespace BeWo.Service.Plugins
|
||||
copySip.ServiceUnitName = existingSip.ServiceUnitName;
|
||||
copySip.Start = existingSip.Start;
|
||||
copySip.Notice = existingSip.Notice;
|
||||
|
||||
copySip.Customer = existingSip.Customer;
|
||||
copySip.SupportConceptApprovalPeriod = existingSip.SupportConceptApprovalPeriod;
|
||||
|
||||
@@ -350,8 +554,13 @@ namespace BeWo.Service.Plugins
|
||||
copyItem.UnitCount = existingItem.UnitCount;
|
||||
copyItem.UnitDescription = existingItem.UnitDescription;
|
||||
copyItem.Notice = existingItem.Notice;
|
||||
|
||||
copyItem.ServiceRecord = existingItem.ServiceRecord;
|
||||
}
|
||||
}
|
||||
|
||||
public class DifferenzRechnungCheck
|
||||
{
|
||||
public ServiceInvoiceDC NeueRechnung { get; set; }
|
||||
public IList<ServiceInvoiceDC> VorhandeneRechungen { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -87,60 +87,9 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
try
|
||||
{
|
||||
var operationService = new OperationsServiceImp();
|
||||
var acc = PluginLoader.FindClass<AccountingService>();
|
||||
return acc.GenerateInitialServiceInvoices(costBearerOid, supportConceptOid, invoicePeriod);
|
||||
|
||||
IEnumerable<CompactSupportConceptDC> supportConcepts;
|
||||
// GetAllActiveSupportConceptCostbearer returns a "Flat" SupportConcept List, one for each CostBearer2SupportConcept!
|
||||
if (!supportConceptOid.HasValue)
|
||||
{
|
||||
supportConcepts = operationService.GetAllActiveSupportConceptCostbearer(false, true, 0)
|
||||
.Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid));
|
||||
}
|
||||
else
|
||||
{
|
||||
supportConcepts = operationService.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.EndDate && 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 = null;
|
||||
|
||||
if (MultitenancyOperationContextExt.Current != null)
|
||||
tenant = MultitenancyOperationContextExt.Current.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);
|
||||
|
||||
//String text = String.Format("Tenant={0}, Context=Null? {1}, Factory = {2}", tenant,
|
||||
// MultitenancyOperationContextExt.Current == null, factory);
|
||||
|
||||
//Utils.SendErrorMail("CB DEBUG", text);
|
||||
|
||||
return creator.GenerateServiceInvoices(costBearerOid, invoicePeriod, supportConcepts2ServiceRecords);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -434,7 +383,25 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
try
|
||||
{
|
||||
var newInvoices = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewEntities(invoices);
|
||||
//Prüfe Flags
|
||||
var neueRechnungen = new List<ServiceInvoiceDC>();
|
||||
var diffRechnungen = invoices.Where(i => i.InvoiceBase.DiffErstellen).ToList();
|
||||
|
||||
//Bei neuer Rechung prüfen, ob eine Diff Rechnung vorher generiert wurde.
|
||||
foreach (var item in invoices.Where(i => i.InvoiceBase.NeuErstellen))
|
||||
{
|
||||
if (item.OriginalZurDifferenz != null)
|
||||
{
|
||||
neueRechnungen.Add(item.OriginalZurDifferenz);
|
||||
}
|
||||
else
|
||||
{
|
||||
neueRechnungen.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
var newInvoices = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewEntities(neueRechnungen);
|
||||
newInvoices.AddRange(MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewEntities(diffRechnungen));
|
||||
if (newInvoices.Count > 0)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
@@ -61,10 +61,22 @@ namespace BS.Shared.DataContracts
|
||||
[DataMember]
|
||||
public bool IsPaid { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public bool NeuErstellen { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public bool DiffErstellen { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Notice { get; set; }
|
||||
|
||||
[DataMember]
|
||||
[DataMember]
|
||||
public string Details { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Hinweise { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string InvoiceId { get; set; }
|
||||
|
||||
[DataMember]
|
||||
|
||||
@@ -77,6 +77,9 @@ namespace BS.Shared.DataContracts
|
||||
[DataMember]
|
||||
public CostRatePeriodDC ServiceUnit { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public ServiceInvoiceDC OriginalZurDifferenz { get; set; }
|
||||
|
||||
public decimal? ClaimSum
|
||||
{
|
||||
get { return ServiceInvoicePeriods.Sum(i => i.Claim); }
|
||||
|
||||
Reference in New Issue
Block a user