public async Task <WrapperPaymentListVM> DeleteCustomerPayment(PaymentVM vm)
        {
            Task <List <Invoice> > paymentInvoiceListT = _repositoryWrapper
                                                         .Invoice
                                                         .FindAll()
                                                         .Include(x => x.InvoiceType)
                                                         .Where(x =>
                                                                x.InvoiceType.Name == TypeInvoice.ClientPayment.ToString() &&
                                                                x.ClientId == vm.ClientId &&
                                                                x.FactoryId == vm.FactoryId &&
                                                                vm.InvoiceId == x.Id)
                                                         .ToListAsync();

            Task <List <Income> > paymentIncomeListT = _repositoryWrapper
                                                       .Income
                                                       .FindAll()
                                                       .Where(x =>
                                                              x.ClientId == vm.ClientId &&
                                                              x.FactoryId == vm.FactoryId &&
                                                              x.InvoiceId == vm.InvoiceId)
                                                       .ToListAsync();

            Task <List <TblTransaction> > paymentTransactionListT = _repositoryWrapper
                                                                    .Transaction
                                                                    .FindAll()
                                                                    .Where(x =>
                                                                           x.ClientId == vm.ClientId &&
                                                                           x.FactoryId == vm.FactoryId &&
                                                                           x.InvoiceId == vm.InvoiceId)
                                                                    .ToListAsync();

            await Task.WhenAll(paymentInvoiceListT, paymentIncomeListT, paymentTransactionListT);


            _repositoryWrapper.Transaction.Delete(paymentTransactionListT.Result.FirstOrDefault());
            _repositoryWrapper.Invoice.Delete(paymentInvoiceListT.Result.FirstOrDefault());
            _repositoryWrapper.Income.Delete(paymentIncomeListT.Result.FirstOrDefault());

            Task <int> t1 = _repositoryWrapper.Transaction.SaveChangesAsync();
            Task <int> t2 = _repositoryWrapper.Invoice.SaveChangesAsync();
            Task <int> t3 = _repositoryWrapper.Income.SaveChangesAsync();

            await Task.WhenAll(t1, t2, t3);

            var item = new GetPaymentDataListVM();

            item.ClientId   = vm.ClientId;
            item.FactoryId  = vm.FactoryId;
            item.PageNumber = 1;
            item.PageSize   = 10;

            return(await GetCustomerPaymentList(item));
        }
예제 #2
0
        public async Task <WrapperPaymentListVM> GetStaffPaymentList(GetPaymentDataListVM vm)
        {
            Task <List <Invoice> > paymentInvoiceListT = _repositoryWrapper
                                                         .Invoice
                                                         .FindAll()
                                                         .Include(x => x.InvoiceType)
                                                         .Where(x =>
                                                                x.InvoiceType.Name == TypeInvoice.StaffPayment.ToString() &&
                                                                x.ClientId == vm.ClientId &&
                                                                x.FactoryId == vm.FactoryId)
                                                         .OrderByDescending(x => x.DateOfOcurrance)
                                                         .Skip((vm.PageNumber - 1) * vm.PageSize)
                                                         .Take(vm.PageSize)
                                                         .ToListAsync();
            await paymentInvoiceListT;
            WrapperPaymentListVM wrapperPaymentListVM = new WrapperPaymentListVM();

            wrapperPaymentListVM.ListOfData = _utilService.Mapper.Map <List <Invoice>, List <PaymentVM> >(paymentInvoiceListT.Result.ToList());
            return(wrapperPaymentListVM);
        }
예제 #3
0
        public async Task <WrapperPaymentListVM> PayToSupplier(PaymentVM paymentVM)
        {
            Invoice invoiceToAdd = new Invoice();

            invoiceToAdd = _utilService.Mapper.Map <PaymentVM, Invoice>(paymentVM);
            _repositoryWrapper.Invoice.Create(invoiceToAdd);

            paymentVM.InvoiceId = invoiceToAdd.Id;

            Expense expenseToAdd = new Expense();

            expenseToAdd = _utilService.Mapper.Map <PaymentVM, Expense>(paymentVM);
            //expenseToAdd.SupplierId = paymentVM.ClientId;
            _repositoryWrapper.Expense.Create(expenseToAdd);

            TblTransaction transactionToAdd = new TblTransaction();

            transactionToAdd = _utilService.Mapper.Map <PaymentVM, TblTransaction>(paymentVM);
            transactionToAdd.PaymentStatus   = PAYMENT_STATUS.CASH_PAID.ToString();
            transactionToAdd.TransactionType = TRANSACTION_TYPE.DEBIT.ToString();
            transactionToAdd.Description     = "Paid to " + paymentVM.ClientName;
            _repositoryWrapper.Transaction.Create(transactionToAdd);

            Task <int> t1 = _repositoryWrapper.Invoice.SaveChangesAsync();
            Task <int> t2 = _repositoryWrapper.Expense.SaveChangesAsync();
            Task <int> t3 = _repositoryWrapper.Transaction.SaveChangesAsync();

            await Task.WhenAll(t1, t2, t3);

            var item = new GetPaymentDataListVM();

            item.ClientId   = paymentVM.ClientId;
            item.FactoryId  = paymentVM.FactoryId;
            item.PageNumber = 1;
            item.PageSize   = 10;

            return(await GetSupplierPaymentList(item));
        }
        public async Task <WrapperPaymentListVM> RecieveFromCustomer(PaymentVM paymentVM)
        {
            Invoice invoiceToAdd = new Invoice();

            invoiceToAdd = _utilService.Mapper.Map <PaymentVM, Invoice>(paymentVM);
            _repositoryWrapper.Invoice.Create(invoiceToAdd);
            paymentVM.InvoiceId = invoiceToAdd.Id;


            Income incomeToAdd = new Income();

            incomeToAdd = _utilService.Mapper.Map <PaymentVM, Income>(paymentVM);
            _repositoryWrapper.Income.Create(incomeToAdd);

            TblTransaction transactionToAdd = new TblTransaction();

            transactionToAdd = _utilService.Mapper.Map <PaymentVM, TblTransaction>(paymentVM);
            transactionToAdd.PaymentStatus   = PAYMENT_STATUS.CASH_RECIEVED.ToString();
            transactionToAdd.Description     = " Recieved from " + paymentVM.ClientName;
            transactionToAdd.TransactionType = TRANSACTION_TYPE.CREDIT.ToString();
            _repositoryWrapper.Transaction.Create(transactionToAdd);

            Task <int> t1 = _repositoryWrapper.Invoice.SaveChangesAsync();
            Task <int> t2 = _repositoryWrapper.Income.SaveChangesAsync();
            Task <int> t3 = _repositoryWrapper.Transaction.SaveChangesAsync();

            await Task.WhenAll(t1, t2, t3);

            var item = new GetPaymentDataListVM();

            item.ClientId   = paymentVM.ClientId;
            item.FactoryId  = paymentVM.FactoryId;
            item.PageNumber = 1;
            item.PageSize   = 10;

            return(await GetCustomerPaymentList(item));
        }
 public async Task <WrapperPaymentListVM> CustomerPaymentList([FromBody] GetPaymentDataListVM vm)
 {
     return(await _serviceWrapper.CustomerService.GetCustomerPaymentList(vm));
 }
 public async Task <WrapperPaymentListVM> StaffPaymentList([FromBody] GetPaymentDataListVM vm)
 {
     return(await _serviceWrapper.StaffService.GetStaffPaymentList(vm));
 }