invoicing test
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Andrés 2023-03-01 10:36:38 +01:00
parent ffdfd1a7e5
commit 6f5e25493d
9 changed files with 65 additions and 55 deletions

View File

@ -69,7 +69,7 @@ BEGIN
JOIN supplier su ON su.id = t.companyFk JOIN supplier su ON su.id = t.companyFk
JOIN client c ON c.id = t.clientFk JOIN client c ON c.id = t.clientFk
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
WHERE YEAR(t.shipped) < 2001 WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted)
OR c.isTaxDataChecked = FALSE OR c.isTaxDataChecked = FALSE
OR t.isDeleted OR t.isDeleted
OR c.hasToInvoice = FALSE OR c.hasToInvoice = FALSE

View File

@ -1,8 +1,16 @@
CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `vn2008`;
CREATE SCHEMA IF NOT EXISTS `tmp`; CREATE SCHEMA IF NOT EXISTS `tmp`;
UPDATE `util`.`config` ALTER TABLE util.config
SET `environment`= 'development'; ADD COLUMN `mockUtcTime` datetime DEFAULT NULL,
ADD COLUMN `mockEnabled` tinyint(3) unsigned NOT NULL DEFAULT 0,
ADD COLUMN `mockTz` varchar(255) DEFAULT NULL;
UPDATE util.config
SET mockUtcTime='2001-01-01 11:00:00',
environment= 'development',
mockEnabled = TRUE,
mockTz='+01:00';
-- FOR MOCK vn.time -- FOR MOCK vn.time
@ -164,7 +172,7 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0), (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0),
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0); (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);

View File

