Redirect invoice out to Lilium #2807

Merged
jon merged 5 commits from InvoiceOut_Migration into dev 2024-09-05 08:32:57 +00:00
34 changed files with 9 additions and 1539 deletions

View File

@ -1,44 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('InvoiceOut summary path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'invoiceOut');
await page.accessToSearchResult('T1111111');
});
afterAll(async() => {
await browser.close();
});
it('should reach the summary section', async() => {
await page.waitForState('invoiceOut.card.summary');
});
it('should contain the company from which the invoice is emited', async() => {
const result = await page.waitToGetProperty(selectors.invoiceOutSummary.company, 'innerText');
expect(result).toEqual('Company VNL');
});
it('should contain the tax breakdown', async() => {
const firstTax = await page.waitToGetProperty(selectors.invoiceOutSummary.taxOne, 'innerText');
const secondTax = await page.waitToGetProperty(selectors.invoiceOutSummary.taxTwo, 'innerText');
expect(firstTax).toContain('10%');
expect(secondTax).toContain('21%');
});
it('should contain the tickets info', async() => {
const firstTicket = await page.waitToGetProperty(selectors.invoiceOutSummary.ticketOne, 'innerText');
const secondTicket = await page.waitToGetProperty(selectors.invoiceOutSummary.ticketTwo, 'innerText');
expect(firstTicket).toContain('Bat cave');
expect(secondTicket).toContain('Bat cave');
});
});

View File

@ -1,137 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('InvoiceOut descriptor path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'ticket');
});
afterAll(async() => {
await browser.close();
});
describe('as Administrative', () => {
it('should search for tickets with an specific invoiceOut', async() => {
await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton);
await page.clearInput(selectors.ticketsIndex.advancedSearchDaysOnward);
await page.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222');
await page.waitToClick(selectors.ticketsIndex.advancedSearchButton);
await page.waitForState('ticket.card.summary');
});
it('should navigate to the invoiceOut index', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.invoiceOutButton);
await page.waitForSelector(selectors.invoiceOutIndex.topbarSearch);
await page.waitForState('invoiceOut.index');
});
it(`should click on the search result to access to the invoiceOut summary`, async() => {
await page.accessToSearchResult('T2222222');
await page.waitForState('invoiceOut.card.summary');
});
it('should delete the invoiceOut using the descriptor more menu', async() => {
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut);
await page.waitToClick(selectors.invoiceOutDescriptor.acceptDeleteButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('InvoiceOut deleted');
});
it('should have been relocated to the invoiceOut index', async() => {
await page.waitForState('invoiceOut.index');
});
it(`should search for the deleted invouceOut to find no results`, async() => {
await page.doSearch('T2222222');
const nResults = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(nResults).toEqual(0);
});
it('should navigate to the ticket index', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
await page.waitForState('ticket.index');
});
it('should search now for tickets with an specific invoiceOut to find no results', async() => {
await page.doSearch('T2222222');
const nResults = await page.countElement(selectors.ticketsIndex.searchResult);
expect(nResults).toEqual(0);
});
it('should now navigate to the invoiceOut index', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.invoiceOutButton);
await page.waitForState('invoiceOut.index');
});
it(`should search and access to the invoiceOut summary`, async() => {
await page.accessToSearchResult('T1111111');
await page.waitForState('invoiceOut.card.summary');
});
it(`should check the invoiceOut is booked in the summary data`, async() => {
await page.waitForTextInElement(selectors.invoiceOutSummary.bookedLabel, '/');
const result = await page.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');
expect(result.length).toBeGreaterThan(1);
});
it('should re-book the invoiceOut using the descriptor more menu', async() => {
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut);
await page.waitToClick(selectors.invoiceOutDescriptor.acceptBookingButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('InvoiceOut booked');
});
it(`should check the invoiceOut booked in the summary data`, async() => {
let today = Date.vnNew();
let day = today.getDate();
if (day < 10) day = `0${day}`;
let month = (today.getMonth() + 1);
if (month < 10) month = `0${month}`;
let expectedDate = `${day}/${month}/${today.getFullYear()}`;
await page.waitForContentLoaded();
const result = await page
.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');
expect(result).toEqual(expectedDate);
});
});
describe('as salesPerson', () => {
it(`should log in as salesPerson then go to the target invoiceOut summary`, async() => {
await page.loginAndModule('salesPerson', 'invoiceOut');
await page.accessToSearchResult('A1111111');
});
it(`should check the salesPerson role doens't see the book option in the more menu`, async() => {
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.waitForSelector(selectors.invoiceOutDescriptor.moreMenuShowInvoiceOutPdf);
await page.waitForSelector(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut, {hidden: true});
});
it(`should check the salesPerson role doens't see the delete option in the more menu`, async() => {
await page.waitForSelector(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut, {hidden: true});
});
});
});

View File

@ -1,53 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('InvoiceOut manual invoice path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'invoiceOut');
});
afterAll(async() => {
await browser.close();
});
it('should create an invoice from a ticket', async() => {
await page.waitToClick(selectors.invoiceOutIndex.createInvoice);
await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm);
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTicket, '15');
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional');
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national');
await page.waitToClick(selectors.invoiceOutIndex.saveInvoice);
const message = await page.waitForSnackbar();
await page.waitForState('invoiceOut.card.summary');
expect(message.text).toContain('Data saved!');
});
it(`should create another invoice from a client`, async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.invoiceOutButton);
await page.waitForSelector(selectors.invoiceOutIndex.topbarSearch);
await page.waitForState('invoiceOut.index');
await page.waitToClick(selectors.invoiceOutIndex.createInvoice);
await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm);
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceClient, 'Petter Parker');
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional');
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national');
await page.waitToClick(selectors.invoiceOutIndex.saveInvoice);
const message = await page.waitForSnackbar();
await page.waitForState('invoiceOut.card.summary');
expect(message.text).toContain('Data saved!');
});
});

View File

@ -1,39 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('InvoiceOut global invoice path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'invoiceOut');
await page.waitToClick('[icon="search"]');
await page.waitForTimeout(1000); // index search needs time to return results
});
afterAll(async() => {
await browser.close();
});
let invoicesBeforeOneClient;
let now = Date.vnNew();
it('should count the amount of invoices listed before globla invoces are made', async() => {
invoicesBeforeOneClient = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(invoicesBeforeOneClient).toBeGreaterThanOrEqual(4);
});
it('should create a global invoice for charles xavier today', async() => {
await page.accessToSection('invoiceOut.global-invoicing');
await page.waitToClick(selectors.invoiceOutGlobalInvoicing.oneClient);
await page.autocompleteSearch(selectors.invoiceOutGlobalInvoicing.clientId, 'Charles Xavier');
await page.pickDate(selectors.invoiceOutGlobalInvoicing.invoiceDate, now);
await page.pickDate(selectors.invoiceOutGlobalInvoicing.maxShipped, now);
await page.autocompleteSearch(selectors.invoiceOutGlobalInvoicing.printer, '1');
await page.waitToClick(selectors.invoiceOutGlobalInvoicing.makeInvoice);
await page.waitForTimeout(1000);
});
});

View File

@ -1,29 +0,0 @@
import getBrowser from '../../helpers/puppeteer';
describe('InvoiceOut negative bases path', () => {
let browser;
let page;
const httpRequests = [];
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
page.on('request', req => {
if (req.url().includes(`InvoiceOuts/negativeBases`))
httpRequests.push(req.url());
});
await page.loginAndModule('administrative', 'invoiceOut');
await page.accessToSection('invoiceOut.negative-bases');
});
afterAll(async() => {
await browser.close();
});
it('should show negative bases in a date range', async() => {
const request = httpRequests.find(req =>
req.includes(`from`) && req.includes(`to`));
expect(request).toBeDefined();
});
});

View File

@ -1,8 +0,0 @@
<vn-portal slot="menu">
<vn-invoice-out-descriptor
invoice-out="$ctrl.invoiceOut"
card-reload="$ctrl.reload()">
</vn-invoice-out-descriptor>
<vn-left-menu source="card"></vn-left-menu>
</vn-portal>
<ui-view></ui-view>

View File

@ -1,41 +0,0 @@
import ngModule from '../module';
import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
const filter = {
fields: [
'id',
'ref',
'issued',
'serial',
'amount',
'clientFk',
'companyFk',
'hasPdf'
],
include: [
{
relation: 'company',
scope: {
fields: ['id', 'code']
}
}, {
relation: 'client',
scope: {
fields: ['id', 'socialName', 'name', 'email']
}
}
]
};
this.$http.get(`InvoiceOuts/${this.$params.id}`, {filter})
.then(res => this.invoiceOut = res.data);
}
}
ngModule.vnComponent('vnInvoiceOutCard', {
template: require('./index.html'),
controller: Controller
});

View File

@ -1,27 +0,0 @@
import './index.js';
describe('vnInvoiceOut', () => {
let controller;
let $httpBackend;
let data = {id: 1, name: 'fooName'};
beforeEach(ngModule('invoiceOut'));
beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => {
$httpBackend = _$httpBackend_;
let $element = angular.element('<div></div>');
controller = $componentController('vnInvoiceOutCard', {$element});
$stateParams.id = data.id;
$httpBackend.whenRoute('GET', 'InvoiceOuts/:id').respond(data);
}));
it('should request data and set it on the controller', () => {
controller.reload();
$httpBackend.flush();
expect(controller.invoiceOut).toEqual(data);
});
});

View File

