@@ 343-371 (lines=29) @@ | ||
340 | } |
|
341 | ||
342 | // 商品別税率機能が有効の場合に税率を更新 |
|
343 | if ($this->BaseInfo->isOptionProductTaxRule()) { |
|
344 | if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) { |
|
345 | $taxRate = $row[$headerByKey['tax_rate']]; |
|
346 | $errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0])); |
|
347 | if ($errors->count() === 0) { |
|
348 | if ($ProductClassOrg->getTaxRule()) { |
|
349 | // 商品別税率の設定があれば税率を更新 |
|
350 | $ProductClassOrg->getTaxRule()->setTaxRate($taxRate); |
|
351 | } else { |
|
352 | // 商品別税率の設定がなければ新規作成 |
|
353 | $TaxRule = $this->taxRuleRepository->newTaxRule(); |
|
354 | $TaxRule->setTaxRate($taxRate); |
|
355 | $TaxRule->setApplyDate(new \DateTime()); |
|
356 | $TaxRule->setProduct($Product); |
|
357 | $TaxRule->setProductClass($ProductClassOrg); |
|
358 | $ProductClassOrg->setTaxRule($TaxRule); |
|
359 | } |
|
360 | } else { |
|
361 | $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]); |
|
362 | $this->addErrors($message); |
|
363 | } |
|
364 | } else { |
|
365 | // 税率の入力がなければ税率の設定を削除 |
|
366 | if ($ProductClassOrg->getTaxRule()) { |
|
367 | $this->taxRuleRepository->delete($ProductClassOrg->getTaxRule()); |
|
368 | $ProductClassOrg->setTaxRule(null); |
|
369 | } |
|
370 | } |
|
371 | } |
|
372 | ||
373 | if (isset($row[$headerByKey['class_category1']]) && StringUtil::isNotBlank($row[$headerByKey['class_category1']])) { |
|
374 | if (isset($row[$headerByKey['class_category2']]) && $row[$headerByKey['class_category1']] == $row[$headerByKey['class_category2']]) { |
|
@@ 468-496 (lines=29) @@ | ||
465 | } |
|
466 | ||
467 | // 商品別税率機能が有効の場合に税率を更新 |
|
468 | if ($this->BaseInfo->isOptionProductTaxRule()) { |
|
469 | if (isset($row[$headerByKey['tax_rate']]) && StringUtil::isNotBlank($row[$headerByKey['tax_rate']])) { |
|
470 | $taxRate = $row[$headerByKey['tax_rate']]; |
|
471 | $errors = $this->validator->validate($taxRate, new GreaterThanOrEqual(['value' => 0])); |
|
472 | if ($errors->count() === 0) { |
|
473 | if ($pc->getTaxRule()) { |
|
474 | // 商品別税率の設定があれば税率を更新 |
|
475 | $pc->getTaxRule()->setTaxRate($taxRate); |
|
476 | } else { |
|
477 | // 商品別税率の設定がなければ新規作成 |
|
478 | $TaxRule = $this->taxRuleRepository->newTaxRule(); |
|
479 | $TaxRule->setTaxRate($taxRate); |
|
480 | $TaxRule->setApplyDate(new \DateTime()); |
|
481 | $TaxRule->setProduct($Product); |
|
482 | $TaxRule->setProductClass($pc); |
|
483 | $pc->setTaxRule($TaxRule); |
|
484 | } |
|
485 | } else { |
|
486 | $message = trans('admin.common.csv_invalid_greater_than_zero', ['%line%' => $line, '%name%' => $headerByKey['tax_rate']]); |
|
487 | $this->addErrors($message); |
|
488 | } |
|
489 | } else { |
|
490 | // 税率の入力がなければ税率の設定を削除 |
|
491 | if ($pc->getTaxRule()) { |
|
492 | $this->taxRuleRepository->delete($pc->getTaxRule()); |
|
493 | $pc->setTaxRule(null); |
|
494 | } |
|
495 | } |
|
496 | } |
|
497 | ||
498 | $flag = true; |
|
499 | break; |