Skip to content

Commit

Permalink
Merge pull request #960 from bakaphp/development
Browse files Browse the repository at this point in the history
Release 21
  • Loading branch information
kaioken committed Feb 19, 2024
2 parents 4e08472 + 090464b commit 25c50c8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
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

0 comments on commit 25c50c8

Please sign in to comment.