@ -1,158 +0,0 @@
<vn-card
ng-if="$ctrl.status"
class="status vn-w-lg vn-pa-md">
<vn-spinner
enable="$ctrl.status != 'done'">
</vn-spinner>
<div>
<div ng-switch="$ctrl.status">
<span ng-switch-when="packageInvoicing" translate>
Build packaging tickets
</span>
<span ng-switch-when="invoicing">
{{'Invoicing client' | translate}} {{$ctrl.currentAddress.clientId}}
</span>
<span ng-switch-when="stopping" translate>
Stopping process
</span>
<span ng-switch-when="done" translate>
Ended process
</span>
</div>
<div ng-if="$ctrl.nAddresses">
<div class="text-caption text-secondary">
{{$ctrl.percentage | percentage: 0}}
({{$ctrl.addressNumber}} <span translate>of</span> {{$ctrl.nAddresses}})
</div>
<div class="text-caption text-secondary">
{{$ctrl.nPdfs}} <span translate>of</span> {{$ctrl.totalPdfs}}
<span translate>PDFs</span>
</div>
</div>
</div>
</vn-card>
<vn-card class="vn-w-lg vn-mt-md" ng-if="$ctrl.errors.length">
<vn-table>
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th>Client</vn-th>
<vn-th number>Address id</vn-th>
<vn-th>Street</vn-th>
<vn-th>Error</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="error in $ctrl.errors">
<vn-td number>
<span
vn-click-stop="clientDescriptor.show($event, error.address.clientId)"
class="link">
{{::error.address.clientId}}
</span>
</vn-td>
<vn-td expand>
{{::error.address.clientName}}
</vn-td>
<vn-td number>
{{::error.address.id}}
</vn-td>
<vn-td expand>
{{::error.address.nickname}}
</vn-td>
<vn-td expand>
<span
class="chip"
ng-class="error.isWarning ? 'warning': 'alert'">
{{::error.message}}
</span>
</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</vn-card>
<vn-side-menu side="right">
<vn-crud-model
auto-load="true"
url="InvoiceOutSerials"
data="invoiceOutSerials"
order="code">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="Companies"
data="companies"
order="code">
</vn-crud-model>
<form class="vn-pa-md">
<vn-vertical>
<vn-vertical class="vn-mb-sm">
<vn-radio
label="All clients"
val="all"
ng-model="$ctrl.clientsToInvoice">
</vn-radio>
<vn-radio
label="One client"
val="one"
ng-model="$ctrl.clientsToInvoice">
</vn-radio>
</vn-vertical>
<vn-autocomplete
url="Clients"
label="Client"
search-function="{or: [{id: $search}, {name: {like: '%'+$search+'%'}}]}"
order="id"
show-field="name"
value-field="id"
ng-model="$ctrl.clientId"
required="true"
ng-if="$ctrl.clientsToInvoice == 'one'">
<tpl-item>
<div>{{::name}}</div>
<div class="text-secondary text-caption">#{{::id}}</div>
</tpl-item>
</vn-autocomplete>
<vn-date-picker
vn-one
label="Invoice date"
ng-model="$ctrl.invoiceDate">
</vn-date-picker>
<vn-date-picker
vn-one
label="Max date"
ng-model="$ctrl.maxShipped">
</vn-date-picker>
<vn-autocomplete
url="Companies"
label="Company"
show-field="code"
value-field="id"
ng-model="$ctrl.companyFk"
on-change="$ctrl.getInvoiceDate(value)">
</vn-autocomplete>
<vn-autocomplete
url="Printers"
label="Printer"
show-field="name"
value-field="id"
where="{isLabeler: false}"
ng-model="$ctrl.printerFk">
</vn-autocomplete>
<vn-submit
ng-if="!$ctrl.invoicing"
ng-click="$ctrl.makeInvoice()"
label="Invoice out">
</vn-submit>
<vn-submit
ng-if="$ctrl.invoicing"
label="Stop"
ng-click="$ctrl.status = 'stopping'">
</vn-submit>
</vn-vertical>
</form>
</vn-side-menu>
<vn-client-descriptor-popover
vn-id="clientDescriptor">
</vn-client-descriptor-popover>

View File

