Пример #1
0
        public async Task <IActionResult> Add(InvoicePaymentAddModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorList()));
            }
            await _invoicePaymentManager.AddAsync(model);

            return(Ok());
        }
Пример #2
0
        public static InvoicePayment Create(InvoicePaymentAddModel model, string depositFrom, decimal amount, string userId)
        {
            var invoicePayment = new InvoicePayment()
            {
                InvoiceId     = model.InvoiceId,
                PaymentMode   = model.PaymentMode,
                BankAccountId = model.BankAccountId,
                ChequeNumber  = model.ChequeNumber,
                DepositFrom   = depositFrom,
                Amount        = amount,
                PaymentDate   = model.PaymentDate,
                Description   = model.Description,
                Status        = Constants.RecordStatus.Active,
                CreatedBy     = userId ?? "0",
                CreatedOn     = Utility.GetDateTime()
            };

            return(invoicePayment);
        }
        public async Task AddAsync(InvoicePaymentAddModel model)
        {
            if (model.PaymentType == Constants.TransactionType.InvoicePayment)
            {
                var invoiceSummary = await _invoiceRepository.GetSummaryAsunc(model.InvoiceId);

                var customerPaymentInfo = await _customerRepository.GetPaymentInfoAsync(invoiceSummary.CustomerId);

                var invoicePayment = InvoicePaymentFactory.Create(model, customerPaymentInfo.AccountNumber, invoiceSummary.TotalAmount, _userId);

                await _invoicePaymentRepository.AddAsync(invoicePayment);

                await _invoiceRepository.UpdateStatusAsync(model.InvoiceId, Constants.InvoiceStatus.Paid);

                //For Transaction Update
                await _transactionRepository.SetTransactionAccountIdForInvoice(model.InvoiceId, model.BankAccountId, model.PaymentDate, model.Description);

                await _unitOfWork.SaveChangesAsync();
            }
            else if (model.PaymentType == Constants.TransactionType.CustomerAdvancePayment)
            {
                var transaction = TransactionFactory.CreateByCustomerAdvancePayment(model, model.BankAccountId, 0, model.Amount, true);
                await _transactionRepository.AddAsync(transaction);

                var transactionForCredit = TransactionFactory.CreateByCustomerAdvancePayment(model, model.CreditBankAccountId, model.Amount, 0, false);
                await _transactionRepository.AddAsync(transactionForCredit);

                await _unitOfWork.SaveChangesAsync();
            }
            else if (model.PaymentType == Constants.TransactionType.AccountIncome)
            {
                var transactionforCredit = TransactionFactory.CreateByTaxPaymentByCustomer(model, model.CreditBankAccountId, model.Amount, 0, false);
                await _transactionRepository.AddAsync(transactionforCredit);

                var transactionforDebit = TransactionFactory.CreateByTaxPaymentByCustomer(model, model.BankAccountId, 0, model.Amount, true);
                await _transactionRepository.AddAsync(transactionforDebit);

                await _unitOfWork.SaveChangesAsync();
            }
        }
Пример #4
0
        public static Transaction CreateByTaxPaymentByCustomer(InvoicePaymentAddModel model, int?accId, decimal creditAmt, decimal debitAmt, bool isForTransEntry)
        {
            var transaction = new Transaction
            {
                TransactionId     = null,
                CompanyId         = null,
                TransactionTypeId = Constants.TransactionType.AccountIncome,
                TransactionDate   = model.PaymentDate,
                TransactionNumber = null,
                ContactType       = null,
                ContactId         = null,
                BankAccountId     = accId,
                DebitAmount       = debitAmt,
                CreditAmount      = creditAmt,
                CreationDate      = model.PaymentDate,
                ModifyDate        = model.PaymentDate,
                Status            = Constants.TransactionStatus.Paid,
                Description       = model.Description,
                isForTransEntry   = isForTransEntry
            };

            return(transaction);
        }