improved new features
This commit is contained in:
@@ -55,7 +55,9 @@ class WarehouseArticleController extends TTCrud {
|
||||
public static function updateCheapestPurchasePrice(int $id): void {
|
||||
$article = WarehouseArticleModel::get($id);
|
||||
if (!$article instanceof WarehouseArticleModel) throw new Exception("Invalid article type");
|
||||
if (($distributor = WarehouseArticleDistributorModel::getAll(['articleId' => $id], 1, 0, ['key' => 'purchasePrice', 'order' => 'ASC'])) && $article->cheapestPurchasePrice != $distributor[0]->purchasePrice)
|
||||
$distributor = WarehouseArticleDistributorModel::getAll(['articleId' => $id], 1, 0, ['key' => 'purchasePrice', 'order' => 'ASC']);
|
||||
if (count($distributor) == 0) WarehouseArticleModel::update(array_merge(get_object_vars($article), ['cheapestPurchasePrice' => null]));
|
||||
else if ($article->cheapestPurchasePrice != $distributor[0]->purchasePrice)
|
||||
WarehouseArticleModel::update(array_merge(get_object_vars($article), ['cheapestPurchasePrice' => $distributor[0]->purchasePrice]));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class WarehouseArticleDistributorController extends TTCrud {
|
||||
protected function checkExistingDistributorEntry($postData): bool {
|
||||
if (isset($postData['id'])) {
|
||||
$count = WarehouseArticleDistributorModel::count(['articleId' => $postData['articleId'],
|
||||
'distributorId' => $postData['articlePriceTypeId'],
|
||||
'distributorId' => $postData['distributorId'],
|
||||
'id' => $postData['id']]);
|
||||
|
||||
if ($count > 0) return true;
|
||||
@@ -66,6 +66,11 @@ class WarehouseArticleDistributorController extends TTCrud {
|
||||
WarehouseArticleController::updateSellPrices($postData['articleId']);
|
||||
}
|
||||
|
||||
protected function afterDelete($postData) {
|
||||
WarehouseArticleController::updateCheapestPurchasePrice($postData);
|
||||
WarehouseArticleController::updateSellPrices($postData);
|
||||
}
|
||||
|
||||
protected function getHistoryAction() {
|
||||
$history = WarehouseHistoryModel::getByRowId($this->request->id, $this->mod);
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ class WarehouseShippingNoteController extends TTCrud {
|
||||
protected array $defaultOrder = ['key' => 'create', 'order' => 'DESC'];
|
||||
|
||||
protected array $additionalJSVariables = ['WAREHOUSE_ADMIN' => true];
|
||||
protected array $additionalJS = ['js/pages/WarehouseArticle/WarehouseArticleModal.js'];
|
||||
protected array $additionalHead = ['<link rel="manifest" href="/assets/pwa/shipping-note-manifest.json">'];
|
||||
|
||||
protected array $infoMessages = ['create' => 'Lieferschein wurde erstellt.',
|
||||
|
||||
Reference in New Issue
Block a user