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

[4.2] インボイス対応 #5382

Merged
merged 18 commits into from
Jun 23, 2022
Merged
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
1 change: 1 addition & 0 deletions html/template/default/assets/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.min.css.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions html/template/default/assets/scss/component/_7.3.cart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ Styleguide 7.3.8
font-weight:bold;
}
& &__paymentTotal{
border-top: 1px dotted #ccc;
padding: 8px 0;
text-align: right;
font-size: 14px;
Expand Down
31 changes: 31 additions & 0 deletions src/Eccube/Entity/BaseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ class BaseInfo extends \Eccube\Entity\AbstractEntity
*/
private $option_product_delivery_fee = false;

/**
* @var string|null
*
* @ORM\Column(name="invoice_registration_number", type="string", length=255, nullable=true)
*/
private $invoice_registration_number;

/**
* @var boolean
*
Expand Down Expand Up @@ -840,6 +847,30 @@ public function isOptionProductDeliveryFee()
return $this->option_product_delivery_fee;
}

/**
* Set invoiceRegistrationNumber.
*
* @param string $invoiceRegistrationNumber
*
* @return BaseInfo
*/
public function setInvoiceRegistrationNumber($invoiceRegistrationNumber)
{
$this->invoice_registration_number = $invoiceRegistrationNumber;

return $this;
}

/**
* Get invoiceRegistrationNumber.
*
* @return string|null
*/
public function getInvoiceRegistrationNumber()
{
return $this->invoice_registration_number;
}

/**
* Set optionProductTaxRule.
*
Expand Down
75 changes: 74 additions & 1 deletion src/Eccube/Entity/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Entity\Master\RoundingType;
use Eccube\Entity\Master\TaxType;
use Eccube\Service\Calculator\OrderItemCollection;
use Eccube\Service\PurchaseFlow\ItemCollection;
use Eccube\Service\TaxRuleService;

if (!class_exists('\Eccube\Entity\Order')) {
/**
Expand Down Expand Up @@ -47,7 +49,7 @@ class Order extends \Eccube\Entity\AbstractEntity implements PurchaseInterface,
/**
* 課税対象の明細を返す.
*
* @return array
* @return OrderItem[]
*/
public function getTaxableItems()
{
Expand Down Expand Up @@ -99,6 +101,50 @@ public function getTaxableTotalByTaxRate()
return $total;
}

/**
* 明細の合計額を税率ごとに集計する.
*
* 不課税, 非課税の値引明細は税率ごとに按分する.
*
* @return int[]
*/
public function getTotalByTaxRate()
{
$roundingTypes = $this->getRoundingTypeByTaxRate();
$total = [];
foreach ($this->getTaxableTotalByTaxRate() as $rate => $totalPrice) {
$total[$rate] = TaxRuleService::roundByRoundingType(
$totalPrice - abs($this->getTaxFreeDiscount()) * $totalPrice / $this->getTaxableTotal(),
$roundingTypes[$rate]->getId()
);
}

ksort($total);
return $total;
}

/**
* 税額を税率ごとに集計する.
*
* 不課税, 非課税の値引明細は税率ごとに按分する.
*
* @return int[]
*/
public function getTaxByTaxRate()
{
$roundingTypes = $this->getRoundingTypeByTaxRate();
$tax = [];
foreach ($this->getTaxableTotalByTaxRate() as $rate => $totalPrice) {
$tax[$rate] = TaxRuleService::roundByRoundingType(
($totalPrice - abs($this->getTaxFreeDiscount()) * $totalPrice / $this->getTaxableTotal()) * ($rate / (100 + $rate)),
$roundingTypes[$rate]->getId()
);
}

ksort($tax);
return $tax;
}

/**
* 課税対象の値引き明細を返す.
*
Expand Down Expand Up @@ -135,6 +181,33 @@ public function getTaxFreeDiscountItems()
});
}

/**
* 非課税・不課税の値引き額を返す.
*
* @return int|float
*/
public function getTaxFreeDiscount()
{
return array_reduce($this->getTaxFreeDiscountItems(), function ($sum, OrderItem $Item) {
return $sum += $Item->getTotalPrice();
}, 0);
}

/**
* 税率ごとの丸め規則を取得する.
*
* @return array<string, RoundingType>
*/
public function getRoundingTypeByTaxRate()
{
$roundingTypes = [];
foreach ($this->getTaxableItems() as $Item) {
$roundingTypes[$Item->getTaxRate()] = $Item->getRoundingType();
}

return $roundingTypes;
}

/**
* 複数配送かどうかの判定を行う.
*
Expand Down
9 changes: 9 additions & 0 deletions src/Eccube/Form/Type/Admin/ShopMasterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('option_favorite_product', ToggleSwitchType::class)
// 在庫切れ商品を非表示にする
->add('option_nostock_hidden', ToggleSwitchType::class)
// 適格請求書発行事業者登録番号
->add('invoice_registration_number', TextType::class, [
'required' => false,
'constraints' => [
new Assert\Length([
'max' => $this->eccubeConfig['eccube_stext_len'],
]),
],
])
// 個別税率設定
->add('option_product_tax_rule', ToggleSwitchType::class)
// ポイント設定
Expand Down
2 changes: 2 additions & 0 deletions src/Eccube/Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ common.payment_total: 'Payment Total'
common.reduced_tax_rate_symbol: '*'
common.reduced_tax_rate_messeage: '* is subject to reduced tax rate.'
common.tax_rate_target: '%rate% %'
common.tax_amount: Tax amount
common.delivery_fee: Shipping Charge
common.charge: Charges
common.discount: Discount
Expand Down Expand Up @@ -1133,6 +1134,7 @@ admin.setting.shop.shop.option_remember_me: Auto Sign-in
admin.setting.shop.shop.option_product: Product Settings
admin.setting.shop.shop.nostock_hidden: Hide out-of-stock products
admin.setting.shop.shop.option_tax: Taxes
admin.setting.shop.shop.option_invoice_registration_number: Invoice registration number
admin.setting.shop.shop.option_product_tax: Taxes by Product
admin.setting.shop.shop.option_point: Point Settings
admin.setting.shop.shop.option_point_enabled: Points
Expand Down
2 changes: 2 additions & 0 deletions src/Eccube/Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ common.payment_total: お支払い合計
common.reduced_tax_rate_symbol: ※
common.reduced_tax_rate_messeage: ※ は軽減税率対象商品です。
common.tax_rate_target: '税率 %rate% %対象'
common.tax_amount: 内消費税
common.delivery_fee: 送料
common.charge: 手数料
common.discount: 値引き
Expand Down Expand Up @@ -1133,6 +1134,7 @@ admin.setting.shop.shop.option_remember_me: 自動ログイン機能
admin.setting.shop.shop.option_product: 商品設定
admin.setting.shop.shop.nostock_hidden: 在庫切れ商品の非表示
admin.setting.shop.shop.option_tax: 税設定
admin.setting.shop.shop.option_invoice_registration_number: 適格請求書発行事業者登録番号
admin.setting.shop.shop.option_product_tax: 商品別税率機能
admin.setting.shop.shop.option_point: ポイント設定
admin.setting.shop.shop.option_point_enabled: ポイント機能
Expand Down
15 changes: 8 additions & 7 deletions src/Eccube/Resource/template/admin/Order/edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -902,13 +902,6 @@ file that was distributed with this source code.
<div class="col-auto"><span class="align-middle">{{ 'admin.order.total'|trans }}</span></div>
<div class="col-2 text-right"><span class="h4 align-middle font-weight-normal">{{ Order.taxable_total|price }}</span></div>
</div>
{% for rate, total in Order.taxable_total_by_tax_rate %}
<div class="row justify-content-end mb-3">
<div class="col-auto"><span class="align-middle">{{ 'common.tax_rate_target'|trans({ '%rate%': rate }) }}</span></div>
<div class="col-2 text-right"><span class="align-middle font-weight-normal">{{ total|price }}</span></div>
</div>
{% endfor %}
<hr>
{% for item in Order.tax_free_discount_items %}
<div class="row justify-content-end mb-3">
<div class="col-auto"><span class="align-middle">{{ item.product_name }}</span></div>
Expand All @@ -921,6 +914,14 @@ file that was distributed with this source code.
<div class="col-2 text-right"><span class="h4 align-middle font-weight-normal">{{ Order.payment_total|price }}</span></div>
</div>
<hr>
<!-- 消費税額 -->
{% for rate, total in Order.total_by_tax_rate %}
<div class="row justify-content-end mb-3">
<div class="col-auto"><span class="align-middle">{{ 'common.tax_rate_target'|trans({ '%rate%': rate }) }}</span></div>
<div class="col-2 text-right"><span class="align-middle font-weight-normal">{{ total|price }}</span>({{ 'common.tax_amount'|trans }} {{ Order.tax_by_tax_rate[rate]|price }})</div>
</div>
{% endfor %}
<hr>
<!-- 加算ポイント -->
<div class="row justify-content-end mb-3">
<div class="col-auto"><span class="align-middle">{{ 'admin.order.add_point'|trans }}</span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ file that was distributed with this source code.
<div class="card rounded border-0 mb-4">
<div class="card-header"><span>{{ 'admin.setting.shop.shop.option_tax'|trans }}</span></div>
<div id="ex-shop-tax" class="card-body">
<div class="row">
<div class="col-3">
<div class="d-inline-block" data-tooltip="true" data-placement="top" title="{{ 'tooltip.setting.shop.shop.option_product_tax'|trans }}"><span>{{ 'admin.setting.shop.shop.option_invoice_registration_number'|trans }}</span></div>
</div>
<div class="col mb-2">
{{ form_widget(form.invoice_registration_number) }}
{{ form_errors(form.invoice_registration_number) }}
</div>
</div>
<div class="row">
<div class="col-3">
<div class="d-inline-block" data-tooltip="true" data-placement="top" title="{{ 'tooltip.setting.shop.shop.option_product_tax'|trans }}"><span>{{ 'admin.setting.shop.shop.option_product_tax'|trans }}</span></div>
Expand Down
6 changes: 3 additions & 3 deletions src/Eccube/Resource/template/default/Mail/order.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ file that was distributed with this source code.
{% endif %}
<hr style="border-top: 1px dotted #8c8b8b;">
合 計:{{ Order.taxable_total|price }}<br/>
{% for rate, total in Order.taxable_total_by_tax_rate %}
({{ rate }} %対象:{{ total|price }})<br/>
{% endfor %}
{% for item in Order.tax_free_discount_items %}
<hr style="border-top: 1px dotted #8c8b8b;">
{{ item.product_name }}:{{ item.total_price|price }}<br/>
{% endfor %}
<hr style="border-top: 1px dotted #8c8b8b;">
お支払い合計:{{ Order.payment_total|price }}
{% for rate, total in Order.total_by_tax_rate %}
({{ rate }} %対象:{{ total|price }} 内消費税: {{ Order.tax_by_tax_rate[rate]|price }})<br/>
{% endfor %}
<br/>
<hr style="border-top: 3px double #8c8b8b;">
ご注文者情報<br/>
Expand Down
7 changes: 3 additions & 4 deletions src/Eccube/Resource/template/default/Mail/order.twig
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ file that was distributed with this source code.
{% endif %}
-------------------------------------------------
合 計:{{ Order.taxable_total|price }}
{% for rate, total in Order.taxable_total_by_tax_rate %}
({{ rate }} %対象:{{ total|price }})
{% endfor %}
{% for item in Order.tax_free_discount_items %}
-------------------------------------------------
{{ item.product_name }}:{{ item.total_price|price }}
{% endfor %}
============================================
お支払い合計:{{ Order.payment_total|price }}
{% for rate, total in Order.total_by_tax_rate %}
({{ rate }} %対象:{{ total|price }} 内消費税:{{ Order.tax_by_tax_rate[rate]|price }})
{% endfor %}

************************************************
 ご注文者情報
Expand Down
13 changes: 6 additions & 7 deletions src/Eccube/Resource/template/default/Mypage/history.twig
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,7 @@ file that was distributed with this source code.
<div class="ec-totalBox__total">{{ 'common.total'|trans }}<span
class="ec-totalBox__price">{{ Order.taxable_total|price }}</span><span
class="ec-totalBox__taxLabel">{{ 'common.tax_include'|trans }}</span></div>
{% for rate, total in Order.taxable_total_by_tax_rate %}
<dl class="ec-totalBox__taxRate">
<dt>{{ 'common.tax_rate_target'|trans({ '%rate%': rate }) }}</dt>
<dd>{{ total|price }}</dd>
</dl>
{% endfor %}
{% for item in Order.tax_free_discount_items %}
{% if loop.first %}<div class="ec-totalBox__total"></div>{% endif %}
<dl class="ec-totalBox__spec">
<dt>{{ item.product_name }}</dt>
<dd>{{ item.total_price|price }}</dd>
Expand All @@ -190,6 +183,12 @@ file that was distributed with this source code.
<div class="ec-totalBox__paymentTotal">{{ 'common.total'|trans }}<span
class="ec-totalBox__price">{{ Order.payment_total|price }}</span><span
class="ec-totalBox__taxLabel">{{ 'common.tax_include'|trans }}</span></div>
{% for rate, total in Order.total_by_tax_rate %}
<dl class="ec-totalBox__taxRate">
<dt>{{ 'common.tax_rate_target'|trans({ '%rate%': rate }) }}</dt>
<dd>{{ total|price }} ({{ 'common.tax_amount'|trans }} {{ Order.tax_by_tax_rate[rate]|price }})</dd>
</dl>
{% endfor %}
{% if stockOrder %}
<a href="{{ url('mypage_order', {'order_no': Order.order_no }) }}"
class="ec-blockBtn--action load-overlay" {{ csrf_token_for_anchor() }} data-method="put"
Expand Down
13 changes: 6 additions & 7 deletions src/Eccube/Resource/template/default/Shopping/confirm.twig
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,19 @@ file that was distributed with this source code.
</dl>
{% endif %}
<div class="ec-totalBox__total">{{ 'common.total'|trans }}<span class="ec-totalBox__price">{{ Order.taxable_total|price }}</span><span class="ec-totalBox__taxLabel">{{ 'common.tax_include'|trans }}</span></div>
{% for rate, total in Order.taxable_total_by_tax_rate %}
<dl class="ec-totalBox__taxRate">
<dt>{{ 'common.tax_rate_target'|trans({ '%rate%': rate }) }}</dt>
<dd>{{ total|price }}</dd>
</dl>
{% endfor %}
{% for item in Order.tax_free_discount_items %}
{% if loop.first %}<div class="ec-totalBox__total"></div>{% endif %}
<dl class="ec-totalBox__spec">
<dt>{{ item.product_name }}</dt>
<dd>{{ item.total_price|price }}</dd>
</dl>
{% endfor %}
<div class="ec-totalBox__paymentTotal">{{ 'common.payment_total'|trans }}<span class="ec-totalBox__price">{{ Order.payment_total|price }}</span><span class="ec-totalBox__taxLabel">{{ 'common.tax_include'|trans }}</span></div>
{% for rate, total in Order.total_by_tax_rate %}
<dl class="ec-totalBox__taxRate">
<dt>{{ 'common.tax_rate_target'|trans({ '%rate%': rate }) }}</dt>
<dd>{{ total|price }} ({{ 'common.tax_amount'|trans }} {{ Order.tax_by_tax_rate[rate]|price }})</dd>
</dl>
{% endfor %}
{% if BaseInfo.isOptionPoint and Order.Customer is not null %}
<div class="ec-totalBox__pointBlock">
<dl class="ec-totalBox__spec">
Expand Down
13 changes: 6 additions & 7 deletions src/Eccube/Resource/template/default/Shopping/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -404,20 +404,19 @@ file that was distributed with this source code.
</dl>
{% endif %}
<div class="ec-totalBox__total">{{ 'common.total'|trans }}<span class="ec-totalBox__price">{{ Order.taxable_total|price }}</span><span class="ec-totalBox__taxLabel">{{ 'common.tax_include'|trans }}</span></div>
{% for rate, total in Order.taxable_total_by_tax_rate %}
<dl class="ec-totalBox__taxRate">
<dt>{{ 'common.tax_rate_target'|trans({ '%rate%': rate }) }}</dt>
<dd>{{ total|price }}</dd>
</dl>
{% endfor %}
{% for item in Order.tax_free_discount_items %}
{% if loop.first %}<div class="ec-totalBox__total"></div>{% endif %}
<dl class="ec-totalBox__spec">
<dt>{{ item.product_name }}</dt>
<dd>{{ item.total_price|price }}</dd>
</dl>
{% endfor %}
<div class="ec-totalBox__paymentTotal">{{ 'common.payment_total'|trans }}<span class="ec-totalBox__price">{{ Order.payment_total|price }}</span><span class="ec-totalBox__taxLabel">{{ 'common.tax_include'|trans }}</span></div>
{% for rate, total in Order.total_by_tax_rate %}
<dl class="ec-totalBox__taxRate">
<dt>{{ 'common.tax_rate_target'|trans({ '%rate%': rate }) }}</dt>
<dd>{{ total|price }} ({{ 'common.tax_amount'|trans }} {{ Order.tax_by_tax_rate[rate]|price }})</dd>
</dl>
{% endfor %}
{% if BaseInfo.isOptionPoint and Order.Customer is not null %}
<div class="ec-totalBox__pointBlock">
<dl class="ec-totalBox__spec">
Expand Down
Loading