Commit 64f159c
committed
Properly calculate inventory item quantities to be moved
The backordered quantity count should differ depending on whether
moving to the same or a different stock location. For this reason,
the way we calculate `available_quantity` changes as follows:
* when the stock location differs:
the stock on hand at the new shipment stock location;
* when the stock location is the same:
the sum of the stock on hand at the shipment stock location
plus the number of on_hand inventory items from the shipment
The explicit `backordered_quantity` variable is introduced to track
the number of backordered items for the target shipment. The value
is calculated as follows:
* when the stock location differs:
the quantity to be moved minus the positive available quantity at
the stock location;
* when the stock location is the same:
the shipment total quantity for the variant minus the positive
available quantity at the stock location.
Also, we start the process by moving backordered items first to
to make sure no pending backordered item remains. If the backordered
count decreased, we're going to leave a few to be later moved and
transformed to on hand, while if the backordered count increased, we
are going to move also some previously on hand items.1 parent 2bc7831 commit 64f159c
1 file changed
+31
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
91 | 90 | | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
112 | | - | |
113 | | - | |
| 114 | + | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
119 | | - | |
120 | | - | |
| 121 | + | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| |||
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
144 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
145 | 157 | | |
146 | | - | |
| 158 | + | |
147 | 159 | | |
148 | | - | |
| 160 | + | |
| 161 | + | |
149 | 162 | | |
150 | 163 | | |
151 | 164 | | |
| |||
156 | 169 | | |
157 | 170 | | |
158 | 171 | | |
159 | | - | |
| 172 | + | |
160 | 173 | | |
161 | 174 | | |
162 | 175 | | |
163 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
164 | 185 | | |
165 | 186 | | |
166 | 187 | | |
| |||
0 commit comments