@ -1,174 +0,0 @@
import ngModule from '../module';
import Section from 'salix/components/section';
import UserError from 'core/lib/user-error';
import './style.scss';
class Controller extends Section {
$onInit() {
const date = Date.vnNew();
Object.assign(this, {
maxShipped: new Date(date.getFullYear(), date.getMonth(), 0),
clientsToInvoice: 'all',
companyFk: this.vnConfig.companyFk,
parallelism: 1
});
const params = {companyFk: this.companyFk};
this.$http.get('InvoiceOuts/getInvoiceDate', {params})
.then(res => {
this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
this.invoiceDate = this.minInvoicingDate;
});
const filter = {fields: ['parallelism']};
this.$http.get('InvoiceOutConfigs/findOne', {filter})
.then(res => {
if (res.data.parallelism)
this.parallelism = res.data.parallelism;
})
.catch(res => {
if (res.status == 404) return;
throw res;
});
}
makeInvoice() {
this.invoicing = true;
this.status = 'packageInvoicing';
this.errors = [];
this.addresses = null;
try {
if (this.clientsToInvoice == 'one' && !this.clientId)
throw new UserError('Choose a valid client');
if (!this.invoiceDate || !this.maxShipped)
throw new UserError('Invoice date and the max date should be filled');
if (this.invoiceDate < this.maxShipped)
throw new UserError('Invoice date can\'t be less than max date');
if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
throw new UserError('Exists an invoice with a future date');
if (!this.companyFk)
throw new UserError('Choose a valid company');
if (!this.printerFk)
throw new UserError('Choose a valid printer');
if (this.clientsToInvoice == 'all')
this.clientId = undefined;
const params = {
invoiceDate: this.invoiceDate,
maxShipped: this.maxShipped,
clientId: this.clientId,
companyFk: this.companyFk
};
this.$http.post(`InvoiceOuts/clientsToInvoice`, params)
.then(res => {
this.addresses = res.data;
if (!this.addresses.length)
throw new UserError(`There aren't tickets to invoice`);
this.nRequests = 0;
this.nPdfs = 0;
this.totalPdfs = 0;
this.addressIndex = 0;
this.invoiceClient();
})
.catch(err => this.handleError(err));
} catch (err) {
this.handleError(err);
}
}
handleError(err) {
this.invoicing = false;
this.status = null;
throw err;
}
invoiceClient() {
if (this.nRequests == this.parallelism || this.isInvoicing) return;
if (this.addressIndex >= this.addresses.length || this.status == 'stopping') {
if (this.nRequests) return;
this.invoicing = false;
this.status = 'done';
return;
}
this.status = 'invoicing';
const address = this.addresses[this.addressIndex];
this.currentAddress = address;
this.isInvoicing = true;
const params = {
clientId: address.clientId,
addressId: address.id,
invoiceDate: this.invoiceDate,
maxShipped: this.maxShipped,
companyFk: this.companyFk
};
this.$http.post(`InvoiceOuts/invoiceClient`, params)
.then(res => {
this.isInvoicing = false;
if (res.data)
this.makePdfAndNotify(res.data, address);
this.invoiceNext();
})
.catch(res => {
this.isInvoicing = false;
if (res.status >= 400 && res.status < 500) {
this.invoiceError(address, res);
this.invoiceNext();
} else {
this.invoicing = false;
this.status = 'done';
throw new UserError(`Critical invoicing error, proccess stopped`);
}
});
}
invoiceNext() {
this.addressIndex++;
this.invoiceClient();
}
makePdfAndNotify(invoiceId, address) {
this.nRequests++;
this.totalPdfs++;
const params = {printerFk: this.printerFk};
this.$http.post(`InvoiceOuts/${invoiceId}/makePdfAndNotify`, params)
.catch(res => {
this.invoiceError(address, res, true);
})
.finally(() => {
this.nPdfs++;
this.nRequests--;
this.invoiceClient();
});
}
invoiceError(address, res, isWarning) {
const message = res.data?.error?.message || res.message;
this.errors.unshift({address, message, isWarning});
}
get nAddresses() {
if (!this.addresses) return 0;
return this.addresses.length;
}
get addressNumber() {
return Math.min(this.addressIndex + 1, this.nAddresses);
}
get percentage() {
const len = this.nAddresses;
return Math.min(this.addressIndex, len) / len;
}
}
ngModule.vnComponent('vnInvoiceOutGlobalInvoicing', {
template: require('./index.html'),
controller: Controller
});

View File

@ -1,74 +0,0 @@
import './index';
describe('InvoiceOut', () => {
describe('Component vnInvoiceOutGlobalInvoicing', () => {
let controller;
let $httpBackend;
beforeEach(ngModule('invoiceOut'));
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
const $scope = $rootScope.$new();
const $element = angular.element('<vn-invoice-out-global-invoicing></vn-invoice-out-global-invoicing>');
controller = $componentController('vnInvoiceOutGlobalInvoicing', {$element, $scope});
}));
describe('makeInvoice()', () => {
it('should throw an error when invoiceDate or maxShipped properties are not filled in', () => {
jest.spyOn(controller.vnApp, 'showError');
controller.clientsToInvoice = 'all';
let error;
try {
controller.makeInvoice();
} catch (e) {
error = e.message;
}
const expectedError = 'Invoice date and the max date should be filled';
expect(error).toBe(expectedError);
});
it('should throw an error when select one client and clientId is not filled in', () => {
jest.spyOn(controller.vnApp, 'showError');
controller.clientsToInvoice = 'one';
let error;
try {
controller.makeInvoice();
} catch (e) {
error = e.message;
}
const expectedError = 'Choose a valid client';
expect(error).toBe(expectedError);
});
it('should make an http POST query and then call to the showSuccess() method', () => {
const date = Date.vnNew();
Object.assign(controller, {
invoiceDate: date,
maxShipped: date,
minInvoicingDate: date,
clientsToInvoice: 'one',
clientId: 1101,
companyFk: 442,
printerFk: 1
});
$httpBackend.expectPOST(`InvoiceOuts/clientsToInvoice`).respond([{
clientId: 1101,
id: 121
}]);
$httpBackend.expectPOST(`InvoiceOuts/invoiceClient`).respond();
controller.makeInvoice();
$httpBackend.flush();
expect(controller.status).toEqual('done');
});
});
});
});

View File

