public BillingProxyTest() { _configuration = SetupConfigurations.GetApplicationConfiguration(Directory.GetCurrentDirectory()); _rootConfiguration = new Mock <IOptionsSnapshot <RootConfigurations> >(); _rootConfiguration.Setup(m => m.Value).Returns(_configuration); _BillingProxy = new BillingProxy(_rootConfiguration.Object); model = new NewBillModel { AgencyJebayaCodeForSaddad = "041001000000002000", AmountDue = 100, DueDate = DateTime.Now, ExpDate = DateTime.Now.AddDays(15), RevList = new List <RevenueEntryInfoType>() { new RevenueEntryInfoType { Amt = 100, BenAgencyId = "067000000000000000", GFSCode = "1421901", } }, sadadInvoiceNumber = "10030161467", SupplierNameAr = "142154293000206", SupplierNameEn = "142154293000206", billRefIdForBillingForSaddad = "SubScriptions", ClientKey = "000000" }; }
private async Task <bool> UploadThroughTahseel(BillModel billModel, BillInfo billInfo) { NewBillModel objBill = new NewBillModel(); decimal totalAmount = 0; List <RevenueEntryInfoType> revList = new List <RevenueEntryInfoType>(); foreach (var item in billModel.TenderFees) { totalAmount += item.FeesValue; if (item.FessType == (int)Enums.TenderFeesType.FinantialCostForInvitation) { revList.Add( new RevenueEntryInfoType() { BenAgencyId = _benAgencyCodeForInvitations, Amt = item.FeesValue, GFSCode = _gFSCODEForInvitations }); } else if (item.FessType == (int)Enums.TenderFeesType.FinantialCostForConditionalBooklet) { revList.Add( new RevenueEntryInfoType() { BenAgencyId = _benAgencyCodeForConditionsBooklet, Amt = item.FeesValue, GFSCode = _gFSCODEForAddedValue }); } else if (item.FessType == (int)Enums.TenderFeesType.ConditionalBookletPrice) { revList.Add( new RevenueEntryInfoType() { BenAgencyId = billModel.ChapterNumber + billModel.BankBranchId + billModel.SectionId + billModel.SequenceNumber + billModel.NumOfSubDepartments + billModel.NumOfSubSections, Amt = item.FeesValue, GFSCode = _gFSCODEForConditionalBooklet }); } } objBill.RevList = revList; objBill.ClientKey = _clientKey; objBill.AmountDue = billModel.AmountDue; objBill.DueDate = billModel.DueDate; objBill.ExpDate = billModel.ExpDate; objBill.billRefIdForBillingForSaddad = _billRefIdForBillingForSaddad; objBill.AgencyJebayaCodeForSaddad = _billAgencyJebayaIdentifierForSaddad; objBill.SupplierNameAr = billModel.DisplayLabelAr; objBill.SupplierNameEn = billModel.DisplayLabelAr; var BillInvoiceNumber = await _billProxy.CreateNewBill(objBill); if (!string.IsNullOrEmpty(BillInvoiceNumber)) { foreach (var item in billModel.TenderFees) { billInfo.BillPaymentDetails.Add(new BillPaymentDetails(item.FeesValue, BillInvoiceNumber, item.GFSCode, item.FessType)); } billInfo.UpdateBillInfo(BillInvoiceNumber, billModel.ChapterNumber, billModel.BankBranchId, billModel.NumOfSubSections, billModel.SequenceNumber, billModel.NumOfSubDepartments, billModel.NumOfSubSections, _billAgencyCodeForSaddad, billModel.DisplayLabelAr, billModel.DisplayLabelEn, billModel.BatchId); await _billCommands.UpdateBillAsync(billInfo); var tender = new Tender(); string cr = ""; string CrName = ""; if (billInfo != null) { if (billModel.RequestType == (int)Enums.RequestType.ConditionalBookletRequest) { tender = billInfo.ConditionsBooklet.Tender; CrName = string.IsNullOrEmpty(billInfo.DisplayLabelAr) ? billInfo.DisplayLabelEn : billInfo.DisplayLabelAr; cr = billInfo.ConditionsBooklet.CommericalRegisterNo; } else { tender = billInfo.Invitation.Tender; CrName = string.IsNullOrEmpty(billInfo.DisplayLabelAr) ? billInfo.DisplayLabelEn : billInfo.DisplayLabelAr; cr = billInfo.Invitation.CommericalRegisterNo; } NotificationArguments NotificationArgument = new NotificationArguments { BodyEmailArgs = new object[] { CrName, tender.TenderName, BillInvoiceNumber }, PanelArgs = new object[] { BillInvoiceNumber }, SMSArgs = new object[] { BillInvoiceNumber } }; 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.sadadgeneratedbill, new List <string> { cr }, billStatusSuccessUploadedForSupplier); } } else { if (billModel.RequestType == (int)Enums.RequestType.ConditionalBookletRequest) { BillArchive billArchiveForCondtionalBooklet = new BillArchive(billInfo.ConditionsBookletID, billInfo.InvitationId, billInfo.ConditionsBooklet.TenderId, billInfo.ConditionsBooklet.Tender.ReferenceNumber, BillInvoiceNumber, billInfo.AgencyCode, billInfo.ConditionsBooklet.CommericalRegisterNo); await _billArchiveCommands.CreateAsync(billArchiveForCondtionalBooklet); billInfo.DeleteBooklet(); await _billCommands.DeleteBillAsync(billInfo); } else { if (billInfo.ConditionsBookletID != null) { billInfo.DeleteBooklet(); } BillArchive billArchive = new BillArchive(billInfo.ConditionsBookletID, billInfo.InvitationId, billInfo.Invitation.TenderId, billInfo.Invitation.Tender.ReferenceNumber, BillInvoiceNumber, billInfo.AgencyCode, billInfo.Invitation.CommericalRegisterNo); await _billArchiveCommands.CreateWithoutSave(billArchive); await _billCommands.DeleteWithoutSave(billInfo); billInfo.DeleteInvitation(); await _billCommands.Save(); } throw new BusinessRuleException(Resources.TenderResources.Messages.IDmSadadDetailsNotExist); } return(true); }