public async Task CreateBuchungRaiseQuestion() { var client = await IntegrationTestEnvironment.GetClient(TestUser.Administrator); var buchung = new FbBuchung { FbPeriodeId = 6963, BuchungTypCode = 0, BuchungsDatum = new DateTime(2012, 5, 24), SollKtoNr = 3101, HabenKtoNr = 1010, Betrag = 500, Text = "Buchung aus Integrationstest", ValutaDatum = new DateTime(2012, 5, 30), FbZahlungswegId = null }; var result = await client.PostAsJsonAsync("api/fibu/buchungen", buchung) as ServiceResult <QuestionDto>; result.ShouldNotBeNull(); result.Result.QuestionIdentifier.ShouldBe(SaveBuchungCommandHandler.ZahlwegNichtErfasstQuestionIdentifier); result.Result.PossibleAnswers.Count().ShouldBe(2); result.Result.PossibleAnswers.Any(ans => ans.Id as bool? == true).ShouldBeTrue(); result.Result.PossibleAnswers.Any(ans => ans.Id as bool? == false).ShouldBeTrue(); }
public async Task CreateBuchungRaiseQuestionAndAnswer() { var client = await IntegrationTestEnvironment.GetClient(TestUser.Administrator); var buchung = new FbBuchung { FbPeriodeId = 6963, BelegNr = "DA-153924", BuchungTypCode = 0, BuchungsDatum = new DateTime(2012, 5, 24), SollKtoNr = 3101, HabenKtoNr = 1010, Betrag = 500, Text = "Buchung aus Integrationstest", ValutaDatum = new DateTime(2012, 5, 30), FbZahlungswegId = null }; var result = await client.PostAsJsonAsync("api/fibu/buchungen", buchung) as ServiceResult <QuestionDto>; result.ShouldNotBeNull(); result.Result.QuestionIdentifier.ShouldBe(SaveBuchungCommandHandler.ZahlwegNichtErfasstQuestionIdentifier); result.Result.PossibleAnswers.Count().ShouldBe(2); result.Result.PossibleAnswers.Any(ans => ans.Id as bool? == true).ShouldBeTrue(); result.Result.PossibleAnswers.Any(ans => ans.Id as bool? == false).ShouldBeTrue(); var resultSecondCall = await client.PostAsJsonAsync <FbBuchung, FbBuchung>("api/fibu/buchungen", buchung, new { dtaQuestion = true }) as ServiceResult <FbBuchung>; resultSecondCall.ShouldNotBeNull(); resultSecondCall.ShouldBeOk(); var buchungFromServer = resultSecondCall.Result; buchungFromServer.FbBuchungId.ShouldBeGreaterThan(0); buchung.FbBuchungId = buchungFromServer.FbBuchungId; buchung.FbBuchungTs = buchungFromServer.FbBuchungTs; TestDataManager.TrackEntity(buchung); }
private async Task ValidatePeriodeStatus(FbBuchung buchung, int baPersonId) { var aktivePeriode = await _perioden.Where(per => per.BaPersonId == baPersonId && per.PeriodeVon <= buchung.BuchungsDatum && per.PeriodeBis >= buchung.BuchungsDatum) .FirstOrDefaultAsync(); if (aktivePeriode == null) { var text = string.Format(await _translationProvider.GetText("CtlFibuBuchung", "KeineAktivePeriode") ?? "Keine aktive Periode gefunden für den {0}!", buchung.BuchungsDatum.ToShortDateString()); throw new ValidationException(text); } switch (aktivePeriode.PeriodeStatusCode) { case FbPeriodeStatus.Aktiv: { buchung.FbPeriodeId = aktivePeriode.FbPeriodeId; break; } case FbPeriodeStatus.Inaktiv: { var text = string.Format(await _translationProvider.GetText("CtlFibuBuchung", "PeriodeInaktiv") ?? "Die zutreffende Periode für den {0} ist inaktiv!", buchung.BuchungsDatum.ToShortDateString()); throw new ValidationException(text); } case FbPeriodeStatus.Abgeschlossen: { var text = string.Format(await _translationProvider.GetText("CtlFibuBuchung", "PeriodeAbgeschlossen") ?? "Die zutreffende Periode für den {0} ist abgeschlossen!", buchung.BuchungsDatum.ToShortDateString()); throw new ValidationException(text); } default: throw new ArgumentOutOfRangeException(); } }
public async Task <FbBuchung> SaveBuchung([FromBody] FbBuchung buchung, bool?dtaQuestion) { await _mediator.Process(new SaveBuchungCommand { Buchung = buchung, DtaQuestion = dtaQuestion }); return(buchung); }