static void Main(string[] args) { var retriever = new StubRetriever(GetStubbedClients(), GetStubbedJournalEntries()); // var retriever = new DynamoRetriever(); var clientsService = new ClientService(retriever); var journalEntryService = new JournalEntryService(retriever); var generalClientsController = new GeneralClientsController(clientsService); var specificClientsController = new SpecificClientsController(clientsService); var generalJournalEntryController = new GeneralJournalEntryController(journalEntryService); var specificJournalEntryController = new SpecificJournalEntryController(journalEntryService); var router = new Router( generalJournalEntryController, specificJournalEntryController, generalClientsController, specificClientsController); var server = new Server(Uri, router); Console.WriteLine($"\n\nServer listening on port: {Port}"); server.Run(); Console.ReadKey(); }
public void ShouldReturnValid() { var username = "******"; var password = ""; var rfcToFind = "CAC840428RH1"; ILoginService loginService = new LoginService(new ContpaqLegacySessionProvider()); ICompanyService companyService = new CompanyService(new ContpaqLegacyCompanyProvider()); IJournalEntryTypeService journalEntryTypeService = new JournalEntryTypeService(new ContpaqLegacyJournalEntryTypeProvider()); IJournalEntryService journalEntryService = new JournalEntryService(new ContpaqLegacyJournalEntryProvider()); AccountingManager accountingManager = new AccountingManager(loginService, companyService, journalEntryTypeService, journalEntryService); ISupplierService supplierService = new SupplierService(new ContpaqLegacySupplierProvider()); SupplierManager supplierManager = new SupplierManager(supplierService); var session = accountingManager.DoLogin(username, password); var companies = accountingManager.GetCompanies(); Assert.NotEmpty(companies); accountingManager.OpenCompany(session, companies.FirstOrDefault().DBName); Assert.True(session.IsValid); var res = supplierManager.GetSupplierByRFC(session, rfcToFind); Assert.NotNull(res); Assert.Equal(rfcToFind, res.RFC); }
public void ShouldNotBeEmpty() { var username = "******"; var password = ""; ILoginService loginService = new LoginService(new ContpaqLegacySessionProvider()); ICompanyService companyService = new CompanyService(new ContpaqLegacyCompanyProvider()); IJournalEntryTypeService journalEntryTypeService = new JournalEntryTypeService(new ContpaqLegacyJournalEntryTypeProvider()); IJournalEntryService journalEntryService = new JournalEntryService(new ContpaqLegacyJournalEntryProvider()); AccountingManager accountingManager = new AccountingManager(loginService, companyService, journalEntryTypeService, journalEntryService); var session = accountingManager.DoLogin(username, password); Assert.True(session.IsValid); var companies = accountingManager.GetCompanies(); Assert.NotEmpty(companies); accountingManager.OpenCompany(session, companies.FirstOrDefault().DBName); var journalEntryTypes = accountingManager.GetJournalEntryTypes(session); Assert.NotEmpty(journalEntryTypes); }
public JournalEntriesController(JournalEntryContext contextJE, GoalContext contextGoal, PromptContext contextPrompt, UserDataContext contextUser, IConfiguration configuration, KeyVaultClient keyVaultClient) { _journalEntryService = new JournalEntryService(configuration, keyVaultClient); _contextJE = contextJE; _contextGoal = contextGoal; _contextUser = contextUser; _contextPrompt = contextPrompt; }
public void ShouldReturnValues() { ILoginService loginService = new LoginService(new ContpaqLegacySessionProvider()); ICompanyService companyService = new CompanyService(new ContpaqLegacyCompanyProvider()); IJournalEntryTypeService journalEntryTypeService = new JournalEntryTypeService(new ContpaqLegacyJournalEntryTypeProvider()); IJournalEntryService journalEntryService = new JournalEntryService(new ContpaqLegacyJournalEntryProvider()); AccountingManager accountingManager = new AccountingManager(loginService, companyService, journalEntryTypeService, journalEntryService); var companies = accountingManager.GetCompanies(); Assert.NotEmpty(companies); }
public void Setup() { var client1 = new Client(1, "John", "Smith"); var client2 = new Client(2, "Bobby", "Brown"); _clients = new List <Client> { client1, client2 }; var journalEntry1 = new JournalEntry( 1, 1, new DateTime(2020, 1, 1), "Today I am grateful for..."); var journalEntry2 = new JournalEntry( 2, 1, new DateTime(2020, 1, 2), "Today I am grateful for something else."); _journalEntries = new List <JournalEntry> { journalEntry1, journalEntry2 }; var retriever = new StubRetriever(_clients, _journalEntries); var clientsService = new ClientService(retriever); var journalEntryService = new JournalEntryService(retriever); var generalClientsController = new GeneralClientsController(clientsService); var specificClientsController = new SpecificClientsController(clientsService); var generalJournalEntryController = new GeneralJournalEntryController(journalEntryService); var specificJournalEntryController = new SpecificJournalEntryController(journalEntryService); var router = new Router( generalJournalEntryController, specificJournalEntryController, generalClientsController, specificClientsController); _server = new Server(ServerUri, router); _server.RunAsync(); _client = new HttpClient(); }
public async Task <string> CreateJournalEntry(List <JournalRelationMap> JournalRelationMaps) { StringBuilder resultStr = new StringBuilder(); foreach (var item in JournalRelationMaps) { if (item.IsApart == "Y") { if (item.IsPositiveSync == "N") { var result = JournalEntryService.ApartPositiveJournal(item); if (result.SyncResult == "N") { resultStr.Append(result.SyncMsg + ";"); } await this.UpdateJournalRelationMapPositiveStatuAsync(result); } if (item.IsMinusSync == "N") { var result = JournalEntryService.ApartMinusJournal(item); if (result.SyncResult == "N") { resultStr.Append(result.SyncMsg + ";"); } await this.UpdateJournalRelationMapMinusStatuAsync(result); } } else { if (item.IsSync == "N") { var result = JournalEntryService.CreateJournal(item); if (result.SyncResult == "N") { resultStr.Append(result.SyncMsg + ";"); } await this.UpdateJournalRelationMapStatuAsync(result); } } } if (String.IsNullOrEmpty(resultStr.ToString())) { return("数据同步至财务系统全部成功"); } else { return(resultStr.ToString()); } }
public void ShouldBeCorrect() { var username = "******"; var password = ""; ILoginService loginService = new LoginService(new ContpaqLegacySessionProvider()); ICompanyService companyService = new CompanyService(new ContpaqLegacyCompanyProvider()); IJournalEntryTypeService journalEntryTypeService = new JournalEntryTypeService(new ContpaqLegacyJournalEntryTypeProvider()); IJournalEntryService journalEntryService = new JournalEntryService(new ContpaqLegacyJournalEntryProvider()); AccountingManager accountingManager = new AccountingManager(loginService, companyService, journalEntryTypeService, journalEntryService); var session = accountingManager.DoLogin(username, password); Assert.True(session.IsValid); }
public void ShouldCreateNoMovements() { var username = "******"; var password = ""; ILoginService loginService = new LoginService(new ContpaqLegacySessionProvider()); ICompanyService companyService = new CompanyService(new ContpaqLegacyCompanyProvider()); IJournalEntryTypeService journalEntryTypeService = new JournalEntryTypeService(new ContpaqLegacyJournalEntryTypeProvider()); IJournalEntryService journalEntryService = new JournalEntryService(new ContpaqLegacyJournalEntryProvider()); AccountingManager accountingManager = new AccountingManager(loginService, companyService, journalEntryTypeService, journalEntryService); var session = accountingManager.DoLogin(username, password); Assert.True(session.IsValid); var companies = accountingManager.GetCompanies(); Assert.NotEmpty(companies); accountingManager.OpenCompany(session, companies.FirstOrDefault().DBName); List <JournalEntryMovement> journalEntryMovements = new List <JournalEntryMovement>(); var journalEntry = new JournalEntry() { Type = "6", Date = DateTime.Now, Adjust = false, Affect = true, Daily = 0, Guid = Guid.NewGuid(), Printed = false, SourceSystem = "11", Concept = Guid.NewGuid().ToString() + " desde UT", //Number = 2, }; journalEntry.JournalEntryMovement = journalEntryMovements; accountingManager.CreateJournalEntry(session, new List <JournalEntry>() { journalEntry }); }
private async Task <ActionResult> CreateJournal(List <JournalRelationMap> journalRelations) { foreach (var item in journalRelations) { var serialNumber = await _serialNumberApp.GetSerialNumberOfDateTimeNow(); item.SerialNumber = GetSerialNumber(serialNumber); serialNumber.CurrentNumber++; try { #region 生成分录条件 //1 需要拆分且拆分标识字段为N的 if (item.IsApart == "Y") { if (item.IsPositiveSync == "N") { //拆分正数单据 var rt = JournalEntryService.ApartPositiveJournal(item); var result = await _journalRelationMapApp.UpdateJournalRelationMapPositiveStatuAsync(rt); if (rt.SyncResult == "Y") { await this._serialNumberApp.UpdateCurrentNumber(serialNumber); } } if (item.IsMinusSync == "N") { //拆分负数单据 var rt = JournalEntryService.ApartMinusJournal(item); await _journalRelationMapApp.UpdateJournalRelationMapMinusStatuAsync(rt); if (rt.SyncResult == "Y") { await this._serialNumberApp.UpdateCurrentNumber(serialNumber); } } } //2 不需要拆分且生成标识字段为N的 else if (item.IsApart == "N" && item.IsSync == "N") { var rt = JournalEntryService.CreateJournal(item); await _journalRelationMapApp.UpdateJournalRelationMapStatuAsync(rt); if (rt.SyncResult == "Y") { await this._serialNumberApp.UpdateCurrentNumber(serialNumber); } } #endregion } catch (Exception ex) { Logger.Writer(ex); await _journalRelationMapApp.UpdateJournalRelationMapStatuAsync( new Entity.Document.DocumentSync() { DocEntry = item.DocEntry.ToString(), SyncResult = "N", SyncMsg = ex.Message }); } } return(Json(new { state = ResultType.success.ToString(), message = "同步完成" })); }
public void ShouldCreate() { var username = "******"; var password = ""; ILoginService loginService = new LoginService(new ContpaqLegacySessionProvider()); ICompanyService companyService = new CompanyService(new ContpaqLegacyCompanyProvider()); IJournalEntryTypeService journalEntryTypeService = new JournalEntryTypeService(new ContpaqLegacyJournalEntryTypeProvider()); IJournalEntryService journalEntryService = new JournalEntryService(new ContpaqLegacyJournalEntryProvider()); AccountingManager accountingManager = new AccountingManager(loginService, companyService, journalEntryTypeService, journalEntryService); var session = accountingManager.DoLogin(username, password); Assert.True(session.IsValid); var companies = accountingManager.GetCompanies(); Assert.NotEmpty(companies); accountingManager.OpenCompany(session, companies.FirstOrDefault().DBName); List <JournalEntryMovement> journalEntryMovements = new List <JournalEntryMovement>(); var journalEntryMovement1 = new JournalEntryMovement() { Account = "20101000", Amount = 123, AmountFC = 0, Concept = Guid.NewGuid().ToString() + "Concpept UT", Guid = Guid.NewGuid(), JournalEntryMovementDaily = 0, JournalEntryMovementType = JournalEntryMovementType.DEBITS, Number = 1, }; var journalEntryMovement2 = new JournalEntryMovement() { Account = "10201000", Amount = 123, AmountFC = 0, Concept = Guid.NewGuid().ToString() + "Concpept UT", Guid = Guid.NewGuid(), JournalEntryMovementDaily = 0, JournalEntryMovementType = JournalEntryMovementType.CREDITS, Number = 2, }; journalEntryMovements.Add(journalEntryMovement1); journalEntryMovements.Add(journalEntryMovement2); var journalEntry = new JournalEntry() { Type = "6", Date = DateTime.Now, Adjust = false, Affect = true, Daily = 0, Guid = Guid.NewGuid(), Printed = false, SourceSystem = "11", Concept = Guid.NewGuid().ToString() + " desde UT", Number = 2, }; journalEntry.JournalEntryMovement = journalEntryMovements; List <JournalEntryMovement> journalEntryMovements2 = new List <JournalEntryMovement>(); var journalEntryMovement12 = new JournalEntryMovement() { Account = "20101000", Amount = 123, AmountFC = 0, Concept = Guid.NewGuid().ToString() + "Concpept UT 2 ", Guid = Guid.NewGuid(), JournalEntryMovementDaily = 0, JournalEntryMovementType = JournalEntryMovementType.DEBITS, Number = 1, }; var journalEntryMovement22 = new JournalEntryMovement() { Account = "10201000", Amount = 123, AmountFC = 0, Concept = Guid.NewGuid().ToString() + "Concpept UT 2 ", Guid = Guid.NewGuid(), JournalEntryMovementDaily = 0, JournalEntryMovementType = JournalEntryMovementType.CREDITS, Number = 2, }; journalEntryMovements2.Add(journalEntryMovement12); journalEntryMovements2.Add(journalEntryMovement22); var journalEntry2 = new JournalEntry() { Type = "6", Date = DateTime.Now, Adjust = false, Affect = true, Daily = 0, Guid = Guid.NewGuid(), Printed = false, SourceSystem = "11", Concept = Guid.NewGuid().ToString() + " desde UT", Number = 2, }; journalEntry2.JournalEntryMovement = journalEntryMovements2; accountingManager.CreateJournalEntry(session, new List <JournalEntry>() { journalEntry, journalEntry2 }); }
public SpecificJournalEntryController(JournalEntryService journalEntryService) { _journalEntryService = journalEntryService; }