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

商品一覧及び商品詳細で個別税率が取得できないのを修正 #73

Open
wants to merge 2 commits into
base: 3.0
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/Eccube/Repository/TaxRuleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public function getByRule($Product = null, $ProductClass = null, $Pref = null, $
$Pref = $Customer->getPref();
$Country = $Customer->getCountry();
}
// Product が null の場合は正常に税率取得できないため, Product を取得し直す
if ($ProductClass instanceof \Eccube\Entity\ProductClass && $Product === null) {
$this->getEntityManager()->refresh($ProductClass);
$Product = $ProductClass->getProduct();
}

// 商品単位税率設定がOFFの場合
/** @var $BaseInfo \Eccube\Entity\BaseInfo */
Expand Down
34 changes: 34 additions & 0 deletions tests/Eccube/Tests/Repository/TaxRuleRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,38 @@ public function testShipmentItem()
}
}
}

/**
* @see https://github.com/EC-CUBE/ec-cube/issues/2251
* @see https://github.com/EC-CUBE/ec-cube/pull/4310
*/
public function testGetByRuleWithProductIsNull()
{
$this->BaseInfo->setOptionProductTaxRule(1); // 商品別税率ON
$this->app['orm.em']->flush();
$oneDayBefore = new \DateTime('-1 days');

$ProductClasses = $this->Product->getProductClasses();
$ProductClass = $ProductClasses[1];
$this->TaxRule2
->setApplyDate($oneDayBefore)
->setProduct($ProductClass->getProduct())
->setProductClass($ProductClass);
$this->TaxRule3
->setApplyDate($oneDayBefore);

$this->app['orm.em']->flush();

$this->app['eccube.repository.tax_rule']->clearCache();
$TaxRule = $this->app['eccube.repository.tax_rule']->getByRule(
null, // Product
$ProductClass, // ProductClass
null, // Pref
null // Country
);

$this->expected = $this->TaxRule2->getId();
$this->actual = $TaxRule->getId();
$this->verify('Product に null が設定されていても対象の ProductClass の税率が取得できる');
}
}