diff --git a/app/src/main/java/com/sw/inbound/viewmodel/SelfProcurementViewModel.kt b/app/src/main/java/com/sw/inbound/viewmodel/SelfProcurementViewModel.kt index 0576b58..b246eea 100644 --- a/app/src/main/java/com/sw/inbound/viewmodel/SelfProcurementViewModel.kt +++ b/app/src/main/java/com/sw/inbound/viewmodel/SelfProcurementViewModel.kt @@ -193,13 +193,6 @@ class SelfProcurementViewModel @Inject constructor( } } - fun updateAddPurchaseUnitDialog(show: Boolean) { - _showAddPurchaseUnitDialog.value = show - if (!show) { - _goodsAddUnitParam.value = GoodsPurchaseUnitParam() - } - } - fun updateSelectedItem(purchaseOrder: PurchaseWarehouseParam?) { if (purchaseOrder != null) { if (purchaseOrder.goodsCount != 0.0) { @@ -388,13 +381,20 @@ class SelfProcurementViewModel @Inject constructor( } } + fun updateAddPurchaseUnitDialog(show: Boolean) { + _showAddPurchaseUnitDialog.value = show + if (show) { + val hasUnitId = GlobalData.unitTypeList.any { it.id == _selectedItem.value?.kcUnitId } + _dropdownTextChange.value = !hasUnitId + } else { + _goodsAddUnitParam.value = GoodsPurchaseUnitParam() + } + } + fun updateGoodsPurchaseUnit(goodsPurchaseUnitParam: GoodsPurchaseUnitParam?) { if (goodsPurchaseUnitParam == null) { - _dropdownTextChange.value = true _goodsAddUnitParam.value = GoodsPurchaseUnitParam() } else { - val hasUnitId = GlobalData.unitTypeList.any { it.id == goodsPurchaseUnitParam.unitId } - _dropdownTextChange.value = !hasUnitId _goodsAddUnitParam.value = goodsPurchaseUnitParam } }