Skip to content

Commit

Permalink
Merge branch 'next-11782/show-the-intra-community-delivery-on-receipt…
Browse files Browse the repository at this point in the history
…s' into 'master'

NEXT-11782 - Show the intra community delivery on receipts

See merge request shopware/6/product/platform!3746
  • Loading branch information
taltholtmann committed Nov 30, 2020
2 parents 2ecdfbd + 853aa9c commit ca9445a
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Show the intra community delivery on receipts
issue: NEXT-11782
flag: FEATURE_NEXT_10559
---
# Administration
* Changed `onChangeType` method in `sw-settings-document-detail` for toggle the `DisplayNoteDelivery` checkbox.
* Changed block of `sw_settings_document_detail_content_form_field_renderer` in `module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.html.twig`.
* Added a new block `sw_settings_document_detail_content_field_additional_note_delivery` in `module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.html.twig`.
* Added new `sw-checkbox-field` and `sw-entity-multi-id-select` components in `module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.html.twig`.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import template from './sw-settings-document-detail.html.twig';
import './sw-settings-document-detail.scss';

const { Component, Mixin } = Shopware;
const { cloneDeep } = Shopware.Utils.object;
const { Criteria, EntityCollection } = Shopware.Data;

Component.register('sw-settings-document-detail', {
template,

inject: ['repositoryFactory', 'acl'],
inject: ['repositoryFactory', 'acl', 'feature'],

mixins: [
Mixin.getByName('notification'),
Expand All @@ -30,13 +31,19 @@ Component.register('sw-settings-document-detail', {

data() {
return {
documentConfig: {},
documentConfig: {
config: {
displayAdditionalNoteDelivery: false
}
},
documentConfigSalesChannelOptionsCollection: [],
documentConfigSalesChannels: [],
isLoading: false,
isSaveSuccessful: false,
salesChannels: {},
selectedType: {},
isShowDisplayNoteDelivery: false,
isShowCountriesSelect: false,
generalFormFields: [
{
name: 'pageOrientation',
Expand Down Expand Up @@ -68,6 +75,15 @@ Component.register('sw-settings-document-detail', {
label: this.$tc('sw-settings-document.detail.labelPageSize')
}
},
{
name: 'itemsPerPage',
type: 'text',
config: {
type: 'text',
label: this.$tc('sw-settings-document.detail.labelItemsPerPage')
}
},
null,
{
name: 'displayHeader',
type: 'bool',
Expand Down Expand Up @@ -116,14 +132,6 @@ Component.register('sw-settings-document-detail', {
label: this.$tc('sw-settings-document.detail.labelDisplayPrices')
}
},
{
name: 'itemsPerPage',
type: 'text',
config: {
type: 'text',
label: this.$tc('sw-settings-document.detail.labelItemsPerPage')
}
},
{
name: 'displayInCustomerAccount',
type: 'bool',
Expand Down Expand Up @@ -265,6 +273,10 @@ Component.register('sw-settings-document-detail', {
return this.documentConfig ? this.documentConfig.name : '';
},

countryRepository() {
return this.repositoryFactory.create('country');
},

documentBaseConfigCriteria() {
const criteria = new Criteria();

Expand Down Expand Up @@ -311,6 +323,17 @@ Component.register('sw-settings-document-detail', {
message: 'ESC',
appearance: 'light'
};
},

showCountriesSelect() {
if (!this.isShowDisplayNoteDelivery) {
return false;
}

const documentConfig = cloneDeep(this.documentConfig);
this.onChangeDisplayNoteDelivery();

return documentConfig.config && documentConfig.config.displayAdditionalNoteDelivery;
}
},

Expand Down Expand Up @@ -367,6 +390,13 @@ Component.register('sw-settings-document-detail', {

this.documentConfig.documentType = documentType;
this.documentConfigSalesChannels = [];
this.isShowDisplayNoteDelivery = false;

const documentTypeCurrent = cloneDeep(documentType);

if (documentTypeCurrent.technicalName === 'invoice') {
this.isShowDisplayNoteDelivery = true;
}

this.createSalesChannelSelectOptions();
const documentSalesChannelCriteria = new Criteria();
Expand Down Expand Up @@ -429,6 +459,13 @@ Component.register('sw-settings-document-detail', {
this.$router.push({ name: 'sw.settings.document.index' });
},

onChangeDisplayNoteDelivery() {
const documentConfig = cloneDeep(this.documentConfig);
if (documentConfig.config && !documentConfig.config.displayAdditionalNoteDelivery) {
this.documentConfig.config.deliveryCountries = [];
}
},

createSalesChannelSelectOptions() {
this.documentConfigSalesChannelOptionsCollection = new EntityCollection(
this.documentConfig.salesChannels.source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,40 @@
<template v-if="documentConfig.config" v-for="formField in generalFormFields">
{% block sw_settings_document_detail_content_form_field_renderer %}
<sw-form-field-renderer
v-if="formField"
:disabled="!acl.can('document.editor')"
class="sw-settings-document-detail__form-field-renderer"
v-bind="formField"
v-model="documentConfig.config[formField.name]">
</sw-form-field-renderer>
<div v-else></div>
{% endblock %}
</template>
{% endblock %}
<template v-if="feature.isActive('FEATURE_NEXT_10559')">
{% block sw_settings_document_detail_content_field_additional_note_delivery %}
<sw-checkbox-field
v-if="isShowDisplayNoteDelivery"
v-model="documentConfig.config.displayAdditionalNoteDelivery"
class="sw-settings-document-detail__field_additional_note_delivery"
:disabled="!acl.can('document.editor')"
:label="$tc('sw-settings-document.detail.labelDisplayAdditionalNoteDelivery')">
</sw-checkbox-field>
{% endblock %}

{% block sw_settings_document_detail_content_field_delivery_countries %}
<sw-entity-multi-id-select
v-if="showCountriesSelect"
v-model="documentConfig.config.deliveryCountries"
class="sw-settings-document-detail__field_delivery_countries"
:repository="countryRepository"
:disabled="!acl.can('document.editor')"
:helpText="$tc('sw-settings-document.detail.helpTextDisplayDeliveryCountries')"
:label="$tc('sw-settings-document.detail.labelDeliveryCountries')"
:placeholder="$tc('sw-settings-document.detail.placeholderDisplayDeliveryCountries')">
</sw-entity-multi-id-select>
{% endblock %}
</template>
</sw-container>
</sw-card>
{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@
.sw-settings-document-detail__company-address-checkbox {
margin-top: 22px;
}

.sw-settings-document-detail__field_delivery_countries {
grid-column: auto / span 2;

.sw-select-selection-list > li:only-child {
width: 100%;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"labelPlaceOfJurisdiction": "Geichtsstand / HBR",
"labelPlaceOfFulfillment": "Erfüllungsort",
"labelExecutiveDirector": "Geschäftsführer",
"labelDisplayAdditionalNoteDelivery": "Hinweis zur innergemeinschaftlichen Lieferung auf Belegen anzeigen",
"labelDeliveryCountries": "Innergemeinschaftliche Länder",
"placeholderDisplayDeliveryCountries": "Innergemeinschaftliche Länder durchsuchen und hinzufügen...",
"labelOptionMedia": "Firmenlogo",
"placeholderName": "Namen eingeben ...",
"buttonCancel": "Abbrechen",
Expand All @@ -61,7 +64,8 @@
"disabledSalesChannelSelect": "Wähle zunächst einen Dokumententyp.",
"disabledTypeSelect": "Der Dokumententyp von globalen Dokumenten kann nicht geändert werden.",
"labelDisplayDocumentInCustomerAccount": "Dokument in \"Mein Konto\" Bereich anzeigen",
"helpTextDisplayDocumentInCustomerAccount": "Das Dokument wird dem Shopkunden unter Bestellungen im Kundenkonto angezeigt. Nur Dokumente die an den Kunden gesendet wurden, werden im Kundenkonto angezeigt."
"helpTextDisplayDocumentInCustomerAccount": "Das Dokument wird dem Shopkunden unter Bestellungen im Kundenkonto angezeigt. Nur Dokumente die an den Kunden gesendet wurden, werden im Kundenkonto angezeigt.",
"helpTextDisplayDeliveryCountries": "Alle ausgewählten Länder erhalten einen zusätzlichen Hinweis zur Innergemeinschaftlichen Lieferung auf den Rechnungsdokumenten."
}
},
"sw-privileges": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"labelPlaceOfJurisdiction": "Place of jurisdiction / HBR",
"labelPlaceOfFulfillment": "Place of fulfillment",
"labelExecutiveDirector": "Executive director",
"labelDisplayAdditionalNoteDelivery": "Display a note relating to intra-community delivery",
"labelDeliveryCountries": "Intra-Community countries",
"placeholderDisplayDeliveryCountries": "Search and add countries to the intra-community...",
"labelOptionMedia": "Company logo",
"placeholderName": "Enter name...",
"buttonCancel": "Cancel",
Expand All @@ -61,7 +64,8 @@
"disabledSalesChannelSelect": "Choose a document type first.",
"disabledTypeSelect": "The type of global documents cannot be changed.",
"labelDisplayDocumentInCustomerAccount": "Display document in \"My account\" area",
"helpTextDisplayDocumentInCustomerAccount": "The document is displayed to the store customer under Orders in the customer account. Only documents sent to the customer are displayed in the customer account."
"helpTextDisplayDocumentInCustomerAccount": "The document is displayed to the store customer under Orders in the customer account. Only documents sent to the customer are displayed in the customer account.",
"helpTextDisplayDeliveryCountries": "All selected countries will have an additional note displayed on the invoice documents relating intra-community deliveries."
}
},
"sw-privileges": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// / <reference types="Cypress" />

describe('Documents: Test crud operations', () => {
beforeEach(() => {
cy.setToInitialState().then(() => {
cy.loginViaApi();
}).then(() => {
return cy.createProductFixture();
})
.then(() => {
cy.openInitialPage(`${Cypress.env('admin')}#/sw/settings/document/index`);
});
});

it('@settings: Create invoice document', () => {
cy.window().then((win) => {
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_10559')) {
cy.log('Skipping test of deactivated feature \'FEATURE_NEXT_10559\' flag');
return;
}

cy.get('.sw-settings-document-list__add-document').click();

// fill data into general field.
cy.get('#sw-field--documentConfig-name').type('Invoice Name');
cy.get('#sw-field--documentConfig-filenamePrefix').type('invoice_');
cy.get('#sw-field--documentConfig-filenameSuffix').type('no');
cy.get('#itemsPerPage').type('10');

// select document type by Invoice type.
cy.get('.sw-settings-document-detail__select-type')
.scrollIntoView()
.click();
cy.get('.sw-select-result-list__item-list li .sw-highlight-text')
.contains('Invoice')
.click();

// check exists additional note delivery field.
cy.get('.sw-settings-document-detail__field_additional_note_delivery input[type="checkbox"]')
.scrollIntoView()
.should('be.visible');

// select additional note delivery checkbox.
cy.get('.sw-settings-document-detail__field_additional_note_delivery input[type="checkbox"]')
.scrollIntoView()
.click();

// check exists select multi countries field.
cy.get('.sw-settings-document-detail__field_delivery_countries').should('be.visible');

// select country
cy.get('.sw-settings-document-detail__field_delivery_countries').typeMultiSelectAndCheck('Germany', {
searchTerm: 'Germany'
});

// do saving action.
cy.get('.sw-settings-document-detail__save-action').click();

// back to documents list and check exists invoice which was created successfully.
cy.get('.smart-bar__back-btn').click();
cy.get('.sw-settings-document-list-grid .sw-grid-row .sw-grid__cell-content a')
.contains('Invoice Name')
.should('be.visible');
cy.get('.sw-settings-document-list-grid .sw-grid-row .sw-document-list__column-type .sw-grid__cell-content')
.contains('Invoice')
.should('be.visible');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ const createWrapper = (customOptions, privileges = []) => {
'sw-icon': true,
'sw-card': true,
'sw-container': true,
'sw-form-field-renderer': true,
'sw-checkbox-field': true,
'sw-entity-multi-id-select': true,
'sw-media-field': { template: '<div id="sw-media-field"/>', props: ['disabled'] },
'sw-multi-select': { template: '<div id="documentSalesChannel"/>', props: ['disabled'] }
},
Expand All @@ -102,6 +105,9 @@ const createWrapper = (customOptions, privileges = []) => {
},
acl: {
can: key => (key ? privileges.includes(key) : true)
},
feature: {
isActive: () => true
}
}
};
Expand Down Expand Up @@ -224,4 +230,30 @@ describe('src/module/sw-settings-document/page/sw-settings-document-detail', ()
expect(wrapper.findAll('.sw-field').wrappers.every(field => field.props().disabled)).toEqual(true);
expect(wrapper.find('#documentSalesChannel').props().disabled).toEqual(true);
});

it('should create an invoice document with countries note delivery', async () => {
const wrapper = createWrapper({}, ['document.editor']);

await wrapper.vm.$nextTick();
await wrapper.setData({
isShowDisplayNoteDelivery: true,
documentConfig: {
config: {
displayAdditionalNoteDelivery: true
}
}
});

const displayAdditionalNoteDeliveryCheckbox = wrapper.find(
'.sw-settings-document-detail__field_additional_note_delivery'
);
const deliveryCountriesSelect = wrapper.find(
'.sw-settings-document-detail__field_delivery_countries'
);

expect(displayAdditionalNoteDeliveryCheckbox.attributes('value')).toBe('true');
expect(displayAdditionalNoteDeliveryCheckbox.attributes('label')).toBe('sw-settings-document.detail.labelDisplayAdditionalNoteDelivery');
expect(deliveryCountriesSelect.attributes('helptext')).toBe('sw-settings-document.detail.helpTextDisplayDeliveryCountries');
expect(deliveryCountriesSelect.attributes('label')).toBe('sw-settings-document.detail.labelDeliveryCountries');
});
});

0 comments on commit ca9445a

Please sign in to comment.