Esempio n. 1
0
        public async Task <bool> UpdateSalesInvoiceMasterAmount(int?salesInvoiceId)
        {
            bool isUpdated = false;

            // get record.
            Salesinvoice salesInvoice = await GetByIdAsync(w => w.InvoiceId == salesInvoiceId);

            if (null != salesInvoice)
            {
                salesInvoice.TotalLineItemAmountFc = salesInvoice.Salesinvoicedetails.Sum(w => w.GrossAmountFc);
                salesInvoice.TotalLineItemAmount   = salesInvoice.TotalLineItemAmountFc * salesInvoice.ExchangeRate;

                if (DiscountType.Percentage.ToString() == salesInvoice.DiscountPercentageOrAmount)
                {
                    salesInvoice.DiscountAmountFc = (salesInvoice.TotalLineItemAmountFc * salesInvoice.DiscountPercentage) / 100;
                }
                else
                {
                    salesInvoice.DiscountAmountFc = salesInvoice.DiscountPercentage;
                }

                salesInvoice.DiscountAmount = salesInvoice.DiscountAmountFc * salesInvoice.ExchangeRate;
                salesInvoice.GrossAmountFc  = salesInvoice.TotalLineItemAmountFc + salesInvoice.DiscountAmountFc;
                salesInvoice.GrossAmount    = salesInvoice.GrossAmountFc * salesInvoice.ExchangeRate;

                if (TaxModelType.LineWise.ToString() == salesInvoice.TaxModelType)
                {
                    salesInvoice.TaxAmountFc = salesInvoice.Salesinvoicedetails.Sum(w => w.TaxAmountFc);
                }
                else
                {
                    salesInvoice.TaxAmountFc = salesInvoice.Salesinvoicetaxes.Sum(w => w.TaxAmountFc);
                }

                salesInvoice.TaxAmount   = salesInvoice.TaxAmountFc * salesInvoice.ExchangeRate;
                salesInvoice.NetAmountFc = salesInvoice.GrossAmountFc + salesInvoice.DiscountAmountFc;
                salesInvoice.NetAmount   = salesInvoice.NetAmountFc * salesInvoice.ExchangeRate;

                if (null != salesInvoice.Currency)
                {
                    salesInvoice.NetAmountFcinWord = await common.AmountInWord_Million(salesInvoice.NetAmountFc.ToString(), salesInvoice.Currency.CurrencyCode, salesInvoice.Currency.Denomination);
                }

                isUpdated = await Update(salesInvoice);
            }

            return(isUpdated); // returns.
        }
        public async Task <bool> UpdatePurchaseInvoiceMasterAmount(int?purchaseInvoiceId)
        {
            bool isUpdated = false;

            // get record.
            Purchaseinvoice purchaseInvoice = await GetByIdAsync(w => w.PurchaseInvoiceId == purchaseInvoiceId);

            if (null != purchaseInvoice)
            {
                purchaseInvoice.TotalLineItemAmountFc = purchaseInvoice.Purchaseinvoicedetails.Sum(w => w.GrossAmountFc);
                purchaseInvoice.TotalLineItemAmount   = purchaseInvoice.TotalLineItemAmountFc * purchaseInvoice.ExchangeRate;

                if (DiscountType.Percentage.ToString() == purchaseInvoice.DiscountPercentageOrAmount)
                {
                    purchaseInvoice.DiscountAmountFc = (purchaseInvoice.TotalLineItemAmountFc * purchaseInvoice.DiscountPerOrAmountFc) / 100;
                }
                else
                {
                    purchaseInvoice.DiscountAmountFc = purchaseInvoice.DiscountPerOrAmountFc;
                }

                purchaseInvoice.DiscountAmount = purchaseInvoice.DiscountAmountFc * purchaseInvoice.ExchangeRate;

                purchaseInvoice.GrossAmountFc = purchaseInvoice.TotalLineItemAmountFc + purchaseInvoice.DiscountAmountFc;
                purchaseInvoice.GrossAmount   = purchaseInvoice.GrossAmountFc * purchaseInvoice.ExchangeRate;

                if (TaxModelType.LineWise.ToString() == purchaseInvoice.TaxModelType)
                {
                    purchaseInvoice.TaxAmountFc = purchaseInvoice.Purchaseinvoicedetails.Sum(w => w.TaxAmountFc);
                }
                else
                {
                    purchaseInvoice.TaxAmountFc = purchaseInvoice.Purchaseinvoicetaxes.Sum(w => w.TaxAmountFc);
                }

                purchaseInvoice.TaxAmount = purchaseInvoice.TaxAmountFc * purchaseInvoice.ExchangeRate;

                purchaseInvoice.NetAmountFc = purchaseInvoice.GrossAmountFc + purchaseInvoice.DiscountAmountFc;
                purchaseInvoice.NetAmount   = purchaseInvoice.NetAmountFc * purchaseInvoice.ExchangeRate;

                purchaseInvoice.NetAmountFcinWord = await common.AmountInWord_Million(purchaseInvoice.NetAmountFc.ToString(), purchaseInvoice.Currency.CurrencyCode, purchaseInvoice.Currency.Denomination);

                isUpdated = await Update(purchaseInvoice);
            }

            return(isUpdated); // returns.
        }