@@ 354-382 (lines=29) @@ | ||
351 | } |
|
352 | ||
353 | // 商品別税率機能が有効の場合に税率を更新 |
|
354 | if ($this->BaseInfo->isOptionProductTaxRule()) { |
|
355 | if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) { |
|
356 | $taxRate = $row[$headerByKey['tax_rate']]; |
|
357 | $errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0])); |
|
358 | if ($errors->count() === 0) { |
|
359 | if ($ProductClassOrg->getTaxRule()) { |
|
360 | // 商品別税率の設定があれば税率を更新 |
|
361 | $ProductClassOrg->getTaxRule()->setTaxRate($taxRate); |
|
362 | } else { |
|
363 | // 商品別税率の設定がなければ新規作成 |
|
364 | $TaxRule = $this->taxRuleRepository->newTaxRule(); |
|
365 | $TaxRule->setTaxRate($taxRate); |
|
366 | $TaxRule->setApplyDate(new \DateTime()); |
|
367 | $TaxRule->setProduct($Product); |
|
368 | $TaxRule->setProductClass($ProductClassOrg); |
|
369 | $ProductClassOrg->setTaxRule($TaxRule); |
|
370 | } |
|
371 | } else { |
|
372 | $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]); |
|
373 | $this->addErrors($message); |
|
374 | } |
|
375 | } else { |
|
376 | // 税率の入力がなければ税率の設定を削除 |
|
377 | if ($ProductClassOrg->getTaxRule()) { |
|
378 | $this->taxRuleRepository->delete($ProductClassOrg->getTaxRule()); |
|
379 | $ProductClassOrg->setTaxRule(null); |
|
380 | } |
|
381 | } |
|
382 | } |
|
383 | ||
384 | if (isset($row[$headerByKey['class_category1']]) && StringUtil::isNotBlank($row[$headerByKey['class_category1']])) { |
|
385 | if (isset($row[$headerByKey['class_category2']]) && $row[$headerByKey['class_category1']] == $row[$headerByKey['class_category2']]) { |
|
@@ 479-507 (lines=29) @@ | ||
476 | } |
|
477 | ||
478 | // 商品別税率機能が有効の場合に税率を更新 |
|
479 | if ($this->BaseInfo->isOptionProductTaxRule()) { |
|
480 | if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) { |
|
481 | $taxRate = $row[$headerByKey['tax_rate']]; |
|
482 | $errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0])); |
|
483 | if ($errors->count() === 0) { |
|
484 | if ($pc->getTaxRule()) { |
|
485 | // 商品別税率の設定があれば税率を更新 |
|
486 | $pc->getTaxRule()->setTaxRate($taxRate); |
|
487 | } else { |
|
488 | // 商品別税率の設定がなければ新規作成 |
|
489 | $TaxRule = $this->taxRuleRepository->newTaxRule(); |
|
490 | $TaxRule->setTaxRate($taxRate); |
|
491 | $TaxRule->setApplyDate(new \DateTime()); |
|
492 | $TaxRule->setProduct($Product); |
|
493 | $TaxRule->setProductClass($pc); |
|
494 | $pc->setTaxRule($TaxRule); |
|
495 | } |
|
496 | } else { |
|
497 | $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]); |
|
498 | $this->addErrors($message); |
|
499 | } |
|
500 | } else { |
|
501 | // 税率の入力がなければ税率の設定を削除 |
|
502 | if ($pc->getTaxRule()) { |
|
503 | $this->taxRuleRepository->delete($pc->getTaxRule()); |
|
504 | $pc->setTaxRule(null); |
|
505 | } |
|
506 | } |
|
507 | } |
|
508 | ||
509 | $flag = true; |
|
510 | break; |