fixed some price handling aswell as tt-autocomplete and tt-table excel export always showing
This commit is contained in:
@@ -20,25 +20,33 @@ class WarehouseArticleDistributorController extends TTCrud {
|
||||
'delete' => 'Lieferanteintrag wurde gelöscht',
|
||||
'noChanges' => 'Keine Änderungen',];
|
||||
|
||||
protected function checkExistingDistributorEntry($postData): bool {
|
||||
$count = WarehouseArticleDistributorModel::count(['articleId' => $postData['articleId'],
|
||||
'distributorId' => $postData['distributorId']]);
|
||||
|
||||
if ($count > 0) {
|
||||
self::returnJson(['success' => false,
|
||||
'message' => 'Es existiert bereits ein Eintrag mit dieser Artikelnummer und diesem Lieferanten.']);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function beforeCreate($postData): bool {
|
||||
return $this->checkExistingDistributorEntry($postData);
|
||||
}
|
||||
|
||||
protected function checkExistingDistributorEntry($postData): bool {
|
||||
if (isset($postData['id'])) {
|
||||
$count = WarehouseArticleDistributorModel::count(['articleId' => $postData['articleId'],
|
||||
'distributorId' => $postData['articlePriceTypeId'],
|
||||
'id' => $postData['id']]);
|
||||
|
||||
if ($count > 0) return true;
|
||||
} else {
|
||||
$count = WarehouseArticleDistributorModel::count(['articleId' => $postData['articleId'],
|
||||
'distributorId' => $postData['distributorId']]);
|
||||
if ($count > 0) {
|
||||
self::returnJson(['success' => false,
|
||||
'message' => 'Es existiert bereits ein Eintrag mit dieser Artikelnummer und diesem Lieferanten.']);
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function afterCreate($postData) {
|
||||
WarehouseArticleController::updateCheapestPurchasePrice($postData['articleId']);
|
||||
WarehouseArticleController::updateSellPrices($postData['articleId']);
|
||||
}
|
||||
|
||||
protected function beforeUpdate($postData): bool {
|
||||
@@ -55,6 +63,7 @@ class WarehouseArticleDistributorController extends TTCrud {
|
||||
|
||||
protected function afterUpdate($postData) {
|
||||
WarehouseArticleController::updateCheapestPurchasePrice($postData['articleId']);
|
||||
WarehouseArticleController::updateSellPrices($postData['articleId']);
|
||||
}
|
||||
|
||||
protected function getHistoryAction() {
|
||||
|
||||
Reference in New Issue
Block a user