Add incoming stock for build orders

This commit is contained in:
Oliver 2022-03-01 17:31:26 +11:00
parent 8f7164d5cd
commit dfd6684699

View File

@ -2035,6 +2035,7 @@ function loadPartSchedulingChart(canvas_id, part_id) {
}
// Extract purchase order information from the server
if (part_info.purchaseable) {
inventreeGet(
`/api/order/po-line/`,
{
@ -2075,6 +2076,7 @@ function loadPartSchedulingChart(canvas_id, part_id) {
}
}
);
}
// Extract sales order information from the server
if (part_info.salable) {
@ -2117,6 +2119,42 @@ function loadPartSchedulingChart(canvas_id, part_id) {
);
}
// Request build orders for this part
if (part_info.assembly) {
inventreeGet(
`/api/build/`,
{
part: part_id,
active: true,
},
{
async: false,
success: function(build_orders) {
build_orders.forEach(function(build_order) {
var target_date = build_order.target_date;
var delta = Math.max(build_order.quantity - build_order.completed, 0);
// TODO: How do we handle the case where the build order does not have a target date??
// TODO: Do we just ignore it?
if (target_date && delta > 0) {
var td = moment(target_date);
if (td >= today) {
addScheduleEntry(td, delta, "Build Order", "");
} else {
// TODO: Handle case where the build order is in the "past"
}
}
});
}
}
)
}
// Iterate through future "events" to calculate expected quantity
var quantity = part_info.in_stock;