Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/4.2' into improve/datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Jun 24, 2022
2 parents aef125d + 04f5a37 commit abbb7c4
Show file tree
Hide file tree
Showing 22 changed files with 274 additions and 71 deletions.
2 changes: 1 addition & 1 deletion app/config/eccube/packages/eccube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parameters:
env(ECCUBE_COOKIE_PATH): '/'
env(ECCUBE_COOKIE_LIFETIME): '0'
env(ECCUBE_GC_MAXLIFETIME): '1440'
env(ECCUBE_PACKAGE_API_URL): 'https://package-api-c2.ec-cube.net'
env(ECCUBE_PACKAGE_API_URL): 'https://package-api-c2.ec-cube.net/v42'
env(ECCUBE_OWNERS_STORE_URL): 'https://www.ec-cube.net'
env(ECCUBE_MAINTENANCE_FILE_PATH): '%kernel.project_dir%/.maintenance'
env(ECCUBE_2FA_ENABLED): '1'
Expand Down
1 change: 1 addition & 0 deletions html/template/default/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11825,6 +11825,7 @@ Styleguide 7.3.8
font-size: 14px;
font-weight: bold; }
.ec-totalBox .ec-totalBox__paymentTotal {
border-top: 1px dotted #ccc;
padding: 8px 0;
text-align: right;
font-size: 14px;
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,21 @@ file that was distributed with this source code.
<script>
function refreshCaptchaImage() {
$('#captcha_image').attr('src', "{{ eccube_config.eccube_package_api_url }}/captcha" + '?' + new Date().getTime())
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var captcha = document.getElementById("captcha_image");
var url = window.URL || window.webkitURL;
captcha.src = url.createObjectURL(this.response);
var captcha_id = document.getElementById("captcha_id");
captcha_id.value = this.getResponseHeader('x-eccube-captcha-id');
}
}
xhr.open('GET', '{{ eccube_config.eccube_package_api_url }}/captcha' + '?' + new Date().getTime());
xhr.responseType = 'blob';
xhr.send();
}
$('#captcha').on('show.bs.modal', function() {
Expand All @@ -45,13 +59,11 @@ file that was distributed with this source code.
dataType: 'json',
cache: false,
data: {
"captcha_id": $('#captcha_id').val(),
"captcha": $('#captcha_text').val(),
"eccube_url": '{{ eccubeUrl }}',
"eccube_version": "{{ constant('Eccube\\Common\\Constant::VERSION') }}",
"eccube_shop_name": "{{ eccubeShopName }}"
},
xhrFields: {
withCredentials: true
}
}).done(function(data) {
$('#captcha').modal('hide');
Expand Down Expand Up @@ -164,6 +176,7 @@ file that was distributed with this source code.
<img id="captcha_image" class="mb-2" src="#">
<button id="captcha-refresh" type="button" class="btn btn-default"><i class="fa fa-refresh" aria-hidden="true"></i></button>
<input type="text" id="captcha_text" value="" class="form-control" placeholder="{{ 'admin.store.setting.captcha_message'|trans }}"/>
<input type="hidden" id="captcha_id" value=""/>
<span id="captcha_error" class="invalid-feedback" style="display: none">
<span class="mb-0 d-block">
<span class="initialism form-error-icon badge badge-danger">{{ 'admin.store.setting.captcha_error'|trans }}</span> <span class="form-error-message">{{ 'admin.store.setting.invalid_captcha'|trans }}</span>
Expand All @@ -178,4 +191,4 @@ file that was distributed with this source code.
</div>
</form>
</div>
{% endblock %}
{% endblock %}
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
Loading

0 comments on commit abbb7c4

Please sign in to comment.