|
@@ -0,0 +1,173 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Xml.Linq;
|
|
|
+using GCHR.Model.Konto;
|
|
|
+
|
|
|
+namespace GCHR.Model.Mandant
|
|
|
+{
|
|
|
+ internal class Hyundai : IMandant
|
|
|
+ {
|
|
|
+ private const string Country = "DE";
|
|
|
+ private const string Currency = "EUR";
|
|
|
+
|
|
|
+ private static readonly XNamespace Tns = XNamespace.None;
|
|
|
+
|
|
|
+ private XDocument _xmlDocument;
|
|
|
+ private readonly XElement _accounts = new XElement(Tns + "RecordList");
|
|
|
+ private readonly HashSet<string> _makes = new HashSet<string>();
|
|
|
+ private readonly HashSet<string> _sites = new HashSet<string>();
|
|
|
+ private readonly HashSet<string> _departments = new HashSet<string>();
|
|
|
+
|
|
|
+ private readonly Konfiguration _config = Konfiguration.GetInstance();
|
|
|
+
|
|
|
+ public bool BalanceDatei
|
|
|
+ {
|
|
|
+ get { return true; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool AccountsDatei
|
|
|
+ {
|
|
|
+ get { return false; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public string BalanceHeader
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return String.Empty;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private IEnumerable<XElement> MakeList
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return (from make in _makes
|
|
|
+ select new XElement("MakeListEntry", new XElement("Make", make), new XElement("MakeCode", make == "01" ? "8252" : "0000")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private IEnumerable<XElement> BmCodeList
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return (from dept in _departments
|
|
|
+ select
|
|
|
+ new XElement("BmCodeListEntry", new XElement("Make", dept.Split(new[] {'-'})[0]),
|
|
|
+ new XElement("Site", dept.Split(new[] {'-'})[1]),
|
|
|
+ new XElement("BmCode", _config.HaendlernummerBmCode)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public string BalanceFooter
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ _xmlDocument = new XDocument();
|
|
|
+ _xmlDocument.Add(new XElement(Tns + "HbvData",
|
|
|
+ new XElement(Tns + "Header",
|
|
|
+ new XElement(Tns + "Country", Country),
|
|
|
+ new XElement(Tns + "MainBmCode", _config.HaendlernummerBmCode),
|
|
|
+ new XElement(Tns + "Month", _config.AktuellePeriode.Monat),
|
|
|
+ new XElement(Tns + "Year", _config.AktuellePeriode.Jahr),
|
|
|
+ new XElement(Tns + "Currency", Currency),
|
|
|
+ new XElement(Tns + "NumberOfMakes", _makes.Count),
|
|
|
+ new XElement(Tns + "NumberOfSites", _sites.Count),
|
|
|
+ new XElement(Tns + "ExtractionDate", DateTime.Now.ToShortDateString()),
|
|
|
+ new XElement(Tns + "ExtractionTime", string.Format("{0:T}", DateTime.Now)),
|
|
|
+ new XElement(Tns + "BeginFiscalYear", _config.Geschaeftsjahr)
|
|
|
+ ),
|
|
|
+ new XElement(Tns + "MakeList", MakeList),
|
|
|
+ new XElement(Tns + "BmCodeList", BmCodeList),
|
|
|
+ _accounts
|
|
|
+ ));
|
|
|
+
|
|
|
+ return _xmlDocument.ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public string BalanceBody(HaendlerKonto konto)
|
|
|
+ {
|
|
|
+ // Konto: Account-Make-Site-Origin-SalesChannel-CostCarrier
|
|
|
+ var split = konto.Kontonummer.Split(new[] {'-'});
|
|
|
+ var make = (split[1] == "??") ? konto.Marke : split[1];
|
|
|
+ if (!_makes.Contains(make))
|
|
|
+ {
|
|
|
+ _makes.Add(make);
|
|
|
+ }
|
|
|
+ var site = (split[2] == "??") ? konto.Betrieb : split[2];
|
|
|
+ if (!_sites.Contains(site))
|
|
|
+ {
|
|
|
+ _sites.Add(site);
|
|
|
+ }
|
|
|
+ var department = make + "-" + site;
|
|
|
+ if (!_departments.Contains(department))
|
|
|
+ {
|
|
|
+ _departments.Add(department);
|
|
|
+ }
|
|
|
+
|
|
|
+ _accounts.Add(new XElement(Tns + "Record",
|
|
|
+ new XElement(Tns + "Account", split[0].PadLeft(4, '0')),
|
|
|
+ new XElement(Tns + "Make", make.PadLeft(2, '0')),
|
|
|
+ new XElement(Tns + "Site", site.PadLeft(2, '0')),
|
|
|
+ new XElement(Tns + "Origin", split[3].PadLeft(2, '0')),
|
|
|
+ new XElement(Tns + "SalesChannel", split[4].PadLeft(2, '0')),
|
|
|
+ new XElement(Tns + "CostCarrier", split[5].PadLeft(2, '0')),
|
|
|
+ new XElement(Tns + "CostAccountingString", make.PadLeft(2, '0') + site.PadLeft(2, '0') + split[3].PadLeft(2, '0') + split[4].PadLeft(2, '0') + split[5].PadLeft(2, '0')),
|
|
|
+ new XElement(Tns + "Decimals", "2"),
|
|
|
+ new XElement(Tns + "OpeningBalance", string.Format("{0:0.}", konto.Eroeffnungsbilanz * 100)),
|
|
|
+ new XElement(Tns + "Period01", MonatFormat(konto, 1)),
|
|
|
+ new XElement(Tns + "Period02", MonatFormat(konto, 2)),
|
|
|
+ new XElement(Tns + "Period03", MonatFormat(konto, 3)),
|
|
|
+ new XElement(Tns + "Period04", MonatFormat(konto, 4)),
|
|
|
+ new XElement(Tns + "Period05", MonatFormat(konto, 5)),
|
|
|
+ new XElement(Tns + "Period06", MonatFormat(konto, 6)),
|
|
|
+ new XElement(Tns + "Period07", MonatFormat(konto, 7)),
|
|
|
+ new XElement(Tns + "Period08", MonatFormat(konto, 8)),
|
|
|
+ new XElement(Tns + "Period09", MonatFormat(konto, 9)),
|
|
|
+ new XElement(Tns + "Period10", MonatFormat(konto, 10)),
|
|
|
+ new XElement(Tns + "Period11", MonatFormat(konto, 11)),
|
|
|
+ new XElement(Tns + "Period12", MonatFormat(konto, 12)),
|
|
|
+ new XElement(Tns + "CumulatedYear", string.Format("{0:0.}", konto.Summe * 100))
|
|
|
+ ));
|
|
|
+ return String.Empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static string MonatFormat(HaendlerKonto konto, int monat)
|
|
|
+ {
|
|
|
+ return string.Format("{0:0.}", konto.Monatssumme(monat)*100);
|
|
|
+ }
|
|
|
+
|
|
|
+ public string AccountsHeader
|
|
|
+ {
|
|
|
+ get { return String.Empty; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public string AccountsBody(HaendlerKonto kto)
|
|
|
+ {
|
|
|
+ return String.Empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ public string AccountsFooter
|
|
|
+ {
|
|
|
+ get { return String.Empty; }
|
|
|
+ }
|
|
|
+
|
|
|
+ public string KontonummerFormatieren(HaendlerKonto konto)
|
|
|
+ {
|
|
|
+ // Konto: Account-Make-Site-Origin-SalesChannel-CostCarrier
|
|
|
+ var split = konto.Kontonummer.Split(new[] { '-' });
|
|
|
+ if (split.Count() < 6) return konto.ToString();
|
|
|
+ var make = (split[1] == "??") ? konto.Marke : split[1];
|
|
|
+ var site = (split[2] == "??") ? konto.Betrieb : split[2];
|
|
|
+ return split[0].PadLeft(4, '0') + "-" + make.PadLeft(2, '0') + site.PadLeft(2, '0') + split[3].PadLeft(2, '0') + split[4].PadLeft(2, '0') + split[5].PadLeft(2, '0');
|
|
|
+ }
|
|
|
+
|
|
|
+ public Encoding Encoding
|
|
|
+ {
|
|
|
+ get { return Encoding.Default; }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|