-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import order_taking/common/decimal.{type Decimal} | ||
import order_taking/common/public_types | ||
|
||
/// From the order form used as input | ||
pub type OrderFormLineDto { | ||
OrderFormLineDto( | ||
order_line_id: String, | ||
product_code: String, | ||
quantity: Decimal, | ||
) | ||
} | ||
|
||
/// Convert the OrderFormLine into a UnvalidatedOrderLine | ||
/// This always succeeds because there is no validation. | ||
/// Used when importing an OrderForm from the outside world into the domain. | ||
pub fn to_unvalidated_order_line( | ||
dto: OrderFormLineDto, | ||
) -> public_types.UnvalidatedOrderLine { | ||
// this is a simple 1:1 copy | ||
public_types.UnvalidatedOrderLine( | ||
order_line_id: dto.order_line_id, | ||
product_code: dto.product_code, | ||
quantity: dto.quantity, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import order_taking/common/decimal.{type Decimal} | ||
import order_taking/common/public_types | ||
import order_taking/common/simple_types/order_line_id | ||
import order_taking/common/simple_types/order_quantity | ||
import order_taking/common/simple_types/price | ||
import order_taking/common/simple_types/product_code | ||
|
||
/// Used in the output of the workflow | ||
pub type PricedOrderLineDto { | ||
PricedOrderLineDto( | ||
order_line_id: String, | ||
product_code: String, | ||
quantity: Decimal, | ||
line_price: Decimal, | ||
) | ||
} | ||
|
||
/// Convert a PricedOrderLine object into the corresponding DTO. | ||
/// Used when exporting from the domain to the outside world. | ||
pub fn from_domain( | ||
domain_obj: public_types.PricedOrderLine, | ||
) -> PricedOrderLineDto { | ||
// this is a simple 1:1 copy | ||
PricedOrderLineDto( | ||
order_line_id: domain_obj.order_line_id |> order_line_id.value, | ||
product_code: domain_obj.product_code |> product_code.value, | ||
quantity: domain_obj.quantity |> order_quantity.value, | ||
line_price: domain_obj.line_price |> price.value, | ||
) | ||
} |