@ -1,22 +0,0 @@
There aren't tickets to invoice: No existen tickets para facturar
Max date: Fecha límite
Invoice date: Fecha de factura
Invoice date can't be less than max date: La fecha de factura no puede ser inferior a la fecha límite
Invoice date and the max date should be filled: La fecha de factura y la fecha límite deben rellenarse
Choose a valid company: Selecciona un empresa válida
Choose a valid printer: Selecciona una impresora válida
All clients: Todos los clientes
Build packaging tickets: Generando tickets de embalajes
Address id: Id dirección
Printer: Impresora
of: de
PDFs: PDFs
Client: Cliente
Current client id: Id cliente actual
Invoicing client: Facturando cliente
Ended process: Proceso finalizado
Invoice out: Facturar
One client: Un solo cliente
Choose a valid client: Selecciona un cliente válido
Stop: Parar
Critical invoicing error, proccess stopped: Error crítico al facturar, proceso detenido

View File

@ -1,21 +0,0 @@
@import "variables";
vn-invoice-out-global-invoicing {
h5 {
color: $color-primary;
}
.status {
height: 80px;
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
}
#error {
line-break: normal;
overflow-wrap: break-word;
white-space: normal;
}
}

View File

@ -1,13 +1,7 @@
export * from './module'; export * from './module';
import './main'; import './main';
import './index/';
import './search-panel';
import './summary'; import './summary';
import './card';
import './descriptor'; import './descriptor';
import './descriptor-popover'; import './descriptor-popover';
import './descriptor-menu'; import './descriptor-menu';
import './index/manual';
import './global-invoicing';
import './negative-bases';

View File

@ -1,89 +0,0 @@
<vn-auto-search
model="model">
</vn-auto-search>
<vn-data-viewer
model="model"
class="vn-w-lg">
<vn-card class="vn-pa-lg">
<vn-button
disabled="$ctrl.totalChecked == 0"
vn-click-stop="$ctrl.openPdf()"
icon="cloud_download"
title="Download PDF"
vn-tooltip="Download PDF">
</vn-button>
</vn-card>
<vn-card>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th shrink>
<vn-multi-check
model="model">
</vn-multi-check>
</vn-th>
<vn-th field="ref">Reference</vn-th>
<vn-th field="issued" expand>Issued</vn-th>
<vn-th field="amount" number>Amount</vn-th>
<vn-th field="clientFk">Client</vn-th>
<vn-th field="created" expand>Created</vn-th>
<vn-th field="companyFk">Company</vn-th>
<vn-th field="dued" expand>Due date</vn-th>
<vn-th></vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<a ng-repeat="invoiceOut in model.data"
class="clickable vn-tr search-result"
ui-sref="invoiceOut.card.summary({id: {{::invoiceOut.id}}})">
<vn-td>
<vn-check
ng-model="invoiceOut.checked"
vn-click-stop>
</vn-check>
</vn-td>
<vn-td>{{::invoiceOut.ref | dashIfEmpty}}</vn-td>
<vn-td shrink>{{::invoiceOut.issued | date:'dd/MM/yyyy' | dashIfEmpty}}</vn-td>
<vn-td number>{{::invoiceOut.amount | currency: 'EUR': 2 | dashIfEmpty}}</vn-td>
<vn-td>
<span
class="link"
vn-click-stop="clientDescriptor.show($event, invoiceOut.clientFk)">
{{::invoiceOut.clientSocialName | dashIfEmpty}}
</span>
</vn-td>
<vn-td expand>{{::invoiceOut.created | date:'dd/MM/yyyy' | dashIfEmpty}}</vn-td>
<vn-td>{{::invoiceOut.companyCode | dashIfEmpty}}</vn-td>
<vn-td shrink>{{::invoiceOut.dued | date:'dd/MM/yyyy' | dashIfEmpty}}</vn-td>
<vn-td shrink>
<vn-icon-button
vn-click-stop="$ctrl.preview(invoiceOut)"
vn-tooltip="Preview"
icon="preview">
</vn-icon-button>
</vn-td>
</a>
</vn-tbody>
</vn-table>
</vn-card>
</vn-data-viewer>
<div fixed-bottom-right>
<vn-button class="round sm vn-mb-sm"
icon="add"
ng-click="manualInvoicing.show()"
vn-tooltip="Make invoice..."
vn-acl="invoicing"
vn-acl-action="remove">
</vn-button>
</div>
<vn-popup vn-id="summary">
<vn-invoice-out-summary
invoice-out="$ctrl.selectedInvoiceOut">
</vn-invoice-out-summary>
</vn-popup>
<vn-client-descriptor-popover
vn-id="clientDescriptor">
</vn-client-descriptor-popover>
<vn-invoice-out-manual
vn-id="manual-invoicing">
</vn-invoice-out-manual>

View File

