diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html
new file mode 100644
index 000000000..8daea7900
--- /dev/null
+++ b/modules/invoiceOut/front/descriptor-menu/index.html
@@ -0,0 +1,137 @@
+
+
+
+
+
+
+ Show invoice...
+
+
+
+
+ Show as PDF
+
+
+ Show as CSV
+
+
+
+
+
+ Send invoice...
+
+
+
+
+ Send PDF
+
+
+ Send CSV
+
+
+
+
+
+ Delete Invoice
+
+
+ Book invoice
+
+
+ {{!$ctrl.invoiceOut.hasPdf ? 'Generate PDF invoice': 'Regenerate PDF invoice'}}
+
+
+ Show CIES letter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Are you sure you want to send it?
+
+
+
+
+
+
+
+
+
+
+
+
+ Are you sure you want to send it?
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js
new file mode 100644
index 000000000..864e21ab2
--- /dev/null
+++ b/modules/invoiceOut/front/descriptor-menu/index.js
@@ -0,0 +1,111 @@
+import ngModule from '../module';
+import Section from 'salix/components/section';
+import './style.scss';
+
+class Controller extends Section {
+ constructor($element, $) {
+ super($element, $);
+ }
+
+ get invoiceOut() {
+ return this._invoiceOut;
+ }
+
+ set invoiceOut(value) {
+ this._invoiceOut = value;
+ }
+
+ loadData() {
+ const filter = {
+ include: [
+ {
+ relation: 'company',
+ scope: {
+ fields: ['id', 'code']
+ }
+ }, {
+ relation: 'client',
+ scope: {
+ fields: ['id', 'name', 'email']
+ }
+ }
+ ]
+ };
+ return this.getData(`InvoiceOuts/${this.invoiceOut.id}`, {filter})
+ .then(res => this.invoice = res.data);
+ }
+ reload() {
+ return this.loadData().then(() => {
+ if (this.parentReload)
+ this.parentReload();
+ });
+ }
+
+ cardReload() {
+ // Prevents error when not defined
+ }
+
+ deleteInvoiceOut() {
+ return this.$http.post(`InvoiceOuts/${this.invoiceOut.id}/delete`)
+ .then(() => this.$state.go('invoiceOut.index'))
+ .then(() => this.vnApp.showSuccess(this.$t('InvoiceOut deleted')))
+ .then(() => this.close());
+ }
+
+ bookInvoiceOut() {
+ return this.$http.post(`InvoiceOuts/${this.invoiceOut.ref}/book`)
+ .then(() => this.$state.reload())
+ .then(() => this.vnApp.showSuccess(this.$t('InvoiceOut booked')));
+ }
+
+ createPdfInvoice() {
+ const invoiceId = this.invoiceOut.id;
+ return this.$http.post(`InvoiceOuts/${invoiceId}/createPdf`)
+ .then(() => this.reload())
+ .then(() => {
+ const snackbarMessage = this.$t(
+ `The invoice PDF document has been regenerated`);
+ this.vnApp.showSuccess(snackbarMessage);
+ });
+ }
+
+ showCsvInvoice() {
+ this.vnReport.showCsv('invoice', {
+ recipientId: this.invoiceOut.client.id,
+ invoiceId: this.id,
+ });
+ }
+
+ sendPdfInvoice($data) {
+ return this.vnEmail.send('invoice', {
+ recipientId: this.invoiceOut.client.id,
+ recipient: $data.email,
+ invoiceId: this.id
+ });
+ }
+
+ sendCsvInvoice($data) {
+ return this.vnEmail.sendCsv('invoice', {
+ recipientId: this.invoiceOut.client.id,
+ recipient: $data.email,
+ invoiceId: this.id
+ });
+ }
+
+ showExportationLetter() {
+ this.vnReport.show('exportation', {
+ recipientId: this.invoiceOut.client.id,
+ invoiceId: this.id,
+ });
+ }
+}
+
+Controller.$inject = ['$element', '$scope'];
+
+ngModule.vnComponent('vnInvoiceOutDescriptorMenu', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ invoiceOut: '<',
+ }
+});
diff --git a/modules/invoiceOut/front/descriptor-menu/index.spec.js b/modules/invoiceOut/front/descriptor-menu/index.spec.js
new file mode 100644
index 000000000..12430d44d
--- /dev/null
+++ b/modules/invoiceOut/front/descriptor-menu/index.spec.js
@@ -0,0 +1,109 @@
+import './index';
+
+describe('vnInvoiceOutDescriptor', () => {
+ let controller;
+ let $httpBackend;
+ let $httpParamSerializer;
+ const invoiceOut = {
+ id: 1,
+ client: {id: 1101}
+ };
+
+ beforeEach(ngModule('invoiceOut'));
+
+ beforeEach(inject(($componentController, _$httpParamSerializer_, _$httpBackend_) => {
+ $httpBackend = _$httpBackend_;
+ $httpParamSerializer = _$httpParamSerializer_;
+ controller = $componentController('vnInvoiceOutDescriptor', {$element: null});
+ }));
+
+ describe('loadData()', () => {
+ it(`should perform a get query to store the invoice in data into the controller`, () => {
+ const id = 1;
+ const response = {id: 1};
+
+ $httpBackend.expectGET(`InvoiceOuts/${id}`).respond(response);
+ controller.id = id;
+ $httpBackend.flush();
+
+ expect(controller.invoiceOut).toEqual(response);
+ });
+ });
+
+ describe('createPdfInvoice()', () => {
+ it('should make a query to the createPdf() endpoint and show a success snackbar', () => {
+ jest.spyOn(controller.vnApp, 'showSuccess');
+
+ controller.invoiceOut = invoiceOut;
+
+ $httpBackend.whenGET(`InvoiceOuts/${invoiceOut.id}`).respond();
+ $httpBackend.expectPOST(`InvoiceOuts/${invoiceOut.id}/createPdf`).respond();
+ controller.createPdfInvoice();
+ $httpBackend.flush();
+
+ expect(controller.vnApp.showSuccess).toHaveBeenCalled();
+ });
+ });
+
+ describe('showCsvInvoice()', () => {
+ it('should make a query to the csv invoice download endpoint and show a message snackbar', () => {
+ jest.spyOn(window, 'open').mockReturnThis();
+
+ controller.invoiceOut = invoiceOut;
+
+ const expectedParams = {
+ invoiceId: invoiceOut.id,
+ recipientId: invoiceOut.client.id
+ };
+ const serializedParams = $httpParamSerializer(expectedParams);
+ const expectedPath = `api/csv/invoice/download?${serializedParams}`;
+ controller.showCsvInvoice();
+
+ expect(window.open).toHaveBeenCalledWith(expectedPath);
+ });
+ });
+
+ describe('sendPdfInvoice()', () => {
+ it('should make a query to the email invoice endpoint and show a message snackbar', () => {
+ jest.spyOn(controller.vnApp, 'showMessage');
+
+ controller.invoiceOut = invoiceOut;
+
+ const $data = {email: 'brucebanner@gothamcity.com'};
+ const expectedParams = {
+ invoiceId: invoiceOut.id,
+ recipient: $data.email,
+ recipientId: invoiceOut.client.id
+ };
+ const serializedParams = $httpParamSerializer(expectedParams);
+
+ $httpBackend.expectGET(`email/invoice?${serializedParams}`).respond();
+ controller.sendPdfInvoice($data);
+ $httpBackend.flush();
+
+ expect(controller.vnApp.showMessage).toHaveBeenCalled();
+ });
+ });
+
+ describe('sendCsvInvoice()', () => {
+ it('should make a query to the csv invoice send endpoint and show a message snackbar', () => {
+ jest.spyOn(controller.vnApp, 'showMessage');
+
+ controller.invoiceOut = invoiceOut;
+
+ const $data = {email: 'brucebanner@gothamcity.com'};
+ const expectedParams = {
+ invoiceId: invoiceOut.id,
+ recipient: $data.email,
+ recipientId: invoiceOut.client.id
+ };
+ const serializedParams = $httpParamSerializer(expectedParams);
+
+ $httpBackend.expectGET(`csv/invoice/send?${serializedParams}`).respond();
+ controller.sendCsvInvoice($data);
+ $httpBackend.flush();
+
+ expect(controller.vnApp.showMessage).toHaveBeenCalled();
+ });
+ });
+});
diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml
new file mode 100644
index 000000000..8a4a09db1
--- /dev/null
+++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml
@@ -0,0 +1,20 @@
+Volume exceded: Volumen excedido
+Volume: Volumen
+Client card: Ficha del cliente
+Invoice ticket list: Listado de tickets de la factura
+Show invoice...: Ver factura...
+Send invoice...: Enviar factura...
+Send PDF invoice: Enviar factura en PDF
+Send CSV invoice: Enviar factura en CSV
+Delete Invoice: Eliminar factura
+Clone Invoice: Clonar factura
+Book invoice: Asentar factura
+Generate PDF invoice: Generar PDF factura
+Show CIES letter: Ver carta CIES
+InvoiceOut deleted: Factura eliminada
+Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura?
+Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura?
+InvoiceOut booked: Factura asentada
+Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura?
+Regenerate PDF invoice: Regenerar PDF factura
+The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado
\ No newline at end of file
diff --git a/modules/invoiceOut/front/descriptor-menu/style.scss b/modules/invoiceOut/front/descriptor-menu/style.scss
new file mode 100644
index 000000000..b68301961
--- /dev/null
+++ b/modules/invoiceOut/front/descriptor-menu/style.scss
@@ -0,0 +1,24 @@
+@import "./effects";
+@import "variables";
+
+vn-invoice-out-descriptor-menu {
+ & > vn-icon-button[icon="more_vert"] {
+ display: flex;
+ min-width: 45px;
+ height: 45px;
+ box-sizing: border-box;
+ align-items: center;
+ justify-content: center;
+ }
+ & > vn-icon-button[icon="more_vert"] {
+ @extend %clickable;
+ color: inherit;
+
+ & > vn-icon {
+ padding: 10px;
+ }
+ vn-icon {
+ font-size: 1.75rem;
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/invoiceOut/front/descriptor/index.html b/modules/invoiceOut/front/descriptor/index.html
index d5522f6a9..9c3685338 100644
--- a/modules/invoiceOut/front/descriptor/index.html
+++ b/modules/invoiceOut/front/descriptor/index.html
@@ -1,81 +1,12 @@
-
-
- Show invoice...
-
-
-
-
- Show as PDF
-
-
- Show as CSV
-
-
-
-
-
- Send invoice...
-
-
-
-
- Send PDF
-
-
- Send CSV
-
-
-
-
-
- Delete Invoice
-
-
- Book invoice
-
-
- {{!$ctrl.invoiceOut.hasPdf ? 'Generate PDF invoice': 'Regenerate PDF invoice'}}
-
-
- Show CIES letter
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Are you sure you want to send it?
-
-
-
-
-
-
-
-
-
-
-
-
- Are you sure you want to send it?
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/modules/invoiceOut/front/descriptor/index.js b/modules/invoiceOut/front/descriptor/index.js
index f4f8c07bd..7eeb85ea6 100644
--- a/modules/invoiceOut/front/descriptor/index.js
+++ b/modules/invoiceOut/front/descriptor/index.js
@@ -41,70 +41,6 @@ class Controller extends Descriptor {
return this.getData(`InvoiceOuts/${this.id}`, {filter})
.then(res => this.entity = res.data);
}
-
- reload() {
- return this.loadData().then(() => {
- if (this.cardReload)
- this.cardReload();
- });
- }
-
- cardReload() {
- // Prevents error when not defined
- }
-
- deleteInvoiceOut() {
- return this.$http.post(`InvoiceOuts/${this.id}/delete`)
- .then(() => this.$state.go('invoiceOut.index'))
- .then(() => this.vnApp.showSuccess(this.$t('InvoiceOut deleted')));
- }
-
- bookInvoiceOut() {
- return this.$http.post(`InvoiceOuts/${this.invoiceOut.ref}/book`)
- .then(() => this.$state.reload())
- .then(() => this.vnApp.showSuccess(this.$t('InvoiceOut booked')));
- }
-
- createPdfInvoice() {
- const invoiceId = this.invoiceOut.id;
- return this.$http.post(`InvoiceOuts/${invoiceId}/createPdf`)
- .then(() => this.reload())
- .then(() => {
- const snackbarMessage = this.$t(
- `The invoice PDF document has been regenerated`);
- this.vnApp.showSuccess(snackbarMessage);
- });
- }
-
- showCsvInvoice() {
- this.vnReport.showCsv('invoice', {
- recipientId: this.invoiceOut.client.id,
- invoiceId: this.id,
- });
- }
-
- sendPdfInvoice($data) {
- return this.vnEmail.send('invoice', {
- recipientId: this.invoiceOut.client.id,
- recipient: $data.email,
- invoiceId: this.id
- });
- }
-
- sendCsvInvoice($data) {
- return this.vnEmail.sendCsv('invoice', {
- recipientId: this.invoiceOut.client.id,
- recipient: $data.email,
- invoiceId: this.id
- });
- }
-
- showExportationLetter() {
- this.vnReport.show('exportation', {
- recipientId: this.invoiceOut.client.id,
- invoiceId: this.id,
- });
- }
}
ngModule.vnComponent('vnInvoiceOutDescriptor', {
@@ -112,6 +48,5 @@ ngModule.vnComponent('vnInvoiceOutDescriptor', {
controller: Controller,
bindings: {
invoiceOut: '<',
- cardReload: '&'
}
});
diff --git a/modules/invoiceOut/front/index.js b/modules/invoiceOut/front/index.js
index 3bb6d54d2..0307b2b4b 100644
--- a/modules/invoiceOut/front/index.js
+++ b/modules/invoiceOut/front/index.js
@@ -7,5 +7,6 @@ import './summary';
import './card';
import './descriptor';
import './descriptor-popover';
+import './descriptor-menu';
import './index/manual';
import './index/global-invoicing';
diff --git a/modules/invoiceOut/front/summary/index.html b/modules/invoiceOut/front/summary/index.html
index 6a117052e..a0d050efd 100644
--- a/modules/invoiceOut/front/summary/index.html
+++ b/modules/invoiceOut/front/summary/index.html
@@ -13,6 +13,10 @@
{{$ctrl.summary.invoiceOut.ref}} - {{$ctrl.summary.invoiceOut.client.socialName}}
+