Exemplo n.º 1
0
        /// <summary>
        /// Input VAT is the value added tax added to the price when you purchase goods or services liable to VAT. If the buyer is registered in the VAT Register, the buyer can deduct the amount of VAT paid from his/her settlement with the tax authorities.
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="quantity"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public List <KeyValuePair <int, decimal> > ComputeInputTax(int vendorId, int itemId, decimal quantity, decimal amount, decimal discount)
        {
            decimal taxAmount = 0, amountXquantity = 0, discountAmount = 0, subTotalAmount = 0;

            var taxes = new List <KeyValuePair <int, decimal> >();
            var item  = _inventoryService.GetItemById(itemId);

            amountXquantity = amount * quantity;

            if (discount > 0)
            {
                discountAmount = (discount / 100) * amountXquantity;
            }

            subTotalAmount = amountXquantity - discountAmount;

            var intersectionTaxes = _taxService.GetIntersectionTaxes(itemId, vendorId, PartyTypes.Vendor);

            foreach (var tax in intersectionTaxes)
            {
                taxAmount = subTotalAmount - (subTotalAmount / (1 + (tax.Rate / 100)));
                taxes.Add(new KeyValuePair <int, decimal>(tax.Id, taxAmount));
            }

            return(taxes);
        }
Exemplo n.º 2
0
        public IActionResult GetTax(int itemId, int partyId, int type = 0)
        {
            //var taxes = _taxService.GetIntersectionTaxes(itemId, partyId);
            //var taxesDto = new List<Tax>();

            //foreach (var tax in taxes) {
            //    var taxDto = new Tax()
            //    {
            //        Id = tax.Id,
            //        TaxCode = tax.TaxCode,
            //        TaxName = tax.TaxName,
            //        Rate = tax.Rate,
            //        IsActive = tax.IsActive
            //    };
            //    taxesDto.Add(taxDto);
            //}

            //return new ObjectResult(taxesDto);

            if (type == 0)
            {
                return(new BadRequestObjectResult("Type is zero."));
            }
            else
            {
                var taxes = _taxService.GetIntersectionTaxes(itemId, partyId, (Core.Domain.PartyTypes)type);

                return(new ObjectResult(taxes));
            }
        }