123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Xml.Linq;
- using GCHR.Model.Konto;
- namespace GCHR.Model.Mandant
- {
- class Volkswagen : IMandant
- {
-
-
-
-
-
-
-
-
- internal enum Hauptmarke { V, A, S, C, E, L };
-
-
-
-
- private const string Level = "1";
- private const string Country = "DEU";
- private const string Currency = "EUR";
- private static readonly XNamespace Tns = "http://xmldefs.volkswagenag.com/Retail/AccountBalanceDTS/V1";
- private static XNamespace _tns1 = "http://xmldefs.volkswagenag.com/DD/BasicTypes";
- private static XNamespace _xsi = "http://www.w3.org/2001/XMLSchema-instance";
- private XDocument _xmlDocument;
- private readonly XElement _accounts = new XElement(Tns + "Accounts");
- private readonly Konfiguration _config = Konfiguration.GetInstance();
- internal Hauptmarke MandantHauptmarke = Hauptmarke.V;
- public bool BalanceDatei
- {
- get
- {
- return true;
- }
- }
- public bool AccountsDatei
- {
- get { return false; }
- }
- public string BalanceHeader
- {
- get
- {
- _xmlDocument = new XDocument();
- _xmlDocument.Add(new XElement(Tns + "ShowAccountBalance",
- new XAttribute(XNamespace.Xmlns + "tns", Tns),
-
-
-
- new XElement(Tns + "PartnerKey",
- new XElement(Tns + "Country", Country),
- new XElement(Tns + "Brand", MandantHauptmarke),
- new XElement(Tns + "PartnerNumber", _config.HaendlernummerBmCode)
- ),
- new XElement(Tns + "IsCumulative", "true"),
- new XElement(Tns + "AccountingDate",
- new XElement(Tns + "AccountingMonth", _config.AktuellePeriode.Monat),
- new XElement(Tns + "AccountingYear", _config.AktuellePeriode.Jahr)
- ),
- new XElement(Tns + "Currency", Currency),
- new XElement(Tns + "Level", Level),
- _accounts
- ));
- return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-
- }
- }
- public string BalanceFooter
- {
- get
- {
- return _xmlDocument.ToString();
- }
- }
- public string BalanceBody(HaendlerKonto konto)
- {
- _accounts.Add(new XElement(Tns + "Account",
- new XElement(Tns + "ProfitCenter", "00"),
- new XElement(Tns + "AccountKey",
- KontonummerFormatieren(konto)
-
- ),
- new XElement(Tns + "AccountValue", AccountValue(konto))
- ));
- return String.Empty;
- }
- private XAttribute[] AccountAttributes(HaendlerKonto kto)
- {
- return (from attrib in AccountKeyDict(kto)
- select new XAttribute(attrib.Key, attrib.Value)).ToArray();
- }
- private static Dictionary<string, string> AccountKeyDict(HaendlerKonto konto)
- {
-
- var split = konto.Kontonummer.Split(new[] { '-' });
- if (split.Count() == 6)
- {
- var marke = (split[1].Contains("?")) ? konto.Marke : split[1];
- marke = marke.PadLeft(6, '0');
- var betrieb = (split[2] == "??") ? konto.Betrieb : split[2];
- return new Dictionary<string, string>
- {
- {"Brand", marke.Substring(0, 2)},
- {"ModelCode", marke.Substring(2)},
- {"Account", split[0].PadLeft(4, '0')},
- {"CostCentre", split[3].PadLeft(2, '0')},
- {"TradeChannel", split[4].PadLeft(2, '0')},
- {"CostUnit", split[5].PadLeft(2, '0')},
- {"Location", betrieb.PadLeft(2, '0')},
- {"TaxCode", "000"}
- };
- }
- var marke2 = konto.Marke.PadRight(6, '?');
- var kontonummer = konto.Kontonummer.PadRight(10, '?');
- return new Dictionary<string, string>
- {
- {"Brand", marke2.Substring(0, 2)},
- {"ModelCode", marke2.Substring(2)},
- {"Account", kontonummer.Substring(0, 4)},
- {"CostCentre", kontonummer.Substring(4, 2)},
- {"TradeChannel", kontonummer.Substring(6, 2)},
- {"CostUnit", kontonummer.Substring(8, 2)},
- {"Location", konto.Betrieb},
- {"TaxCode", "000"}
- };
- }
- private static string AccountValue(HaendlerKonto kto)
- {
-
- return String.Format("{0:+0.00;-0.00;+0.00}", kto.Summe).Replace(',', '.');
- }
- 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)
- {
- return String.Join("", AccountKeyDict(konto).Values.ToArray());
- }
- public Encoding Encoding
- {
- get { return Encoding.Default; }
- }
- }
- }
|