Exemplo n.º 1
0
        private static TaxItemType MapVatItemType2Vm(object vatItem, decimal taxableAmount)
        {
            if (vatItem == null)
            {
                return(null);
            }
            if (vatItem.GetType() == typeof(SRC.TaxExemptionType))
            {
                SRC.TaxExemptionType taxExemption = (SRC.TaxExemptionType)vatItem;
                TaxItemType          taxItem      = new TaxItemType()
                {
                    TaxPercent = new TaxPercentType()
                    {
                        TaxCategoryCode = PlugInSettings.VStBefreitCode,
                        Value           = 0
                    },
                    TaxableAmount = taxableAmount,
                    Comment       = taxExemption.Value
                };
                return(taxItem);
            }
            SRC.VATRateType vATRate    = (SRC.VATRateType)vatItem;
            TaxItemType     taxItemVat = new TaxItemType()
            {
                TaxPercent = new TaxPercentType()
                {
                    Value           = vATRate.Value,
                    TaxCategoryCode = PlugInSettings.Default.GetValueFromPercent(vATRate.Value).Code
                },
                TaxableAmount = taxableAmount,
            };

            return(taxItemVat);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Maps the tax from Model to ebInterface V5p0
        /// Caution: OtherTax Element not suppored.
        /// </summary>
        /// <param name="SourceTax">The source tax.</param>
        /// <returns></returns>
        private static Model.TaxType MapTax(SRC.TaxType SourceTax)
        {
            TaxType            tax      = new TaxType();
            List <TaxItemType> taxItems = new List <TaxItemType>();

            if (SourceTax.TaxItem == null)
            {
                return(null);
            }
            foreach (var taxItemModel in SourceTax.TaxItem)
            {
                TaxItemType taxItem = new TaxItemType()
                {
                    TaxableAmount      = taxItemModel.TaxableAmount,
                    TaxAmount          = taxItemModel.TaxAmount, //(taxItemModel.TaxableAmount * taxItemModel.TaxPercent.Value / 100).FixedFraction(2),
                    TaxAmountSpecified = true,
                    TaxPercent         = new TaxPercentType()
                    {
                        TaxCategoryCode = taxItemModel.TaxPercent.TaxCategoryCode,
                        Value           = taxItemModel.TaxPercent.Value
                    },
                };
                taxItems.Add(taxItem);
            }
            tax.TaxItem = taxItems;
            return(tax);
        }
Exemplo n.º 3
0
        private static VatDefaultValue GetVatValueFromTaxItem(TaxItemType tax, bool VatBerechtigt)
        {
            if (!VatBerechtigt)
            {
                return(PlugInSettings.Default.IstNichtVStBerechtigtVatValue);
            }
            VatDefaultValue vatDefault = PlugInSettings.Default.GetValueFromPercent(tax.TaxPercent.Value);

            return(vatDefault);
        }
Exemplo n.º 4
0
        private static TaxItemType MapTaxItemType(Model.TaxItemType taxItem)
        {
            TaxItemType tax = new TaxItemType()
            {
                TaxableAmount      = taxItem.TaxableAmount.FixedFraction(2),
                Comment            = taxItem.Comment,
                TaxAmountSpecified = true,
                TaxAmount          = (taxItem.TaxableAmount * taxItem.TaxPercent.Value / 100).FixedFraction(2),
                TaxPercent         = new TaxPercentType()
                {
                    TaxCategoryCode = taxItem.TaxPercent.TaxCategoryCode,
                    Value           = taxItem.TaxPercent.Value
                }
            };

            return(tax);
        }
Exemplo n.º 5
0
        private static TaxItemType MapVatItemType2Vm(object vatItem, decimal taxableAmount)
        {
            if (vatItem == null)
            {
                return(null);
            }
            if (vatItem.GetType() != typeof(SRC.TaxRateType))
            {
                string      taxExemption = (string)vatItem;
                TaxItemType taxItem      = new TaxItemType()
                {
                    TaxableAmount = taxableAmount,
                    TaxPercent    = new TaxPercentType()
                    {
                        TaxCategoryCode = PlugInSettings.VStBefreitCode,
                        Value           = 0
                    },
                    Comment = taxExemption
                };
                return(taxItem);
            }
            SRC.TaxRateType vATRate    = (SRC.TaxRateType)vatItem;
            TaxItemType     taxItemVat = new TaxItemType()
            {
                TaxableAmount = taxableAmount,
                TaxPercent    = new TaxPercentType()
                {
                    Value           = vATRate.Value,
                    TaxCategoryCode = PlugInSettings.Default.GetValueFromPercent(vATRate.Value).Code
                },
                TaxAmount = (taxableAmount * vATRate.Value / 100).FixedFraction(2)
            };

            //Log.DumpToLog(CallerInfo.Create(), vATRate);
            //Log.DumpToLog(CallerInfo.Create(), taxItemVat);
            return(taxItemVat);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Converts the Viewmodel DetailsViewModelList to Model ItemListType
        /// </summary>
        /// <param name="detailsList">The details list.</param>
        /// <param name="orderId">The order identifier.</param>
        /// <returns>List of ItemListType</returns>
        public static List <ItemListType> ConvertToItemList(BindingList <DetailsViewModel> detailsList, string orderId)
        {
            ItemListType itemList = new ItemListType
            {
                ListLineItem = new List <ListLineItemType>()
            };
            int posNr = 1;

            foreach (DetailsViewModel details in detailsList)
            {
                ListLineItemType lineItem = new ListLineItemType
                {
                    ArticleNumber = new List <ArticleNumberType>()
                    {
                        new ArticleNumberType()
                        {
                            Value = details.ArtikelNr
                        }
                    },
                    Description = new List <string>()
                    {
                        details.Bezeichnung
                    },
                    PositionNumber = posNr.ToString()
                };
                posNr++;
                lineItem.InvoiceRecipientsOrderReference.OrderID             = orderId;
                lineItem.InvoiceRecipientsOrderReference.OrderPositionNumber = details.BestellBezug;

                lineItem.UnitPrice = new UnitPriceType()
                {
                    Value = details.EinzelPreis
                };
                TaxItemType taxItem = new TaxItemType()
                {
                    TaxableAmount = details.NettoBetragZeile,
                    TaxPercent    = new TaxPercentType()
                    {
                        TaxCategoryCode = details.VatItem.Code,
                        Value           = details.VatItem.MwStSatz
                    },
                    TaxAmount = (details.NettoBetragZeile * details.VatItem.MwStSatz / 100).FixedFraction(2)
                };
                if (PlugInSettings.Default.VStBerechtigt)
                {
                    taxItem.Comment = PlugInSettings.Default.VatDefaultValues
                                      .Where(p => p.Code == taxItem.TaxPercent.TaxCategoryCode && p.MwStSatz == taxItem.TaxPercent.Value)
                                      .FirstOrDefault().Beschreibung;
                }
                else
                {
                    taxItem.Comment = PlugInSettings.Default.VStText;
                }
                lineItem.TaxItem  = taxItem;
                lineItem.Quantity = new UnitType()
                {
                    Unit  = details.Einheit,
                    Value = details.Menge
                };
                if (details.Rabatt != 0)
                {
                    ReductionAndSurchargeListLineItemDetailsType red = new ReductionAndSurchargeListLineItemDetailsType
                    {
                        ItemsElementName = new List <ItemsChoiceType>()
                        {
                            ItemsChoiceType.ReductionListLineItem
                        },
                        Items = new List <object>()
                    };
                    ReductionAndSurchargeBaseType redBase = new ReductionAndSurchargeBaseType
                    {
                        BaseAmount          = details.NettoBasisBetrag,
                        Percentage          = details.Rabatt,
                        PercentageSpecified = true
                    };
                    red.Items.Add(redBase);
                    lineItem.ReductionAndSurchargeListLineItemDetails = red;
                }
                lineItem.LineItemAmount = details.NettoBetragZeile;
                itemList.ListLineItem.Add(lineItem);
            }
            List <ItemListType> item = new List <ItemListType>
            {
                itemList
            };

            return(item);
        }