@ -1043,20 +1043,22 @@ export default {
invoiceOutIndex: { invoiceOutIndex: {
topbarSearch: 'vn-searchbar', topbarSearch: 'vn-searchbar',
searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr', searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
createInvoice: 'vn-invoice-out-index > div > vn-vertical > vn-button > button vn-icon[icon="add"]', createInvoice: 'vn-invoice-out-index > div > vn-button > button vn-icon[icon="add"]',
createManualInvoice: 'vn-item[name="manualInvoice"]',
createGlobalInvoice: 'vn-item[name="globalInvoice"]',
manualInvoiceForm: '.vn-invoice-out-manual', manualInvoiceForm: '.vn-invoice-out-manual',
manualInvoiceTicket: 'vn-autocomplete[ng-model="$ctrl.invoice.ticketFk"]', manualInvoiceTicket: 'vn-autocomplete[ng-model="$ctrl.invoice.ticketFk"]',
manualInvoiceClient: 'vn-autocomplete[ng-model="$ctrl.invoice.clientFk"]', manualInvoiceClient: 'vn-autocomplete[ng-model="$ctrl.invoice.clientFk"]',
manualInvoiceSerial: 'vn-autocomplete[ng-model="$ctrl.invoice.serial"]', manualInvoiceSerial: 'vn-autocomplete[ng-model="$ctrl.invoice.serial"]',
manualInvoiceTaxArea: 'vn-autocomplete[ng-model="$ctrl.invoice.taxArea"]', manualInvoiceTaxArea: 'vn-autocomplete[ng-model="$ctrl.invoice.taxArea"]',
saveInvoice: 'button[response="accept"]', saveInvoice: 'button[response="accept"]'
globalInvoiceForm: '.vn-invoice-out-global-invoicing', },
globalInvoiceClientsRange: 'vn-radio[val="clientsRange"]', invoiceOutGlobalInvoicing: {
globalInvoiceDate: '[ng-model="$ctrl.invoice.invoiceDate"]', oneClient: 'vn-invoice-out-global-invoicing vn-side-menu form > vn-vertical > vn-vertical > vn-radio[val="one"]',
globalInvoiceFromClient: '[ng-model="$ctrl.invoice.fromClientId"]', allClients: 'vn-invoice-out-global-invoicing vn-side-menu form > vn-vertical > vn-vertical > vn-radio[val="all"]',
globalInvoiceToClient: '[ng-model="$ctrl.invoice.toClientId"]', clientId: 'vn-invoice-out-global-invoicing vn-side-menu form > vn-vertical > vn-autocomplete[ng-model="$ctrl.clientId"]',
printer: 'vn-invoice-out-global-invoicing vn-side-menu form > vn-vertical > vn-autocomplete[ng-model="$ctrl.printerFk"]',
makeInvoice: 'vn-invoice-out-global-invoicing vn-side-menu form > vn-vertical > vn-submit',
invoiceDate: 'vn-invoice-out-global-invoicing vn-side-menu form > vn-vertical > vn-date-picker[ng-model="$ctrl.invoiceDate"]',
maxShipped: 'vn-invoice-out-global-invoicing vn-side-menu form > vn-vertical > vn-date-picker[ng-model="$ctrl.maxShipped"]'
}, },
invoiceOutDescriptor: { invoiceOutDescriptor: {
moreMenu: 'vn-invoice-out-descriptor vn-icon-button[icon=more_vert]', moreMenu: 'vn-invoice-out-descriptor vn-icon-button[icon=more_vert]',

View File

@ -17,7 +17,6 @@ describe('InvoiceOut manual invoice path', () => {
it('should open the manual invoice form', async() => { it('should open the manual invoice form', async() => {
await page.waitToClick(selectors.invoiceOutIndex.createInvoice); await page.waitToClick(selectors.invoiceOutIndex.createInvoice);
await page.waitToClick(selectors.invoiceOutIndex.createManualInvoice);
await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm);
}); });
@ -45,7 +44,6 @@ describe('InvoiceOut manual invoice path', () => {
it('should now open the manual invoice form', async() => { it('should now open the manual invoice form', async() => {
await page.waitToClick(selectors.invoiceOutIndex.createInvoice); await page.waitToClick(selectors.invoiceOutIndex.createInvoice);
await page.waitToClick(selectors.invoiceOutIndex.createManualInvoice);
await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm);
}); });

View File

@ -17,47 +17,53 @@ describe('InvoiceOut global invoice path', () => {
await browser.close(); await browser.close();
}); });
let invoicesBefore; let invoicesBeforeOneClient;
let invoicesBeforeAllClients;
let now = Date.vnNew();
it('should count the amount of invoices listed before globla invoces are made', async() => { it('should count the amount of invoices listed before globla invoces are made', async() => {
invoicesBefore = await page.countElement(selectors.invoiceOutIndex.searchResult); invoicesBeforeOneClient = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(invoicesBefore).toBeGreaterThanOrEqual(4); expect(invoicesBeforeOneClient).toBeGreaterThanOrEqual(4);
}); });
it('should open the global invoice form', async() => { it('should open the global invoice form', async() => {
await page.waitToClick(selectors.invoiceOutIndex.createInvoice); await page.accessToSection('invoiceOut.global-invoicing');
await page.waitToClick(selectors.invoiceOutIndex.createGlobalInvoice);
await page.waitForSelector(selectors.invoiceOutIndex.globalInvoiceForm);
}); });
it('should create a global invoice for charles xavier today', async() => { it('should create a global invoice for charles xavier today', async() => {
await page.pickDate(selectors.invoiceOutIndex.globalInvoiceDate); await page.waitToClick(selectors.invoiceOutGlobalInvoicing.oneClient);
await page.waitToClick(selectors.invoiceOutIndex.globalInvoiceClientsRange); await page.autocompleteSearch(selectors.invoiceOutGlobalInvoicing.clientId, '1108');
await page.autocompleteSearch(selectors.invoiceOutIndex.globalInvoiceFromClient, 'Petter Parker'); await page.pickDate(selectors.invoiceOutGlobalInvoicing.invoiceDate, now);
await page.autocompleteSearch(selectors.invoiceOutIndex.globalInvoiceToClient, 'Petter Parker'); await page.pickDate(selectors.invoiceOutGlobalInvoicing.maxShipped, now);
await page.waitToClick(selectors.invoiceOutIndex.saveInvoice); await page.autocompleteSearch(selectors.invoiceOutGlobalInvoicing.printer, '1');
const message = await page.waitForSnackbar(); await page.waitToClick(selectors.invoiceOutGlobalInvoicing.makeInvoice);
await page.waitForTimeout(1000);
expect(message.text).toContain('Data saved!');
}); });
it('should count the amount of invoices listed after globla invocing', async() => { it('should count the amount of invoices listed after invoice for charles xavier today', async() => {
await page.waitToClick('[icon="search"]');
await page.waitForTimeout(1000); // index search needs time to return results
invoicesBeforeAllClients = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(invoicesBeforeAllClients).toBeGreaterThan(invoicesBeforeOneClient);
});
it('should create a global invoice for all clients today', async() => {
await page.accessToSection('invoiceOut.global-invoicing');
await page.waitToClick(selectors.invoiceOutGlobalInvoicing.allClients);
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);
});
it('should count the amount of invoices listed after global invocing', async() => {
await page.waitToClick('[icon="search"]'); await page.waitToClick('[icon="search"]');
await page.waitForTimeout(1000); // index search needs time to return results await page.waitForTimeout(1000); // index search needs time to return results
const currentInvoices = await page.countElement(selectors.invoiceOutIndex.searchResult); const currentInvoices = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(currentInvoices).toBeGreaterThan(invoicesBefore); expect(currentInvoices).toBeGreaterThan(invoicesBeforeAllClients);
});
it('should create a global invoice for all clients today', async() => {
await page.waitToClick(selectors.invoiceOutIndex.createInvoice);
await page.waitToClick(selectors.invoiceOutIndex.createGlobalInvoice);
await page.waitForSelector(selectors.invoiceOutIndex.globalInvoiceForm);
await page.pickDate(selectors.invoiceOutIndex.globalInvoiceDate);
await page.waitToClick(selectors.invoiceOutIndex.saveInvoice);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
}); });
}); });

