Correction des URLs de l'inventaire.
Ajout d'une confirmation avant de déduire l'inventaire.
This commit is contained in:
parent
0abef6ab05
commit
2a55e3d2f9
|
@ -57,7 +57,7 @@
|
|||
step="0.001"
|
||||
[value]="getComputedQuantityRounded(mixMaterial)"
|
||||
[disabled]="mixMaterial.material.materialType.usePercentages"
|
||||
(change)="changeQuantity($event, mixMaterial)"/>
|
||||
(keyup)="changeQuantity($event, mixMaterial)"/>
|
||||
</mat-form-field>
|
||||
</td>
|
||||
<td mat-footer-cell *matFooterCellDef>
|
||||
|
@ -69,7 +69,7 @@
|
|||
min="0.001"
|
||||
step="0.001"
|
||||
[value]="round(getTotalQuantity())"
|
||||
(change)="changeQuantity($event, null, true)"/>
|
||||
(keyup)="changeQuantity($event, null, true)"/>
|
||||
</mat-form-field>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
[units$]="units$"
|
||||
(quantityChange)="changeQuantity($event)"
|
||||
(locationChange)="changeMixLocation($event)"
|
||||
(deduct)="deductMix($event)">
|
||||
(deduct)="showDeductMixConfirm($event, deductConfirmBox)">
|
||||
</cre-mixes-card>
|
||||
</div>
|
||||
|
||||
|
@ -45,3 +45,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<cre-confirm-box
|
||||
#deductConfirmBox
|
||||
message="Voulez-vous vraiment déduire les quantités de ce mélange?"
|
||||
(click)="deductMix()">
|
||||
</cre-confirm-box>
|
||||
|
|
|
@ -7,6 +7,8 @@ import {Observable, Subject} from 'rxjs'
|
|||
import {ErrorModel, ErrorService} from '../../../shared/service/error.service'
|
||||
import {AlertService} from '../../../shared/service/alert.service'
|
||||
import {GlobalAlertHandlerComponent} from '../../../shared/components/global-alert-handler/global-alert-handler.component'
|
||||
import {InventoryService} from '../../../material/service/inventory.service'
|
||||
import {ConfirmBoxComponent} from '../../../shared/components/confirm-box/confirm-box.component'
|
||||
|
||||
@Component({
|
||||
selector: 'cre-explore',
|
||||
|
@ -32,6 +34,7 @@ export class ExploreComponent extends ErrorHandlingComponent {
|
|||
|
||||
constructor(
|
||||
private recipeService: RecipeService,
|
||||
private inventoryService: InventoryService,
|
||||
private alertService: AlertService,
|
||||
errorService: ErrorService,
|
||||
router: Router,
|
||||
|
@ -94,15 +97,19 @@ export class ExploreComponent extends ErrorHandlingComponent {
|
|||
)
|
||||
}
|
||||
|
||||
deductMix(mixId: number) {
|
||||
showDeductMixConfirm(mixId: number, confirmBox: ConfirmBoxComponent) {
|
||||
this.deductedMixId = mixId
|
||||
const firstMixMaterial = this.recipe.mixes.filter(m => m.id === mixId)[0].mixMaterials[0]
|
||||
if (this.quantitiesChanges.has(mixId) && this.quantitiesChanges.get(mixId).has(firstMixMaterial.material.id)) {
|
||||
confirmBox.show()
|
||||
}
|
||||
|
||||
deductMix() {
|
||||
const firstMixMaterial = this.recipe.mixes.filter(m => m.id === this.deductedMixId)[0].mixMaterials[0]
|
||||
if (this.quantitiesChanges.has(this.deductedMixId) && this.quantitiesChanges.get(this.deductedMixId).has(firstMixMaterial.material.id)) {
|
||||
const originalQuantity = firstMixMaterial.quantity
|
||||
const currentQuantity = this.quantitiesChanges.get(mixId).get(firstMixMaterial.material.id)
|
||||
this.subscribeDeductMix(this.recipeService.deductMixFromQuantities(mixId, originalQuantity, currentQuantity))
|
||||
const currentQuantity = this.quantitiesChanges.get(this.deductedMixId).get(firstMixMaterial.material.id)
|
||||
this.subscribeDeductMix(this.inventoryService.deductMixFromQuantities(this.deductedMixId, originalQuantity, currentQuantity))
|
||||
} else {
|
||||
this.subscribeDeductMix(this.recipeService.deductMix(mixId, 1))
|
||||
this.subscribeDeductMix(this.inventoryService.deductMix(this.deductedMixId, 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,13 +67,4 @@ export class RecipeService {
|
|||
delete(id: number): Observable<void> {
|
||||
return this.api.delete<void>(`/recipe/${id}`)
|
||||
}
|
||||
|
||||
deductMixFromQuantities(mixId: number, originalQuantity: number, currentQuantity: number): Observable<MaterialQuantity[]> {
|
||||
return this.deductMix(mixId, currentQuantity / originalQuantity)
|
||||
}
|
||||
|
||||
deductMix(mixId: number, ratio: number): Observable<MaterialQuantity[]> {
|
||||
const body = {id: mixId, ratio}
|
||||
return this.api.put<MaterialQuantity[]>('/inventory/deduct/mix', body)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,20 @@ export class InventoryService {
|
|||
}
|
||||
|
||||
add(material: number, quantity: number): Observable<MaterialQuantity[]> {
|
||||
return this.api.put<MaterialQuantity[]>('/material/inventory/add', [{material, quantity}])
|
||||
return this.api.put<MaterialQuantity[]>('/inventory/add', [{material, quantity}])
|
||||
}
|
||||
|
||||
deductMixFromQuantities(mixId: number, originalQuantity: number, currentQuantity: number): Observable<MaterialQuantity[]> {
|
||||
return this.deductMix(mixId, currentQuantity / originalQuantity)
|
||||
}
|
||||
|
||||
deductMix(mixId: number, ratio: number): Observable<MaterialQuantity[]> {
|
||||
const body = {id: mixId, ratio}
|
||||
return this.api.put<MaterialQuantity[]>('/inventory/deduct/mix', body)
|
||||
}
|
||||
|
||||
deduct(materialQuantities: [{material: number, quantity: number}]): Observable<MaterialQuantity[]> {
|
||||
return this.api.put<MaterialQuantity[]>('/material/inventory/deduct', materialQuantities)
|
||||
return this.api.put<MaterialQuantity[]>('/inventory/deduct', materialQuantities)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue