예제 #1
0
        private InvoiceXml.invoiceInvoiceItem CreateInvoiceItem(InvoiceItemBase invoiceItem)
        {
            var data = new InvoiceXml.invoiceInvoiceItem();

            int MaxItemNameLength = 85;

            //this name is not actually used in pohoda, so it can be automatically truncated
            if (invoiceItem.Name.Length > MaxItemNameLength) // TODO do this operation during BLO->DTO convertion
            {
                invoiceItem.Name = invoiceItem.Name.Substring(0, MaxItemNameLength);
            }

            data.text     = invoiceItem.Name;
            data.quantity = invoiceItem.Quantity;

            data.discountPercentage = 0;
            data.foreignCurrency    = new InvoiceXml.invoiceInvoiceItemForeignCurrency();
            data.homeCurrency       = new InvoiceXml.invoiceInvoiceItemHomeCurrency();
            data.PDP = false;

            data.rateVAT = "historyHigh";
            data.foreignCurrency.unitPrice = invoiceItem.UnitPrice.AmountForeign.DefRound();
            data.foreignCurrency.price     = invoiceItem.TotalPrice.AmountForeign.DefRound();
            data.foreignCurrency.priceSum  = invoiceItem.TotalPrice.AmountForeign.DefRound();
            data.foreignCurrency.priceVAT  = invoiceItem.VatPrice.AmountForeign.DefRound();

            data.homeCurrency.unitPrice = invoiceItem.UnitPrice.AmountHome.DefRound();
            data.homeCurrency.price     = invoiceItem.TotalPrice.AmountHome.DefRound();
            data.homeCurrency.priceSum  = invoiceItem.TotalPrice.AmountHome.DefRound();
            data.homeCurrency.priceVAT  = invoiceItem.VatPrice.AmountHome.DefRound();
            data.payVAT = invoiceItem.ParentInvoice.PayVat;

            if (invoiceItem.IsMoss)
            {
                data.typeServiceMOSS = new InvoiceXml.typeServiceMOSS {
                    ids = "GD"
                };
                data.percentVAT = invoiceItem.PercentVat;
            }

            if (invoiceItem is not InvoiceProduct product)
            {
                return(data);
            }

            data.stockItem           = new InvoiceXml.invoiceInvoiceItemStockItem();
            data.stockItem.stockItem = new InvoiceXml.stockItem();
            data.stockItem.store     = new InvoiceXml.store();
            data.code                    = product.WarehouseCode;
            data.amazonSkuCode           = product.AmazonSku;
            data.stockItem.stockItem.ids = product.WarehouseCode;
            data.stockItem.store.ids     = "Zboží";

            return(data);
        }
예제 #2
0
        private InvoiceItemBase FillInvoiceItem(InvoiceItemBase invoiceItem, string name, decimal priceIncludingTax, decimal tax, decimal quantity)
        {
            invoiceItem.Name              = name;
            invoiceItem.Quantity          = quantity;
            invoiceItem.TotalPriceWithTax = new CommonServices.Currency(
                priceIncludingTax, // There is no need to manually calculate tax (ReverseTaxValue) and subtract it since its value is available in amazon report
                                   // and recalculation logic is included into InvoiceBase Item
                invoiceItem.ParentInvoice.TotalPrice.ForeignCurrencyName,
                _rates);

            invoiceItem.Tax = new CommonServices.Currency(
                tax,
                invoiceItem.ParentInvoice.TotalPrice.ForeignCurrencyName,
                _rates);

            invoiceItem.PercentVat = invoiceItem.ParentInvoice.CountryVat.Percentage * (decimal)100.0;

            return(invoiceItem);
        }