public static TurnoverReportBuyerLine FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item;
            TurnoverReportBuyerLine result = new TurnoverReportBuyerLine ();

            try
            {
                item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (xmlDocument.SelectSingleNode ("(//didius.turnoverreportbuyerline)[1]")));
            }
            catch
            {
                item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);
            }

            if (item.ContainsKey ("id"))
            {
                result._id = new Guid ((string)item["id"]);
            }
            else
            {
                throw new Exception (string.Format (Strings.Exception.CreditnoteLineFromXmlDocument, "ID"));
            }

            if (item.ContainsKey ("caseid"))
            {
                result._caseid = new Guid ((string)item["caseid"]);
            }
            else
            {
                throw new Exception (string.Format (Strings.Exception.CreditnoteLineFromXmlDocument, "ITEMID"));
            }

            if (item.ContainsKey ("itemid"))
            {
                result._itemid = new Guid ((string)item["itemid"]);
            }
            else
            {
                throw new Exception (string.Format (Strings.Exception.CreditnoteLineFromXmlDocument, "ITEMID"));
            }

            if (item.ContainsKey ("amount"))
            {
                result._amount = decimal.Parse ((string)item["amount"], System.Globalization.CultureInfo.InvariantCulture);
            }

            if (item.ContainsKey ("vatamount"))
            {
                result._vatamount = decimal.Parse ((string)item["vatamount"], System.Globalization.CultureInfo.InvariantCulture);
            }

            if (item.ContainsKey ("commissionfee"))
            {
                result._commissionfee = decimal.Parse ((string)item["commissionfee"], System.Globalization.CultureInfo.InvariantCulture);
            }

            if (item.ContainsKey ("vatcommissionfee"))
            {
                result._vatcommissionfee = decimal.Parse ((string)item["vatcommissionffee"], System.Globalization.CultureInfo.InvariantCulture);
            }

            return result;
        }
Esempio n. 2
0
        public static TurnoverReport Create(Auction Auction)
        {
            TurnoverReport result = new TurnoverReport ();

            foreach (Item item in Item.List (Auction))
            {
            //				if (item.CurrentBidId != Guid.Empty)
                if (item.Invoiced)
                {
                    Case case_ = Case.Load (item.CaseId);
                    Bid bid = Bid.Load (item.CurrentBidId);

                    TurnoverReportSellerLine sellerline = new TurnoverReportSellerLine (item);
                    TurnoverReportSeller seller = result._sellers.Find(TurnoverReportSeller => TurnoverReportSeller.Id == case_.CustomerId);

                    if (seller == null)
                    {
                        seller = new TurnoverReportSeller (Customer.Load (case_.CustomerId));
                        result._sellers.Add (seller);
                    }

                    seller.Amount += sellerline.Amount;
                    seller.VatAmount += sellerline.VatAmount;
                    seller.CommissionFee += sellerline.CommissionFee;
                    seller.VatCommissionFee += sellerline.VatCommissionFee;

                    result._sellerlines.Add (sellerline);

                    TurnoverReportBuyerLine buyerline = new TurnoverReportBuyerLine (item);
                    TurnoverReportBuyer buyer = result._buyers.Find(TurnoverReportBuyer => TurnoverReportBuyer.Id == bid.CustomerId);

                    if (buyer == null)
                    {
                        buyer = new TurnoverReportBuyer (Customer.Load (bid.CustomerId));
                        result._buyers.Add (buyer);
                    }

                    buyer.Amount += buyerline.Amount;
                    buyer.VatAmount += buyerline.VatAmount;
                    buyer.CommissionFee += buyerline.CommissionFee;
                    buyer.VatCommissionFee += buyerline.VatCommissionFee;

                    result._buyerlines.Add (buyerline);
                }
                else
                {
                    Case case_ = Case.Load (item.CaseId);

                    TurnoverReportSellerLine sellerline = new TurnoverReportSellerLine (item);
                    TurnoverReportSeller seller = result._sellers.Find(TurnoverReportSeller => TurnoverReportSeller.Id == case_.CustomerId);

                    if (seller == null)
                    {
                        seller = new TurnoverReportSeller (Customer.Load (case_.CustomerId));
                        result._sellers.Add (seller);
                    }

                    seller.Amount += sellerline.Amount;
                    seller.VatAmount += sellerline.VatAmount;
                    seller.CommissionFee += sellerline.CommissionFee;
                    seller.VatCommissionFee += sellerline.VatCommissionFee;

                    result._sellerlines.Add (sellerline);

                    result._notsoldlines.Add (new TurnoverReportNotSoldLine (item));
                }
            }

            return result;
        }