domain

도메인 모듈.

@startuml Domain Model

allow_mixing
left to right direction

!include ./config.puml

class Order {
    * id: str
}

class OrderLine << valueobject >> {
    * orderid: str
    * sku: str
    * qty: int
}

class Batch {
    * reference: str
    sku: str
    eta: date
    --
    _purchased_quantity: int
    _allocations: [OrderLine]
}

actor Customer
actor "Purchasing\nDept. User"

Customer --> Order : places
Order::id o--> OrderLine::orderid : "comprises\nmultiple"
Batch::_allocations o--> OrderLine
"Purchasing\nDept. User" --> Batch : "purchases"

@enduml

models

도메인 모델.

class Batch(ref, sku, qty, eta=None, id=None)

재고 단위(SKU)별로 예정 시간(eta)까지 지정 수량(qta)으로 한번에 구매될 상품입니다.

allocate(line)

지정된 OrderLine 을 현재 Batch 에 추가합니다.

Parameters

line (OrderLine) – 배치에 추가할 OrderLine.

Return type

None

property allocated_quantity

할당된 주문선 수량.

Return type

int

property available_quantity

사용 가능한 재고 수량.

Return type

int

can_allocate(line)

할당 가능 여부를 리턴합니다.

주문선의 SKU가 배치의 SKU와 동일하고 할당 가능한 수량이 주문선의 요구 수량보다 큰 경우에만 할당 가능합니다.

Return type

bool

change_purchased_quantity(new_qty)

구매 수량을 변경합니다.

Return type

None

deallocate(line)

주문선 line 을 할당 취소 합니다.

Return type

None

deallocate_one()

주문선 line 을 할당 취소 합니다.

Return type

Optional[OrderLine]

eta

예정 도착 시간(Estimated Time of Arrival).

id

매핑된 DB가 할당한 고유 ID. 세션 commit이 될 경우에만 값이 부여됩니다.

sku

재고 보관 단위(Stock Keeping Unit).

class Order(id)

고객이 발주하는 주문(Order) 모델입니다..

class OrderLine(orderid, sku, qty)

주문(Order)에 대한 여러 주문선을 나타냅니다.

Batch.allocate() 를 이용해 재고 Batch 소스와 연결합니다.

orderid: str

Order.id 를 가리키는 레퍼런스 id입니다.

sku: str

재고 보관 단위(Stock Keeping Unit).

exception OutOfStock

Batch 에 할당할 재고(Stock)가 없을 때 발생하는 예외입니다.

allocate(line, batches)

주어진 배치들 중 할당 가능하고 가장 ETA가 빠른 배치를 주문선 `line`에 할당합니다.

Raises

OutOfStock

Return type

str