fix(booking): require arrival time before release

This commit is contained in:
2026-10-22 18:47:58 +08:00
parent bfeeef130e
commit ef0f691845
3 changed files with 9 additions and 16 deletions
@@ -231,24 +231,17 @@ class OceanBookingServiceTest {
verify(repository, times(1)).transition(1L, "DRAFT", "RELEASED", 3, 9L, "admin");
}
/** 不录预计到港仍可放舱,其余资料及附件门禁保持有效。 */
/** 缺预计到港不能放舱,避免关联柜次后丢失日历及默认到仓日期来源。 */
@Test
void releasesWithoutEstimatedArrival() {
stubMasterData();
void rejectsReleaseWithoutEstimatedArrival() {
OceanBookingEntity draft = completeBooking("DRAFT", 3);
OceanBookingEntity released = completeBooking("RELEASED", 4);
draft.setEstimatedArrivalAt(null);
released.setEstimatedArrivalAt(null);
when(repository.find(1L)).thenReturn(draft, released);
when(repository.find(1L)).thenReturn(draft);
when(repository.parties(1L)).thenReturn(parties());
when(repository.requirements(1L)).thenReturn(List.of(requirement()));
when(repository.transition(1L, "DRAFT", "RELEASED", 3, 9L, "admin")).thenReturn(1);
Detail result = service.release(1L, 9L, "admin", "release-no-arrival", new ReleaseRequest(3, "确认放舱"));
assertThat(result.oceanBooking().getStatus()).isEqualTo("RELEASED");
assertThat(result.oceanBooking().getEstimatedArrivalAt()).isNull();
verify(documents).requireActiveValidDocument(draft);
assertThatThrownBy(() -> service.release(1L, 9L, "admin", "release-no-arrival", new ReleaseRequest(3, "确认放舱")))
.isInstanceOf(BizException.class).hasMessageContaining("尚未填写完整");
verify(repository, never()).transition(anyLong(), anyString(), anyString(), anyInt(), anyLong(), anyString());
}
@Test