123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Xml.Linq;
- using GCHR.Model;
- using GCHR.Model.Konto;
- namespace GCHR.Mandantenschnittstelle
- {
- class Volkswagen : IMandant
- {
-
-
-
-
-
-
-
-
- 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();
- 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", Hauptmarke.V),
- new XElement(Tns + "PartnerNumber", _config.Händlernummer)
- ),
- new XElement(Tns + "IsCumulative", "true"),
- new XElement(Tns + "AccountingDate",
- new XElement(Tns + "AccountingMonth", HaendlerKonto.AktuellePeriode.Monat),
- new XElement(Tns + "AccountingYear", HaendlerKonto.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 kto)
- {
- _accounts.Add(new XElement(Tns + "Account",
- new XElement(Tns + "ProfitCenter", "00"),
- new XElement(Tns + "AccountKey",
- AccountKey(kto)
-
- ),
- new XElement(Tns + "AccountValue", AccountValue(kto))
- ));
- return String.Empty;
- }
- private string AccountKey(HaendlerKonto kto)
- {
- return String.Join("", AccountKeyDict(kto).Values.ToArray());
- }
- private object[] AccountAttributes(HaendlerKonto kto)
- {
- return (from attrib in AccountKeyDict(kto)
- select new XAttribute(attrib.Key, attrib.Value)).ToArray();
- }
- private static Dictionary<string, string> AccountKeyDict(HaendlerKonto kto)
- {
- var marke = kto.Marke.PadRight(6, '?');
- var kontonummer = kto.Kontonummer.PadRight(10, '?');
- var dict = new Dictionary<string, string>();
- dict.Add("Brand", marke.Substring(0,2));
- dict.Add("ModelCode", marke.Substring(2));
- dict.Add("Account", kontonummer.Substring(0,4));
- dict.Add("CostCentre", kontonummer.Substring(4, 2));
- dict.Add("TradeChannel", kontonummer.Substring(6, 2));
- dict.Add("CostUnit", kontonummer.Substring(8, 2));
- dict.Add("Location", kto.Betrieb);
- dict.Add("TaxCode", "000");
- return dict;
- }
- 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 AccountsFooter
- {
- get
- {
- return String.Empty;
- }
- }
- public string AccountsBody(HaendlerKonto kto)
- {
- return String.Empty;
- }
- }
- }
|