almost finish chart data sell
This commit is contained in:
parent
6ec2fb99d7
commit
673a962dfa
|
@ -62,6 +62,7 @@ class DashboardController extends AbstractController
|
||||||
if(array_key_exists('commodities',$params)) $setting->setCommodities($params['commodities']);
|
if(array_key_exists('commodities',$params)) $setting->setCommodities($params['commodities']);
|
||||||
if(array_key_exists('persons',$params)) $setting->setPersons($params['persons']);
|
if(array_key_exists('persons',$params)) $setting->setPersons($params['persons']);
|
||||||
if(array_key_exists('notif',$params)) $setting->setNotif($params['notif']);
|
if(array_key_exists('notif',$params)) $setting->setNotif($params['notif']);
|
||||||
|
if(array_key_exists('sellChart',$params)) $setting->setSellChart($params['sellChart']);
|
||||||
|
|
||||||
$entityManagerInterface->persist($setting);
|
$entityManagerInterface->persist($setting);
|
||||||
$entityManagerInterface->flush();
|
$entityManagerInterface->flush();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Service\Jdate;
|
||||||
use App\Service\Log;
|
use App\Service\Log;
|
||||||
use App\Service\Access;
|
use App\Service\Access;
|
||||||
use App\Service\Explore;
|
use App\Service\Explore;
|
||||||
|
@ -74,8 +75,7 @@ class SellController extends AbstractController
|
||||||
if ($item->getCommodity() && $item->getCommdityCount()) {
|
if ($item->getCommodity() && $item->getCommdityCount()) {
|
||||||
if ($acc['bid']->getProfitCalctype() == 'simple') {
|
if ($acc['bid']->getProfitCalctype() == 'simple') {
|
||||||
$profit = $profit + (($item->getCommodity()->getPriceSell() - $item->getCommodity()->getPriceSell()) * $item->getCommdityCount());
|
$profit = $profit + (($item->getCommodity()->getPriceSell() - $item->getCommodity()->getPriceSell()) * $item->getCommdityCount());
|
||||||
}
|
} elseif ($acc['bid']->getProfitCalctype() == 'lis') {
|
||||||
elseif ($acc['bid']->getProfitCalctype() == 'lis') {
|
|
||||||
$last = $entityManager->getRepository(HesabdariRow::class)->findOneBy([
|
$last = $entityManager->getRepository(HesabdariRow::class)->findOneBy([
|
||||||
'commodity' => $item->getCommodity(),
|
'commodity' => $item->getCommodity(),
|
||||||
'bs' => 0
|
'bs' => 0
|
||||||
|
@ -104,8 +104,7 @@ class SellController extends AbstractController
|
||||||
if ($count != 0) {
|
if ($count != 0) {
|
||||||
$price = $avg / $count;
|
$price = $avg / $count;
|
||||||
$profit = $profit + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount());
|
$profit = $profit + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount());
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$profit = $profit + $item->getBs();
|
$profit = $profit + $item->getBs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,8 +453,7 @@ class SellController extends AbstractController
|
||||||
if ($count != 0) {
|
if ($count != 0) {
|
||||||
$price = $avg / $count;
|
$price = $avg / $count;
|
||||||
$temp['profit'] = $temp['profit'] + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount());
|
$temp['profit'] = $temp['profit'] + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount());
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$temp['profit'] = $temp['profit'] + $item->getBs();
|
$temp['profit'] = $temp['profit'] + $item->getBs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -639,4 +637,45 @@ class SellController extends AbstractController
|
||||||
}
|
}
|
||||||
return $this->json(['id' => $pdfPid]);
|
return $this->json(['id' => $pdfPid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/api/sell/chart/data', name: 'app_sell_chart_data')]
|
||||||
|
public function app_sell_chart_data(Jdate $jdate, Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
$acc = $access->hasRole('sell');
|
||||||
|
if (!$acc)
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
// create data numbers
|
||||||
|
$dayTime = 3600 * 24;
|
||||||
|
$dayNames = [];
|
||||||
|
$daySells = [];
|
||||||
|
for ($i = 0; $i < 7; $i++) {
|
||||||
|
$dayInfo = [
|
||||||
|
$jdate->jdate('l', time() - ($i * $dayTime)),
|
||||||
|
$jdate->jdate('Y/n/d', time() - ($i * $dayTime))
|
||||||
|
];
|
||||||
|
$dayNames[] = $jdate->jdate('l', time() - ($i * $dayTime));
|
||||||
|
//get sell docs
|
||||||
|
$docs = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
'money' => $acc['money'],
|
||||||
|
'year' => $acc['year'],
|
||||||
|
'type' => 'sell',
|
||||||
|
'date' => $dayInfo[1],
|
||||||
|
]);
|
||||||
|
$bd = 0;
|
||||||
|
foreach ($docs as $doc) {
|
||||||
|
foreach ($doc->getHesabdariRows() as $row) {
|
||||||
|
if ($row->getPerson()) {
|
||||||
|
$bd += $row->getBd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$daySells[] = $bd;
|
||||||
|
}
|
||||||
|
return $this->json([
|
||||||
|
'dayNames' => $dayNames,
|
||||||
|
'daySells' => $daySells
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,9 @@ class DashboardSettings
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
private ?bool $notif = null;
|
private ?bool $notif = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?bool $sellChart = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
@ -184,4 +187,16 @@ class DashboardSettings
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isSellChart(): ?bool
|
||||||
|
{
|
||||||
|
return $this->sellChart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSellChart(?bool $sellChart): static
|
||||||
|
{
|
||||||
|
$this->sellChart = $sellChart;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -577,6 +577,7 @@ class Explore
|
||||||
'commodities' => $item->isCommodities(),
|
'commodities' => $item->isCommodities(),
|
||||||
'persons' => $item->isPersons(),
|
'persons' => $item->isPersons(),
|
||||||
'notif' => $item->isNotif(),
|
'notif' => $item->isNotif(),
|
||||||
|
'sellChart' => $item->isSellChart(),
|
||||||
];
|
];
|
||||||
if ($result['banks'] === null)
|
if ($result['banks'] === null)
|
||||||
$result['banks'] = true;
|
$result['banks'] = true;
|
||||||
|
@ -596,6 +597,8 @@ class Explore
|
||||||
$result['persons'] = true;
|
$result['persons'] = true;
|
||||||
if ($result['notif'] === null)
|
if ($result['notif'] === null)
|
||||||
$result['notif'] = true;
|
$result['notif'] = true;
|
||||||
|
if ($result['sellChart'] === null)
|
||||||
|
$result['sellChart'] = true;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue