Пример #1
0
        } // !AddTradeLineItem()

        /// <summary>
        /// Adds a new line to the invoice. The line id is passed as a parameter.
        /// </summary>
        public TradeLineItem AddTradeLineItem(string lineID,
                                              string name,
                                              string description            = null,
                                              QuantityCodes unitCode        = QuantityCodes.Unknown,
                                              decimal?unitQuantity          = null,
                                              decimal?grossUnitPrice        = null,
                                              decimal?netUnitPrice          = null,
                                              decimal billedQuantity        = 0,
                                              TaxTypes taxType              = TaxTypes.Unknown,
                                              TaxCategoryCodes categoryCode = TaxCategoryCodes.Unknown,
                                              decimal taxPercent            = 0,
                                              string comment              = null,
                                              GlobalID id                 = null,
                                              string sellerAssignedID     = "", string buyerAssignedID      = "",
                                              string deliveryNoteID       = "", DateTime?deliveryNoteDate   = null,
                                              string buyerOrderID         = "", DateTime?buyerOrderDate     = null,
                                              DateTime?billingPeriodStart = null, DateTime?billingPeriodEnd = null)
        {
            TradeLineItem newItem = new TradeLineItem()
            {
                LineID             = lineID,
                GlobalID           = id,
                SellerAssignedID   = sellerAssignedID,
                BuyerAssignedID    = buyerAssignedID,
                Name               = name,
                Description        = description,
                UnitCode           = unitCode,
                UnitQuantity       = unitQuantity,
                GrossUnitPrice     = grossUnitPrice,
                NetUnitPrice       = netUnitPrice,
                BilledQuantity     = billedQuantity,
                TaxType            = taxType,
                TaxCategoryCode    = categoryCode,
                TaxPercent         = taxPercent,
                BillingPeriodStart = billingPeriodStart,
                BillingPeriodEnd   = billingPeriodEnd
            };

            if (String.IsNullOrEmpty(lineID))
            {
                throw new ArgumentException("LineID cannot be Null or Empty");
            }
            else
            {
                if (this.TradeLineItems.Any(p => p.AssociatedDocument.LineID.ToLower() == lineID.ToLower()))
                {
                    throw new ArgumentException("LineID must be unique");
                }
            }

            newItem.AssociatedDocument = new ZUGFeRD.AssociatedDocument(lineID);
            if (!String.IsNullOrEmpty(comment))
            {
                newItem.AssociatedDocument.Notes.Add(new Note(comment, SubjectCodes.Unknown, ContentCodes.Unknown));
            }

            if (!String.IsNullOrEmpty(deliveryNoteID) || deliveryNoteDate.HasValue)
            {
                newItem.SetDeliveryNoteReferencedDocument(deliveryNoteID, deliveryNoteDate);
            }

            if (!String.IsNullOrEmpty(buyerOrderID) || buyerOrderDate.HasValue)
            {
                newItem.SetOrderReferencedDocument(buyerOrderID, buyerOrderDate);
            }

            this.TradeLineItems.Add(newItem);
            return(newItem);
        } // !AddTradeLineItem()
Пример #2
0
        } // !AddTradeLineCommentItem()

        // TODO Rabatt ergänzen:
        // <ram:AppliedTradeAllowanceCharge>
        //     <ram:ChargeIndicator><udt:Indicator>false</udt:Indicator></ram:ChargeIndicator>
        //     <ram:CalculationPercent>2.00</ram:CalculationPercent>
        //     <ram:BasisAmount currencyID = "EUR" > 1.5000 </ram:BasisAmount>
        //     <ram:ActualAmount currencyID = "EUR" > 0.0300 </ram:ActualAmount>
        //     <ram:Reason>Artikelrabatt 1</ram:Reason>
        // </ram:AppliedTradeAllowanceCharge>
        public TradeLineItem AddTradeLineItem(string name,
                                              string description            = null,
                                              QuantityCodes unitCode        = QuantityCodes.Unknown,
                                              decimal?unitQuantity          = null,
                                              decimal grossUnitPrice        = Decimal.MinValue,
                                              decimal netUnitPrice          = Decimal.MinValue,
                                              decimal billedQuantity        = Decimal.MinValue,
                                              TaxTypes taxType              = TaxTypes.Unknown,
                                              TaxCategoryCodes categoryCode = TaxCategoryCodes.Unknown,
                                              decimal taxPercent            = Decimal.MinValue,
                                              string comment          = null,
                                              GlobalID id             = null,
                                              string sellerAssignedID = "", string buyerAssignedID    = "",
                                              string deliveryNoteID   = "", DateTime?deliveryNoteDate = null,
                                              string buyerOrderID     = "", DateTime?buyerOrderDate   = null)
        {
            TradeLineItem newItem = new TradeLineItem()
            {
                GlobalID         = id,
                SellerAssignedID = sellerAssignedID,
                BuyerAssignedID  = buyerAssignedID,
                Name             = name,
                Description      = description,
                UnitCode         = unitCode,
                UnitQuantity     = unitQuantity,
                GrossUnitPrice   = grossUnitPrice,
                NetUnitPrice     = netUnitPrice,
                BilledQuantity   = billedQuantity,
                TaxType          = taxType,
                TaxCategoryCode  = categoryCode,
                TaxPercent       = taxPercent,
                LineTotalAmount  = netUnitPrice * billedQuantity
            };

            int?_lineID = null;

            if (this.TradeLineItems.Count > 0)
            {
                _lineID = this.TradeLineItems.Last().AssociatedDocument.LineID;
            }

            if (_lineID.HasValue)
            {
                _lineID = _lineID.Value + 1;
            }
            else
            {
                _lineID = 1;
            }

            newItem.AssociatedDocument = new ZUGFeRD.AssociatedDocument(_lineID);
            if (!String.IsNullOrEmpty(comment))
            {
                newItem.AssociatedDocument.Notes.Add(new Note(comment, SubjectCodes.Unknown, ContentCodes.Unknown));
            }

            if (!String.IsNullOrEmpty(deliveryNoteID) || deliveryNoteDate.HasValue)
            {
                newItem.SetDeliveryNoteReferencedDocument(deliveryNoteID, deliveryNoteDate);
            }

            if (!String.IsNullOrEmpty(buyerOrderID) || buyerOrderDate.HasValue)
            {
                newItem.SetOrderReferencedDocument(buyerOrderID, buyerOrderDate);
            }

            this.TradeLineItems.Add(newItem);
            return(newItem);
        } // !AddTradeLineItem()