} // !AddTradeLineCommentItem()

        /// <summary>
        /// Adds a new line to the invoice. The line id is generated automatically.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="unitCode"></param>
        /// <param name="unitQuantity"></param>
        /// <param name="grossUnitPrice"></param>
        /// <param name="netUnitPrice"></param>
        /// <param name="billedQuantity"></param>
        /// <param name="taxType"></param>
        /// <param name="categoryCode"></param>
        /// <param name="taxPercent"></param>
        /// <param name="comment"></param>
        /// <param name="id"></param>
        /// <param name="sellerAssignedID"></param>
        /// <param name="buyerAssignedID"></param>
        /// <param name="deliveryNoteID"></param>
        /// <param name="deliveryNoteDate"></param>
        /// <param name="buyerOrderID"></param>
        /// <param name="buyerOrderDate"></param>
        /// <returns></returns>
        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)
        {
            return(AddTradeLineItem(lineID: _getNextLineId(),
                                    name: name,
                                    description: description,
                                    unitCode: unitCode,
                                    unitQuantity: unitQuantity,
                                    grossUnitPrice: grossUnitPrice,
                                    netUnitPrice: netUnitPrice,
                                    billedQuantity: billedQuantity,
                                    taxType: taxType,
                                    categoryCode: categoryCode,
                                    taxPercent: taxPercent,
                                    comment: comment,
                                    id: id,
                                    sellerAssignedID: sellerAssignedID,
                                    deliveryNoteID: deliveryNoteID,
                                    buyerOrderID: buyerOrderID));
        } // !AddTradeLineItem()
Exemplo n.º 2
0
        } // !addTradeLineCommentItem()

        /// <summary>
        /// @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>
        /// </summary>
        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()
Exemplo n.º 3
0
 public void SetSeller(string name, string postcode, string city, string street, CountryCodes country, string id, GlobalID globalID = null)
 {
     this.Seller = new Party()
     {
         ID       = id,
         Name     = name,
         Postcode = postcode,
         City     = city,
         Street   = street,
         Country  = country,
         GlobalID = globalID
     };
 } // !SetSeller()
Exemplo n.º 4
0
        } // !AddNote()

        public void SetBuyer(string name, string postcode, string city, string street, CountryCodes country, string id, GlobalID globalID = null, string receiver = "")
        {
            this.Buyer = new Party()
            {
                ID          = id,
                Name        = name,
                Postcode    = postcode,
                ContactName = receiver,
                City        = city,
                Street      = street,
                Country     = country,
                GlobalID    = globalID
            };
        }
Exemplo n.º 5
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()