fixed some price handling aswell as tt-autocomplete and tt-table excel export always showing

This commit is contained in:
2024-07-25 08:59:41 +02:00
parent 813b0b4524
commit e4427c9eac
8 changed files with 106 additions and 74 deletions
@@ -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() {