library(dplyr)
library(DomoR)
library(gbp)
library(knitr)
library(rgl)
knit_hooks$set(webgl = hook_webgl)
load("domoCustomer")
load("domoAccessToken")
init(domoCustomer, domoAccessToken)
opts_chunk$set(echo = TRUE)box_list <- fetch("51434740-ea01-43cf-92af-8a7f724e2c30")
shipments <- fetch("d003b999-a0c4-40b6-8ebc-22aab825855b") %>%
filter(products_quantity > 0,
products_quantity < 100,
#used_box_alias != 'NOBOX',
products_length > 0,
products_width > 0,
products_height > 0,
products_weight > 0)big_box <- data.frame(id = 'too_big', l = 40, d = 40, h = 10, w = 60)
bn <- box_list %>%
filter(active == 1,
usps_priority_box == 0,
usps_flat_rate_box == 0,
!box_alias %in% c('PROD NOBOX SM', 'PROD NOBOX LG', 'PLY1', 'MM', 'LIQ NOBOX', 'NOBOX')) %>%
rename(id = box_alias,
l = length,
d = width,
h = height) %>%
mutate(w = 70) %>%
select(id, l, d, h, w) %>%
rbind(big_box) %>%
mutate(volume = l*d*h) %>%
arrange(volume) %>%
select(-volume)it <- data.frame(
oid = integer(),
sku = integer(),
l = numeric(),
d = numeric(),
h = numeric(),
w = numeric()
)
for (i in 1:dim(shp)[1]) {
if (shp$products_quantity[i] == 1) {
newDF = data.frame(
oid = as.integer(shp$shipments_id[i]),
sku = as.integer(shp$products_id[i]),
l = as.numeric(shp$products_length[i]),
d = as.numeric(shp$products_width[i]),
h = as.numeric(shp$products_height[i]),
w = as.numeric(shp$products_weight[i])
)
it = rbind(it, newDF)
}
else{
subTable = data.frame(
oid = integer(),
sku = integer(),
l = numeric(),
d = numeric(),
h = numeric(),
w = numeric()
)
for (j in 1:shp$products_quantity[i]) {
newDF = data.frame(
oid = as.integer(shp$shipments_id[i]),
sku = as.integer(shp$products_id[i]),
l = as.numeric(shp$products_length[i]),
d = as.numeric(shp$products_width[i]),
h = as.numeric(shp$products_height[i]),
w = as.numeric(shp$products_weight[i])
)
subTable = rbind(subTable, newDF)
}
it = rbind(it, subTable)
}
}## bpp_solver_dpp: processing order id: 51338674 on index: 0 - 5 ..
You must enable Javascript to view this page properly.