Ejemplo n.º 1
0
        public async Task ShouldFindBillByInvoiceNumberWithTenderSuccess(string invoiceNumbers)
        {
            var result = await _sut.FindBillByInvoiceNumberWithTender(invoiceNumbers);

            Assert.NotNull(result);
            Assert.IsType <BillInfo>(result);
        }
Ejemplo n.º 2
0
        public async Task <string> SetBillPaid(PaymentNotificationServiceModel postedModel)
        {
            VerifyPaymentNotification(postedModel);

            var bill = await _billQueries.FindBulkBillByInvoiceNumberWithTenderInfoAsync(postedModel.BillAccount);

            var billnumbersUpdated = bill.BillInvoiceNumber;
            var CurrentBillStatus  = bill.BillStatusId;

            try
            {
                Check.EntityNotNull(nameof(bill), bill, Resources.SharedResources.DisplayInputs.NotFound);
                if (bill.InvitationId != null)
                {
                    bill.Invitation.UpdateStatus((int)Enums.InvitationStatus.Approved, "");
                }
                bill.UpdatePaymentDetails(postedModel.IntermediatePaymentId, postedModel.PaymentMethodDetail?.SadadPaymentTranactionId, postedModel.PaymentMethodDetail.BankReversalTransactionID,
                                          postedModel.PaymentStatusCode, postedModel.BillAccount, postedModel.PaymentAmount,
                                          postedModel.PaymentDate,
                                          postedModel.PaymentMethodDetail.BankId, postedModel.PaymentMethodDetail.PaymentChannel, postedModel.PaymentMethod, postedModel?.PaymentReferenceInfo,
                                          postedModel.PaymentMethodDetail.BankPaymentID, postedModel.PayorPOIDetail.POINumber, postedModel.PayorPOIDetail.POIType);
                await _billCommands.UpdateBillAsync(bill);

                if (CurrentBillStatus != (int)Enums.BillStatus.Paid)
                {
                    if (bill.ConditionsBookletID != null)
                    {
                        var billobj = await _billQueries.FindBillByInvoiceNumberWithTender(postedModel.BillAccount);

                        var tender = billobj.ConditionsBooklet.Tender;

                        NotificationArguments NotificationArgument = new NotificationArguments
                        {
                            BodyEmailArgs = new object[] { bill.ConditionsBooklet.CommericalRegisterNo, tender.TenderName },
                            PanelArgs     = new object[] { tender.TenderName },
                            SMSArgs       = new object[] { tender.TenderName }
                        };
                        MainNotificationTemplateModel billStatusSuccessUploadedForSupplier = new MainNotificationTemplateModel(
                            NotificationArgument,
                            $"Tender/Details?STenderId={Util.Encrypt(tender.TenderId)}",
                            NotificationEntityType.Tender,
                            tender.TenderId.ToString(),
                            tender.BranchId);
                        await _notificationAppService.SendNotificationForSuppliers(NotificationOperations.Supplier.OperationsOnTheTender.sadadpaymentnotification, new List <string> {
                            bill.ConditionsBooklet.CommericalRegisterNo
                        }, billStatusSuccessUploadedForSupplier);
                    }
                    else
                    {
                        var tender = bill.Invitation.Tender;
                        NotificationArguments NotificationArgument = new NotificationArguments
                        {
                            BodyEmailArgs = new object[] { bill.Invitation.CommericalRegisterNo, tender.TenderName },
                            PanelArgs     = new object[] { tender.TenderName },
                            SMSArgs       = new object[] { tender.TenderName }
                        };
                        MainNotificationTemplateModel billStatusSuccessUploadedForSupplier = new MainNotificationTemplateModel(
                            NotificationArgument,
                            $"Tender/Details?STenderId={Util.Encrypt(tender.TenderId)}",
                            NotificationEntityType.Tender,
                            tender.TenderId.ToString(),
                            tender.BranchId
                            );
                        await _notificationAppService.SendNotificationForSuppliers(NotificationOperations.Supplier.OperationsOnTheTender.sadadpaymentnotification, new List <string> {
                            bill.Invitation.CommericalRegisterNo
                        }, billStatusSuccessUploadedForSupplier);
                    }
                }


                return(billnumbersUpdated);
            }
            catch (Exception ex)
            {
                _logger.LogError("ex", ex.Message.ToString());
                throw;
            }
        }