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 7 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=4000, nullable=true)
nanasess marked this conversation as resolved.
Show resolved Hide resolved
*/
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
48 changes: 48 additions & 0 deletions src/Eccube/Entity/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,42 @@ public function getTaxableTotalByTaxRate()
return $total;
}

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

ksort($total);
return $total;
}

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

ksort($tax);
return $tax;
}

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

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

/**
* 複数配送かどうかの判定を行う.
*
Expand Down
4 changes: 4 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,10 @@ 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
nanasess marked this conversation as resolved.
Show resolved Hide resolved
])
// 個別税率設定
->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/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
38 changes: 30 additions & 8 deletions src/Eccube/Service/OrderPdfService.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ protected function renderShopData()
$this->lfText(125, 75, $text, 8); // Email
}

// インボイス登録番号
if (!empty($this->baseInfoRepository->getInvoiceRegistrationNumber())) {
$text = '登録番号: '.$this->baseInfoRepository->getInvoiceRegistrationNumber();
$this->lfText(125, 79, $text, 8);
}

// user_dataにlogo.pngが配置されている場合は優先的に読み込む
$logoFile = $this->eccubeConfig->get('eccube_html_dir').'/user_data/assets/pdf/logo.png';

Expand Down Expand Up @@ -563,14 +569,6 @@ protected function renderOrderDetailData(Shipping $Shipping)
$arrOrder[$i][2] = '合計';
$arrOrder[$i][3] = $this->eccubeExtension->getPriceFilter($Order->getTaxableTotal());

foreach ($Order->getTaxableTotalByTaxRate() as $rate => $total) {
++$i;
$arrOrder[$i][0] = '';
$arrOrder[$i][1] = '';
$arrOrder[$i][2] = '('.$rate.'%対象)';
$arrOrder[$i][3] = $this->eccubeExtension->getPriceFilter($total);
}

++$i;
$arrOrder[$i][0] = '';
$arrOrder[$i][1] = '';
Expand Down Expand Up @@ -602,6 +600,30 @@ protected function renderOrderDetailData(Shipping $Shipping)

// PDFに設定する
$this->setFancyTable($this->labelCell, $arrOrder, $this->widthCell);

// インボイス対応
$this->backupFont();
$this->SetLineWidth(.3);
$this->SetFont(self::FONT_SJIS, '', 6);

$this->Cell(0, 0, '', 0, 1, 'C', 0, '');
// 行頭近くの場合、表示崩れがあるためもう一個字下げする
if (270 <= $this->GetY()) {
$this->Cell(0, 0, '', 0, 1, 'C', 0, '');
}
$width = array_reduce($this->widthCell, function ($n, $w) {
return $n + $w;
});
$this->SetX(20);
$message = '';
foreach ($Order->getTotalByTaxRate() as $rate => $total) {
$message .= '('.$rate.'%対象: ';
$message .= $this->eccubeExtension->getPriceFilter($total);
$message .= ' 内消費税: '.$this->eccubeExtension->getPriceFilter($Order->getTaxByTaxRate()[$rate]).')'.PHP_EOL;
}
$this->MultiCell($width, 4, $message, 0, 'R', 0, '');

$this->restoreFont();
}

/**
Expand Down
Loading