@ -1,47 +0,0 @@
import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
get checked() {
const rows = this.$.model.data || [];
const checkedRows = [];
for (let row of rows) {
if (row.checked)
checkedRows.push(row.id);
}
return checkedRows;
}
get totalChecked() {
return this.checked.length;
}
preview(invoiceOut) {
this.selectedInvoiceOut = invoiceOut;
this.$.summary.show();
}
openPdf() {
const access_token = this.vnToken.tokenMultimedia;
if (this.checked.length <= 1) {
const [invoiceOutId] = this.checked;
const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${access_token}`;
window.open(url, '_blank');
} else {
const invoiceOutIds = this.checked;
const invoicesIds = invoiceOutIds.join(',');
const serializedParams = this.$httpParamSerializer({
access_token,
ids: invoicesIds
});
const url = `api/InvoiceOuts/downloadZip?${serializedParams}`;
window.open(url, '_blank');
}
}
}
ngModule.vnComponent('vnInvoiceOutIndex', {
template: require('./index.html'),
controller: Controller
});

View File

@ -1,9 +0,0 @@
Created: Fecha creacion
Issued: Fecha factura
Due date: Fecha vencimiento
Has PDF: PDF disponible
Minimum: Minimo
Maximum: Máximo
Global invoicing: Facturación global
Manual invoicing: Facturación manual
Files are too large: Los archivos son demasiado grandes

View File

@ -1,86 +0,0 @@
<tpl-title translate>
Create manual invoice
</tpl-title>
<tpl-body id="manifold-form">
<vn-crud-model
auto-load="true"
url="InvoiceOutSerials"
data="invoiceOutSerials"
where="{code: {neq: 'R'}}"
order="code">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="TaxAreas"
data="taxAreas"
order="code">
</vn-crud-model>
<div
class="progress vn-my-md"
ng-if="$ctrl.isInvoicing">
<vn-horizontal>
<vn-icon vn-none icon="warning"></vn-icon>
<span vn-none translate>Invoicing in progress...</span>
</vn-horizontal>
</div>
<vn-horizontal class="manifold-panel">
<vn-autocomplete
url="Tickets"
label="Ticket"
search-function="{refFk: null, or: [{id: $search}, {nickname: {like: '%'+$search+'%'}}]}"
show-field="id"
value-field="id"
fields="['nickname']"
ng-model="$ctrl.invoice.ticketFk"
order="shipped DESC"
on-change="$ctrl.invoice.clientFk = null">
<tpl-item>
<div>#{{::id}}</div>
<div class="text-secondary text-caption">{{::nickname}}</div>
</tpl-item>
</vn-autocomplete>
<vn-none class="or vn-px-md" translate>Or</vn-none>
<vn-autocomplete
url="Clients"
label="Client"
search-function="{or: [{id: $search}, {name: {like: '%'+$search+'%'}}]}"
show-field="name"
value-field="id"
ng-model="$ctrl.invoice.clientFk"
on-change="$ctrl.invoice.ticketFk = null">
</vn-autocomplete>
<vn-date-picker
vn-one
label="Max date"
ng-model="$ctrl.invoice.maxShipped">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
data="invoiceOutSerials"
label="Serial"
show-field="description"
value-field="code"
ng-model="$ctrl.invoice.serial"
required="true">
</vn-autocomplete>
<vn-autocomplete
data="taxAreas"
label="Area"
show-field="code"
value-field="code"
ng-model="$ctrl.invoice.taxArea"
required="true">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
label="Reference"
ng-model="$ctrl.invoice.reference">
</vn-textfield>
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate vn-focus>Make invoice</button>
</tpl-buttons>

View File

@ -1,51 +0,0 @@
import ngModule from '../../module';
import Dialog from 'core/components/dialog';
import './style.scss';
class Controller extends Dialog {
constructor($element, $, $transclude) {
super($element, $, $transclude);
this.isInvoicing = false;
this.invoice = {
maxShipped: Date.vnNew()
};
}
responseHandler(response) {
try {
if (response !== 'accept')
return super.responseHandler(response);
if (this.invoice.clientFk && !this.invoice.maxShipped)
throw new Error('Client and the max shipped should be filled');
if (!this.invoice.serial || !this.invoice.taxArea)
throw new Error('Some fields are required');
this.isInvoicing = true;
return this.$http.post(`InvoiceOuts/createManualInvoice`, this.invoice)
.then(res => {
this.$state.go('invoiceOut.card.summary', {id: res.data.id});
super.responseHandler(response);
})
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
.finally(() => this.isInvoicing = false);
} catch (e) {
this.vnApp.showError(this.$t(e.message));
this.isInvoicing = false;
return false;
}
}
}
Controller.$inject = ['$element', '$scope', '$transclude'];
ngModule.vnComponent('vnInvoiceOutManual', {
slotTemplate: require('./index.html'),
controller: Controller,
bindings: {
ticketFk: '<?',
clientFk: '<?'
}
});

View File

@ -1,66 +0,0 @@
import './index';
describe('InvoiceOut', () => {
describe('Component vnInvoiceOutManual', () => {
let controller;
let $httpBackend;
beforeEach(ngModule('invoiceOut'));
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
let $scope = $rootScope.$new();
const $element = angular.element('<vn-invoice-out-manual></vn-invoice-out-manual>');
const $transclude = {
$$boundTransclude: {
$$slots: []
}
};
controller = $componentController('vnInvoiceOutManual', {$element, $scope, $transclude});
}));
describe('responseHandler()', () => {
it('should throw an error when clientFk property is set and the maxShipped is not filled', () => {
jest.spyOn(controller.vnApp, 'showError');
controller.invoice = {
clientFk: 1101,
serial: 'T',
taxArea: 'B'
};
controller.responseHandler('accept');
expect(controller.vnApp.showError).toHaveBeenCalledWith(`Client and the max shipped should be filled`);
});
it('should throw an error when some required fields are not filled in', () => {
jest.spyOn(controller.vnApp, 'showError');
controller.invoice = {
ticketFk: 1101
};
controller.responseHandler('accept');
expect(controller.vnApp.showError).toHaveBeenCalledWith(`Some fields are required`);
});
it('should make an http POST query and then call to the parent showSuccess() method', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
controller.invoice = {
ticketFk: 1101,
serial: 'T',
taxArea: 'B'
};
$httpBackend.expect('POST', `InvoiceOuts/createManualInvoice`).respond({id: 1});
controller.responseHandler('accept');
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
});
});

View File

@ -1,6 +0,0 @@
Create manual invoice: Crear factura manual
Some fields are required: Algunos campos son obligatorios
Client and max shipped fields should be filled: Los campos de cliente y fecha límite deben rellenarse
Max date: Fecha límite
Serial: Serie
Invoicing in progress...: Facturación en progreso...

View File

@ -1,17 +0,0 @@
@import "variables";
.vn-invoice-out-manual {
tpl-body {
width: 500px;
.progress {
font-weight: bold;
text-align: center;
font-size: 1.5rem;
color: $color-primary;
vn-horizontal {
justify-content: center
}
}
}
}

View File

@ -1,18 +0,0 @@
<vn-crud-model
vn-id="model"
url="InvoiceOuts/filter"
limit="20"
order="issued DESC, id DESC">
</vn-crud-model>
<vn-portal slot="topbar">
<vn-searchbar
vn-focus
panel="vn-invoice-search-panel"
info="Search invoices by reference"
model="model">
</vn-searchbar>
</vn-portal>
<vn-portal slot="menu">
<vn-left-menu></vn-left-menu>
</vn-portal>
<ui-view></ui-view>

View File

@ -1,7 +1,15 @@
import ngModule from '../module'; import ngModule from '../module';
import ModuleMain from 'salix/components/module-main'; import ModuleMain from 'salix/components/module-main';
export default class InvoiceOut extends ModuleMain {} export default class InvoiceOut extends ModuleMain {
constructor($element, $) {
super($element, $);
}
async $onInit() {
this.$state.go('home');
window.location.href = await this.vnApp.getUrl(`invoice-out/`);
}
}
ngModule.vnComponent('vnInvoiceOut', { ngModule.vnComponent('vnInvoiceOut', {
controller: InvoiceOut, controller: InvoiceOut,

View File

@ -1,134 +0,0 @@
<vn-crud-model
vn-id="model"
url="InvoiceOuts/negativeBases"
auto-load="true"
params="$ctrl.params"
limit="20">
</vn-crud-model>
<vn-portal slot="topbar">
</vn-portal>
<vn-card>
<smart-table
model="model"
options="$ctrl.smartTableOptions"
expr-builder="$ctrl.exprBuilder(param, value)">
<slot-actions>
<vn-date-picker
vn-one
label="From"
ng-model="$ctrl.params.from"
on-change="model.refresh()">
</vn-date-picker>
<vn-date-picker
vn-one
label="To"
ng-model="$ctrl.params.to"
on-change="model.refresh()">
</vn-date-picker>
<vn-button
disabled="model._orgData.length == 0"
icon="download"
ng-click="$ctrl.downloadCSV()"
vn-tooltip="Download as CSV">
</vn-button>
</slot-actions>
<slot-table>
<table>
<thead>
<tr>
<th field="company">
<span translate>Company</span>
</th>
<th field="country">
<span translate>Country</span>
</th>
<th field="clientId">
<span translate>Client id</span>
</th>
<th field="clientSocialName">
<span translate>Client</span>
</th>
<th field="amount">
<span translate>Amount</span>
</th>
<th field="taxableBase">
<span translate>Base</span>
</th>
<th field="ticketFk">
<span translate>Ticket id</span>
</th>
<th field="isActive">
<span translate>Active</span>
</th>
<th field="hasToInvoice">
<span translate>Has To Invoice</span>
</th>
<th field="isTaxDataChecked">
<span translate>Verified data</span>
</th>
<th field="comercialName">
<span translate>Comercial</span>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="client in model.data">
<td>{{client.company | dashIfEmpty}}</td>
<td>{{client.country | dashIfEmpty}}</td>
<td>
<vn-span
class="link"
ng-click="clientDescriptor.show($event, client.clientId)">
{{::client.clientId | dashIfEmpty}}
</vn-span>
</td>
<td>{{client.clientSocialName | dashIfEmpty}}</td>
<td>{{client.amount | currency: 'EUR':2 | dashIfEmpty}}</td>
<td>{{client.taxableBase | dashIfEmpty}}</td>
<td>
<vn-span
class="link"
ng-click="ticketDescriptor.show($event, client.ticketFk)">
{{::client.ticketFk | dashIfEmpty}}
</vn-span>
</td>
<td>
<vn-check
disabled="true"
ng-model="client.isActive">
</vn-check>
</td>
<td>
<vn-check
disabled="true"
ng-model="client.hasToInvoice">
</vn-check>
</td>
<td>
<vn-check
disabled="true"
ng-model="client.isTaxDataChecked">
</vn-check>
</td>
<td>
<vn-span
class="link"
ng-click="workerDescriptor.show($event, client.comercialId)">
{{::client.workerName | dashIfEmpty}}
</vn-span>
</td>
</tr>
</tbody>
</table>
</slot-table>
</smart-table>
</vn-card>
<vn-ticket-descriptor-popover
vn-id="ticket-descriptor">
</vn-ticket-descriptor-popover>
<vn-client-descriptor-popover
vn-id="client-descriptor">
</vn-client-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="worker-descriptor">
</vn-worker-descriptor-popover>

View File

@ -1,74 +0,0 @@
import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
export default class Controller extends Section {
constructor($element, $, vnReport) {
super($element, $);
this.vnReport = vnReport;
const now = Date.vnNew();
const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
const lastDayOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0);
this.params = {
from: firstDayOfMonth,
to: lastDayOfMonth
};
this.$checkAll = false;
this.smartTableOptions = {
activeButtons: {
search: true,
},
columns: [
{
field: 'isActive',
searchable: false
},
{
field: 'hasToInvoice',
searchable: false
},
{
field: 'isTaxDataChecked',
searchable: false
},
]
};
}
exprBuilder(param, value) {
switch (param) {
case 'company':
return {'company': value};
case 'country':
return {'country': value};
case 'clientId':
return {'clientId': value};
case 'clientSocialName':
return {'clientSocialName': value};
case 'amount':
return {'amount': value};
case 'taxableBase':
return {'taxableBase': value};
case 'ticketFk':
return {'ticketFk': value};
case 'comercialName':
return {'comercialName': value};
}
}
downloadCSV() {
this.vnReport.show('InvoiceOuts/negativeBasesCsv', {
from: this.params.from,
to: this.params.to
});
}
}
Controller.$inject = ['$element', '$scope', 'vnReport'];
ngModule.vnComponent('vnNegativeBases', {
template: require('./index.html'),
controller: Controller
});

View File

@ -1,2 +0,0 @@
Has To Invoice: Facturar
Download as CSV: Descargar como CSV

View File

@ -1,10 +0,0 @@
@import "./variables";
vn-negative-bases {
vn-date-picker{
padding-right: 5%;
}
slot-actions{
align-items: center;
}
}

View File

@ -26,12 +26,6 @@
"component": "vn-invoice-out-index", "component": "vn-invoice-out-index",
"description": "InvoiceOut" "description": "InvoiceOut"
}, },
{
"url": "/global-invoicing?q",
"state": "invoiceOut.global-invoicing",
"component": "vn-invoice-out-global-invoicing",
"description": "Global invoicing"
},
{ {
"url": "/summary", "url": "/summary",
"state": "invoiceOut.card.summary", "state": "invoiceOut.card.summary",
@ -40,21 +34,6 @@
"params": { "params": {
"invoice-out": "$ctrl.invoiceOut" "invoice-out": "$ctrl.invoiceOut"
} }
},
{
"url": "/:id",
"state": "invoiceOut.card",
"abstract": true,
"component": "vn-invoice-out-card"
},
{
"url": "/negative-bases",
"state": "invoiceOut.negative-bases",
"component": "vn-negative-bases",
"description": "Negative bases",
"acl": [
"administrative"
]
} }
] ]
} }

View File

@ -1,68 +0,0 @@
<div class="search-panel">
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield
vn-one
label="General search"
ng-model="filter.search"
info="Search invoices by reference"
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Client id"
ng-model="filter.clientFk">
</vn-textfield>
<vn-textfield
vn-one
label="Client fiscal id"
ng-model="filter.fi">
</vn-textfield>
<vn-check
vn-one
triple-state="true"
label="Has PDF"
ng-model="filter.hasPdf">
</vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Amount"
ng-model="filter.amount">
</vn-textfield>
<vn-textfield
vn-one
label="Minimum"
ng-model="filter.min">
</vn-textfield>
<vn-textfield
vn-one
label="Maximum"
ng-model="filter.max">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker
vn-one
label="Issued"
ng-model="filter.issued">
</vn-date-picker>
<vn-date-picker
vn-one
label="Created"
ng-model="filter.created">
</vn-date-picker>
<vn-date-picker
vn-one
label="Due date"
ng-model="filter.dued">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal class="vn-mt-lg">
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>

View File

@ -1,7 +0,0 @@
import ngModule from '../module';
import SearchPanel from 'core/components/searchbar/search-panel';
ngModule.vnComponent('vnInvoiceSearchPanel', {
template: require('./index.html'),
controller: SearchPanel
});