Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 21 #960

Merged
merged 8 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Domains/Connectors/Zoho/DataTransferObject/ZohoLead.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function __construct(
public static function fromLead(Lead $lead): self
{
$customFields = $lead->getAll();
$companyZohoMapFields = $lead->company()->first()->get(CustomFieldEnum::FIELDS_MAP->value);
$company = $lead->company()->first();
$companyZohoMapFields = $company->get(CustomFieldEnum::FIELDS_MAP->value);

$additionalFields = [];
if ($companyZohoMapFields && is_array($companyZohoMapFields)) {
Expand All @@ -38,9 +39,10 @@ public static function fromLead(Lead $lead): self
}

$people = $lead->people()->first();
$owner = (string) ($lead->owner()->first() ? $lead->company()->first()->get(CustomFieldEnum::DEFAULT_OWNER->value) : null);
$leadStatus = $lead->status()->first();
$owner = (string) ($lead->owner()->first() ? $company->get(CustomFieldEnum::DEFAULT_OWNER->value) : null);
$newLead = 'New Lead';
$status = (string) ($lead->status()->first() ? ($lead->status()->first()->get(CustomFieldEnum::ZOHO_STATUS_NAME->value) ?? $newLead) : $newLead);
$status = $leadStatus ? ($leadStatus->get(CustomFieldEnum::ZOHO_STATUS_NAME->value) ?? $newLead) : $newLead;

return new self(
$people->firstname,
Expand Down
6 changes: 6 additions & 0 deletions src/Domains/Inventory/Variants/Models/VariantsWarehouses.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,10 @@ public function getStatusHistory(): array

return $statusHistories;
}

public function getTotalProducts()
{
$total = VariantsWarehouses::where('is_deleted', 0)->sum('quantity');
return $total;
}
}
7 changes: 5 additions & 2 deletions src/Domains/Inventory/Warehouses/Models/Warehouses.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,12 @@ public function isVariantPublished(): ?Attribute
public function getTotalProducts(): int
{
if (! $totalProducts = $this->get('total_products')) {
$this->set('total_products', $this->variantsWarehouses()->count());
$this->set(
'total_products',
$this->variantsWarehouses()->first()->getTotalProducts()
);
return $this->get('total_products');
}
return $totalProducts;
return (int) $totalProducts;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,26 @@ public function saved(VariantsWarehouses $variantWarehouse): void
))->execute();
}

if ($variantWarehouse->wasChanged('quantity')) {
$variantWarehouse->warehouse->set(
'total_products',
$variantWarehouse->getTotalProducts()
);
}

if ($variantWarehouse->wasChanged('status_id')) {
(new CreateStatusHistoryAction(
StatusRepository::getById($variantWarehouse->status_id),
$variantWarehouse
))->execute();
}
}

public function created(VariantsWarehouses $variantWarehouse): void
{
$variantWarehouse->warehouse->set(
'total_products',
$variantWarehouse->getTotalProducts()
);
}
}
2 changes: 1 addition & 1 deletion src/Kanvas/Enums/AppEnums.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getValue(): mixed
self::KANVAS_APP_BRANCH_HEADER => 'X-Kanvas-Location',
self::KANVAS_APP_COMPANY_AUTH_HEADER => 'Company-Authorization', //@deprecated
self::DISPLAYNAME_LOGIN => 'displayname_login',
self::VERSION => '1.0-BETA-23',
self::VERSION => '1.0-BETA-21',
self::ANONYMOUS_USER_ID => -1
};
}
Expand Down
Loading