Skip to content

Commit

Permalink
Merge pull request #24 from flash-global/hotfix/662_binpacking_height…
Browse files Browse the repository at this point in the history
…_issue

fix binpacking issue with package height
  • Loading branch information
acacopardo committed Oct 18, 2023
2 parents 8acb5d0 + bb9b8cc commit 0794c49
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = function (RED) {
const adaptedPackages = []

packages.forEach((pkg) => {
if (pkg.item.originale_height) {
pkg.item.height = pkg.item.originale_height
} else {
pkg.item.originale_height = pkg.item.height
}
if (pkg.stackable === 'no' && pkg.item.height < bin.height) {
pkg.item.height = bin.height
}
Expand Down
42 changes: 42 additions & 0 deletions test/stackable.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const request = require('supertest')
const hostDemo = 'http://localhost:1880/binpacking'

const data = {
packages: [
{
name: 'bh',
width: 60,
height: 60,
length: 70,
weight: 28,
quantity: 1,
stackable: 'no',
allowedRotation: [
0
]
}
],
bins: [
{
name: 'avion',
width: 100,
height: 200,
length: 120,
weight: 400
},
{
name: 'break',
width: 100,
height: 100,
length: 120,
weight: 400
}
]
}

describe('Test related to binpacking', () => {
test('package should fit in the second bin', async () => {
const response = await request(`${hostDemo}`).post('/').send(data)
expect(response.body.result[1].success).toBe(true)
})
})

0 comments on commit 0794c49

Please sign in to comment.