73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using BeWo.Data.Entities;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Services;
|
|
|
|
namespace PraxisPusteblume.Invoicing
|
|
{
|
|
public class InvoiceHelper
|
|
{
|
|
|
|
public static void InitInvoiceItem(InvoiceItem ii)
|
|
{
|
|
//if (iServiceRecord.ServiceDescription.Name == "")
|
|
ii.ItemDescription = "Einzelbetreuung";
|
|
if (ii.RateFactor.HasValue && ii.UnitCount.HasValue)
|
|
{
|
|
if (ii.RateFactor == 33.33m)
|
|
{
|
|
ii.RateFactor = 100m / 3m;
|
|
}
|
|
ii.UnitCount = ii.UnitCount.Value * ((100 + ii.RateFactor.Value) / 100);
|
|
|
|
ii.GrossAmountTotal = ii.UnitCount * (ii.AmountPerUnit ?? 0);
|
|
}
|
|
|
|
}
|
|
|
|
public static String GetUnitString(decimal? unitCount)
|
|
{
|
|
if (!unitCount.HasValue)
|
|
return "0";
|
|
|
|
if (unitCount.Value != Math.Floor(unitCount.Value))
|
|
{
|
|
var floor = Math.Floor(unitCount.Value);
|
|
var rest = unitCount.Value - floor;
|
|
|
|
if (Math.Round(rest, 2, MidpointRounding.AwayFromZero) == 0.33m)
|
|
{
|
|
if (floor == 0)
|
|
{
|
|
return "1/3";
|
|
}
|
|
|
|
return String.Format("{0:0} 1/3", floor);
|
|
}
|
|
if (Math.Round(rest, 2, MidpointRounding.AwayFromZero) == 0.67m)
|
|
{
|
|
if (floor == 0)
|
|
{
|
|
return "2/3";
|
|
}
|
|
return String.Format("{0:0} 2/3", floor);
|
|
}
|
|
}
|
|
return String.Format("{0:0.##}", unitCount);
|
|
}
|
|
|
|
public static int GetKW(DateTime actualDate)
|
|
{
|
|
Calendar objCal = CultureInfo.CurrentCulture.Calendar;
|
|
int weekofyear = objCal.GetWeekOfYear(actualDate, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
|
|
|
|
return weekofyear;
|
|
}
|
|
}
|
|
}
|