Beispiel #1
0
        public int AddPaymentRefundRecord(DLModel.PaymentRefund modelPaymentRefund)
        {
            DLModel.Invoice InvoiceDetail = _IInvoiceImpl.GetInvoiceDetailsById(modelPaymentRefund.InvoiceId);
            InvoiceDetail.InvoiceBalanceAmt = (InvoiceDetail.InvoiceBalanceAmt + modelPaymentRefund.RefundAmount).Value;
            var updInvoiceBalAmt = _invoiceRepository.Update(InvoiceDetail, inv => inv.InvoiceBalanceAmt);

            return(_paymentRefundRepository.Add((DLModel.PaymentRefund) new DLModel.PaymentRefund().InjectFrom(modelPaymentRefund)).PaymentRefundID);
        }
Beispiel #2
0
 public int UpdateInvoiceRecord(DLModel.Invoice modelInvoice)
 {
     if (_invoiceRepostory.GetAll(Inv => (Inv.InvoiceID != modelInvoice.InvoiceID) && (Inv.FileID == modelInvoice.FileID) && (Inv.InvoiceNumber == modelInvoice.InvoiceNumber)).Count() > 0)
     {
         return(0); // means Invoice number allready exist for same file Id
     }
     else
     {
         return(_invoiceRepostory.Update((DLModel.Invoice) new DLModel.Invoice().InjectFrom(modelInvoice)));
     }
 }
Beispiel #3
0
        public int UpdatePaymentRefundRecord(DLModel.PaymentRefund modelPaymentRefund)
        {
            DLModel.Invoice InvoiceDetail    = _IInvoiceImpl.GetInvoiceDetailsById(modelPaymentRefund.InvoiceId);
            var             oldPaymentAmount = _paymentRefundRepository.GetAll(pay => pay.PaymentRefundID == modelPaymentRefund.PaymentRefundID).Select(inv => new DLModel.PaymentRefund().InjectFrom(inv)).Cast <DLModel.PaymentRefund>().SingleOrDefault().RefundAmount;
            var             newInvoiceAmount = (InvoiceDetail.InvoiceBalanceAmt - oldPaymentAmount) + modelPaymentRefund.RefundAmount;

            InvoiceDetail.InvoiceBalanceAmt = newInvoiceAmount.Value;
            var updInvoiceBalAmt = _invoiceRepository.Update(InvoiceDetail, inv => inv.InvoiceBalanceAmt);

            return(_paymentRefundRepository.Update((DLModel.PaymentRefund) new DLModel.PaymentRefund().InjectFrom(modelPaymentRefund)));
        }
Beispiel #4
0
        public int AddPaymentRecord(DLModel.Payment modelPayment)
        {
            //  var PaymentSum = _paymentRepository.GetAll(Pay => Pay.InvoiceId == modelPayment.InvoiceId).ToList().Select(Pay => Pay.PaymentAmount == null ? 0 : Pay.PaymentAmount).Sum();
            //PaymentSum = PaymentSum + modelPayment.PaymentAmount;
            DLModel.Invoice InvoiceDetail = _IInvoiceImpl.GetInvoiceDetailsById(modelPayment.InvoiceId);

            //if (modelPayment.PaymentAmount <= InvoiceDetail.InvoiceBalanceAmt)
            //{
            InvoiceDetail.InvoiceBalanceAmt = (InvoiceDetail.InvoiceBalanceAmt - modelPayment.PaymentAmount).Value;
            var updInvoiceBalAmt = _invoiceRepository.Update(InvoiceDetail, inv => inv.InvoiceBalanceAmt);

            return(_paymentRepository.Add((DLModel.Payment) new DLModel.Payment().InjectFrom(modelPayment)).PaymentId);
            //}
            //else
            //    return -1; // Payment Sum amout can't be greater then invoice amount
        }
Beispiel #5
0
        public int UpdatePaymentRecord(DLModel.Payment modelPayment)
        {
            // var PaymentSum = _paymentRepository.GetAll(Pay => Pay.InvoiceId == modelPayment.InvoiceId && Pay.PaymentId != modelPayment.PaymentId).ToList().Select(Pay => Pay.PaymentAmount == null ? 0 : Pay.PaymentAmount).Sum();
            //PaymentSum = PaymentSum + modelPayment.PaymentAmount;
            DLModel.Invoice InvoiceDetail    = _IInvoiceImpl.GetInvoiceDetailsById(modelPayment.InvoiceId);
            var             oldPaymentAmount = _paymentRepository.GetAll(pay => pay.PaymentId == modelPayment.PaymentId).Select(inv => new DLModel.Payment().InjectFrom(inv)).Cast <DLModel.Payment>().SingleOrDefault().PaymentAmount;
            //if (modelPayment.PaymentAmount <= (InvoiceDetail.InvoiceBalanceAmt + oldPaymentAmount))
            //{
            var newInvoiceAmount = (InvoiceDetail.InvoiceBalanceAmt + oldPaymentAmount) - modelPayment.PaymentAmount;

            InvoiceDetail.InvoiceBalanceAmt = newInvoiceAmount.Value;
            var updInvoiceBalAmt = _invoiceRepository.Update(InvoiceDetail, inv => inv.InvoiceBalanceAmt);

            return(_paymentRepository.Update((DLModel.Payment) new DLModel.Payment().InjectFrom(modelPayment)));
            //}
            //else
            //    return -1; // Payment Sum amout can't be greater then invoice amount
        }