View File

@ -150,5 +150,6 @@
"It is not possible to modify tracked sales": "It is not possible to modify tracked sales", "It is not possible to modify tracked sales": "It is not possible to modify tracked sales",
"It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo",
"It is not possible to modify cloned sales": "It is not possible to modify cloned sales", "It is not possible to modify cloned sales": "It is not possible to modify cloned sales",
"Valid priorities: 1,2,3": "Valid priorities: 1,2,3" "Valid priorities: 1,2,3": "Valid priorities: 1,2,3",
"Warehouse inventory not seted": "Warehouse inventory not seted"
} }

View File

@ -266,5 +266,6 @@
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.", "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
"There is no assigned email for this client": "No hay correo asignado para este cliente", "There is no assigned email for this client": "No hay correo asignado para este cliente",
"Exists an invoice with a previous date": "Existe una factura con fecha anterior", "Exists an invoice with a previous date": "Existe una factura con fecha anterior",
"Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite" "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
"Warehouse inventory not seted": "Warehouse inventory not seted"
} }

View File

@ -4,10 +4,6 @@ module.exports = Self => {
accessType: 'READ', accessType: 'READ',
accepts: [ accepts: [
{ {
arg: 'year',
type: 'number',
required: true
}, {
arg: 'companyFk', arg: 'companyFk',
type: 'number', type: 'number',
required: true required: true
@ -23,17 +19,16 @@ module.exports = Self => {
} }
}); });
Self.getInvoiceDate = async(year, companyFk) => { Self.getInvoiceDate = async companyFk => {
const models = Self.app.models; const models = Self.app.models;
const [invoiceDate] = await models.InvoiceOut.rawSql( const [invoiceDate] = await models.InvoiceOut.rawSql(
`SELECT MAX(io.issued) issued `SELECT MAX(io.issued) issued
FROM invoiceOut io FROM invoiceOut io
JOIN invoiceOutSerial ios ON ios.code = io.serial JOIN invoiceOutSerial ios ON ios.code = io.serial
WHERE ios.type = 'global' WHERE ios.type = 'global'
AND io.issued BETWEEN MAKEDATE(?, 1) AND AND io.issued
util.lastDayOfYear(MAKEDATE(?, 1))
AND io.companyFk = ?`, AND io.companyFk = ?`,
[year, year, companyFk] [companyFk]
); );
return invoiceDate; return invoiceDate;
}; };

View File

@ -15,13 +15,12 @@ class Controller extends Section {
.then(res => { .then(res => {
this.companyFk = res.data.companyFk; this.companyFk = res.data.companyFk;
const params = { const params = {
year: this.maxShipped.getFullYear(),
companyFk: this.companyFk companyFk: this.companyFk
}; };
return this.$http.get('InvoiceOuts/getInvoiceDate', {params}); return this.$http.get('InvoiceOuts/getInvoiceDate', {params});
}) })
.then(res => { .then(res => {
this.minInvoicingDate = new Date(res.data.issued); this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
this.invoiceDate = this.minInvoicingDate; this.invoiceDate = this.minInvoicingDate;
}); });
} }