bug fix in years list
This commit is contained in:
parent
c9bf77eaa2
commit
f8872804bd
|
@ -251,7 +251,9 @@ class BusinessController extends AbstractController
|
|||
'bid' => $business,
|
||||
'head' => true
|
||||
]);
|
||||
|
||||
if(!$year){
|
||||
$year = new Year;
|
||||
}
|
||||
$startYearArray = explode('-', $params['year']['startShamsi']);
|
||||
if(count($startYearArray) == 1) $startYearArray = explode('/', $params['year']['startShamsi']);
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ class CommodityController extends AbstractController
|
|||
}
|
||||
$temp['count'] = $count;
|
||||
}
|
||||
|
||||
$res[] = $temp;
|
||||
}
|
||||
return $this->json($res);
|
||||
|
@ -160,6 +159,29 @@ class CommodityController extends AbstractController
|
|||
$temp['count'] = $count;
|
||||
}
|
||||
|
||||
//calculate other prices
|
||||
$pricesAll = $entityManager->getRepository(PriceList::class)->findBy([
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
foreach ($pricesAll as $list) {
|
||||
$priceDetails = $entityManager->getRepository(PriceListDetail::class)->findOneBy([
|
||||
'list' => $list,
|
||||
'commodity' => $item
|
||||
]);
|
||||
if ($priceDetails) {
|
||||
$temp['prices'][] = Explore::ExploreCommodityPriceListDetail($priceDetails);
|
||||
} else {
|
||||
$spd = new PriceListDetail;
|
||||
$spd->setList($list);
|
||||
$spd->setMoney($acc['bid']->getMoney());
|
||||
$spd->setCommodity($item);
|
||||
$spd->setPriceBuy(0);
|
||||
$spd->setPriceSell(0);
|
||||
$entityManager->persist($spd);
|
||||
$entityManager->flush();
|
||||
$temp['prices'][] = Explore::ExploreCommodityPriceListDetail($spd);
|
||||
}
|
||||
}
|
||||
$res[] = $temp;
|
||||
}
|
||||
return $this->json($res);
|
||||
|
|
|
@ -21,6 +21,18 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
|
||||
class YearController extends AbstractController
|
||||
{
|
||||
public function createDefaultYear(Business $bid,EntityManagerInterface $entityManagerInterface) : Year{
|
||||
$year = new Year();
|
||||
$year->setBid($bid);
|
||||
$year->setHead(true);
|
||||
$year->setLabel('سال مالی اول');
|
||||
$year->setStart(time());
|
||||
$year->setEnd(time() + 31563000);
|
||||
$entityManagerInterface->persist($year);
|
||||
$entityManagerInterface->flush();
|
||||
return $year;
|
||||
|
||||
}
|
||||
#[Route('/api/year/list', name: 'app_year_list')]
|
||||
public function app_year_list(Request $request, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
|
@ -30,6 +42,10 @@ class YearController extends AbstractController
|
|||
$years = $entityManager->getRepository(Year::class)->findBy([
|
||||
'bid' => $business
|
||||
]);
|
||||
if (count($years) == 0) {
|
||||
//no year created create first year
|
||||
$years = [$this->createDefaultYear($business,$entityManager)];
|
||||
}
|
||||
return $this->json($years);
|
||||
}
|
||||
|
||||
|
|
|
@ -337,9 +337,16 @@ class Explore
|
|||
'name' => $money->getName(),
|
||||
];
|
||||
}
|
||||
public static function ExploreYear(Year $year)
|
||||
public static function ExploreYear(Year | null $year)
|
||||
{
|
||||
$jdate = new Jdate();
|
||||
if(!$year){
|
||||
$year = new Year();
|
||||
$year->setHead(true);
|
||||
$year->setLabel('سال مالی اول');
|
||||
$year->setStart(time());
|
||||
$year->setEnd(time() + 31536000);
|
||||
}
|
||||
return [
|
||||
'id' => $year->getId(),
|
||||
'label' => $year->getLabel(),
|
||||
|
@ -347,8 +354,8 @@ class Explore
|
|||
'start' => $year->getStart(),
|
||||
'end' => $year->getEnd(),
|
||||
'now' => time(),
|
||||
'startShamsi' => $jdate->jdate('Y-n-d', $year->getStart()),
|
||||
'endShamsi' => $jdate->jdate('Y-n-d', $year->getEnd()),
|
||||
'startShamsi' => $jdate->jdate('Y/n/d', $year->getStart()),
|
||||
'endShamsi' => $jdate->jdate('Y/n/d', $year->getEnd()),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue