Files
BeWoPlaner/ReportImp/VKMAachen/Invoicing/CustomInvoiceNumberGenerator.cs
2021-02-21 19:01:51 +01:00

84 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Invoicing;
using BeWo.Service.Plugins;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.Services;
namespace VKMAachen.Invoicing
{
internal class CustomInvoiceNumberGenerator : InvoiceNumberGenerator
{
public override string GetNextInvoiceNumber(int increment, InvoiceBase invoiceBase)
{
string next = base.GetNextInvoiceNumber(increment, invoiceBase);
String debNummer = "";
if (invoiceBase.CostBearer2SupportConcept != null)
{
debNummer = invoiceBase.CostBearer2SupportConcept.SupportConcept.Customer.DebitorNumber;
}
next = next.Replace("{d}", debNummer);
return next;
}
public override string GetNextInvoiceNumber(int increment, string id)
{
return base.GetNextInvoiceNumber(increment, id);
}
public override string GetNextInvoiceNumber(int increment, Settlement2DC settlementInvoice)
{
return base.GetNextInvoiceNumber(increment, settlementInvoice);
}
protected override String ApplyPatternWithId(String pattern, long number, String id)
{
string next = pattern;
if (!String.IsNullOrEmpty(next))
{
int pos = next.IndexOf("{n");
if (pos >= 0)
{
int stop = next.IndexOf("}", pos);
if (stop > pos)
{
int nCount = stop - pos - 1;
String nextNumberStr = number.ToString();
while (nextNumberStr.Length < nCount)
nextNumberStr = "0" + nextNumberStr;
next = next.Replace(next.Substring(pos, stop - pos + 1), nextNumberStr);
}
}
DateTime dt = DateTime.Now.Date.AddMonths(-1);
next = next.Replace("{jj}", String.Format("{0:yy}", dt));
next = next.Replace("{jjjj}", String.Format("{0:yyyy}", dt));
next = next.Replace("{MM}", String.Format("{0:MM}", dt));
next = next.Replace("{mm}", String.Format("{0:MM}", dt));
}
return next;
}
}
}