diff --git a/changelog/_unreleased/2020-11-10-show-the-intra-community-delivery-on-receipts.md b/changelog/_unreleased/2020-11-10-show-the-intra-community-delivery-on-receipts.md new file mode 100644 index 00000000000..83da20ca257 --- /dev/null +++ b/changelog/_unreleased/2020-11-10-show-the-intra-community-delivery-on-receipts.md @@ -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`. diff --git a/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/index.js b/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/index.js index 51631295347..a3862f71238 100644 --- a/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/index.js +++ b/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/index.js @@ -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'), @@ -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', @@ -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', @@ -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', @@ -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(); @@ -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; } }, @@ -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(); @@ -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, diff --git a/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.html.twig b/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.html.twig index eb3cd12f573..01956c5c5a1 100644 --- a/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.html.twig +++ b/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.html.twig @@ -81,14 +81,40 @@ {% endblock %} + {% endblock %} diff --git a/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.scss b/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.scss index 179a2835102..73f0a1e1fa1 100644 --- a/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.scss +++ b/src/Administration/Resources/app/administration/src/module/sw-settings-document/page/sw-settings-document-detail/sw-settings-document-detail.scss @@ -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%; + } + } } diff --git a/src/Administration/Resources/app/administration/src/module/sw-settings-document/snippet/de-DE.json b/src/Administration/Resources/app/administration/src/module/sw-settings-document/snippet/de-DE.json index 1fb129a95ee..f534c1c5e96 100644 --- a/src/Administration/Resources/app/administration/src/module/sw-settings-document/snippet/de-DE.json +++ b/src/Administration/Resources/app/administration/src/module/sw-settings-document/snippet/de-DE.json @@ -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", @@ -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": { diff --git a/src/Administration/Resources/app/administration/src/module/sw-settings-document/snippet/en-GB.json b/src/Administration/Resources/app/administration/src/module/sw-settings-document/snippet/en-GB.json index 3a71590d416..cee6cf50a00 100644 --- a/src/Administration/Resources/app/administration/src/module/sw-settings-document/snippet/en-GB.json +++ b/src/Administration/Resources/app/administration/src/module/sw-settings-document/snippet/en-GB.json @@ -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", @@ -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": { diff --git a/src/Administration/Resources/app/administration/test/e2e/cypress/integration/settings/sw-settings-document/crud.spec.js b/src/Administration/Resources/app/administration/test/e2e/cypress/integration/settings/sw-settings-document/crud.spec.js new file mode 100644 index 00000000000..512a27a5869 --- /dev/null +++ b/src/Administration/Resources/app/administration/test/e2e/cypress/integration/settings/sw-settings-document/crud.spec.js @@ -0,0 +1,69 @@ +// / + +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'); + }); + }); +}); diff --git a/src/Administration/Resources/app/administration/test/module/sw-settings-document/sw-settings-document-detail-page.spec.js b/src/Administration/Resources/app/administration/test/module/sw-settings-document/sw-settings-document-detail-page.spec.js index 4e1fdea8d1b..e7bc14c83e4 100644 --- a/src/Administration/Resources/app/administration/test/module/sw-settings-document/sw-settings-document-detail-page.spec.js +++ b/src/Administration/Resources/app/administration/test/module/sw-settings-document/sw-settings-document-detail-page.spec.js @@ -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: '
', props: ['disabled'] }, 'sw-multi-select': { template: '
', props: ['disabled'] } }, @@ -102,6 +105,9 @@ const createWrapper = (customOptions, privileges = []) => { }, acl: { can: key => (key ? privileges.includes(key) : true) + }, + feature: { + isActive: () => true } } }; @@ -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'); + }); });