2510-client-address-create-test #418

Merged
jgallego merged 11 commits from 2510-client-address-create-test into dev 2020-11-02 07:53:55 +00:00
21 changed files with 373 additions and 16 deletions
Showing only changes of commit 7dfe7ee379 - Show all commits

View File

@ -0,0 +1,107 @@
USE `vn`;
DROP procedure IF EXISTS `ticket_componentPreview`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentPreview`(
vTicketFk INT,
vLanded DATE,
vAddressFk INT,
vZoneFk INT,
vWarehouseFk SMALLINT)
BEGIN
/**
* Calcula los componentes de los articulos de un ticket
*
* @param vTicketFk id del ticket
* @param vLanded nueva fecha de entrega
* @param vAddressFk nuevo consignatario
* @param vZoneFk nueva zona
* @param vWarehouseFk nuevo warehouse
*
* @return tmp.ticketComponentPreview (warehouseFk, itemFk, componentFk, cost)
*/
DECLARE vHasDataChanged BOOL DEFAULT FALSE;
DECLARE vHasAddressChanged BOOL;
DECLARE vHasZoneChanged BOOL DEFAULT FALSE;
DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE;
DECLARE vShipped DATE;
DECLARE vAddressTypeRateFk INT DEFAULT NULL;
DECLARE vAgencyModeTypeRateFk INT DEFAULT NULL;
DECLARE vHasChangeAll BOOL DEFAULT FALSE;
SELECT DATE(landed) <> vLanded,
addressFk <> vAddressFk,
zoneFk <> vZoneFk,
warehouseFk <> vWarehouseFk
INTO
vHasDataChanged,
vHasAddressChanged,
vHasZoneChanged,
vHasWarehouseChanged
FROM vn.ticket t
WHERE t.id = vTicketFk;
IF vHasDataChanged OR vHasWarehouseChanged THEN
SET vHasChangeAll = TRUE;
END IF;
IF vHasAddressChanged THEN
SET vAddressTypeRateFk = 5;
END IF;
IF vHasZoneChanged THEN
SET vAgencyModeTypeRateFk = 6;
END IF;
SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped
FROM zone
WHERE id = vZoneFk;
CALL buyUltimate(vWarehouseFk, vShipped);
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
SELECT
vWarehouseFk AS warehouseFk,
NULL AS available,
s.itemFk,
bu.buyFk,
vZoneFk zoneFk
FROM sale s
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
WHERE s.ticketFk = vTicketFk
GROUP BY bu.warehouseFk, bu.itemFk);
CALL catalog_componentPrepare();
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
REPLACE INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
SELECT t.warehouseFk, s.itemFk, sc.componentFk, sc.value
FROM saleComponent sc
JOIN sale s ON s.id = sc.saleFk
JOIN ticket t ON t.id = s.ticketFk
JOIN `component` c ON c.id = sc.componentFk
WHERE s.ticketFk = vTicketFk
AND (c.isRenewable = FALSE
OR
(NOT vHasChangeAll
AND (NOT (c.typeFk <=> vAddressTypeRateFk
OR c.typeFk <=> vAgencyModeTypeRateFk))));
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPreview;
CREATE TEMPORARY TABLE tmp.ticketComponentPreview
SELECT * FROM tmp.ticketComponent;
CALL catalog_componentPurge();
DROP TEMPORARY TABLE tmp.buyUltimate;
IF vShipped IS NULL THEN
CALL util.throw('NO_ZONE_AVAILABLE');
END IF;
END$$
DELIMITER ;

View File

@ -83,6 +83,9 @@ export default {
equalizationTaxCheckbox: 'vn-client-fiscal-data vn-check[ng-model="$ctrl.client.isEqualizated"]',
address: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.street"]',
postcode: 'vn-client-fiscal-data vn-datalist[ng-model="$ctrl.client.postcode"]',
sageTax: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.sageTaxTypeFk"]',
sageTransaction: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.sageTransactionTypeFk"]',
transferor: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.transferorFk"]',
city: 'vn-client-fiscal-data vn-datalist[ng-model="$ctrl.client.city"]',
province: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.provinceFk"]',
country: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.countryFk"]',

View File

@ -66,6 +66,9 @@ describe('Client Edit fiscalData path', () => {
await page.autocompleteSearch(selectors.clientFiscalData.province, 'Province one');
await page.clearInput(selectors.clientFiscalData.city);
await page.write(selectors.clientFiscalData.city, 'Valencia');
await page.autocompleteSearch(selectors.clientFiscalData.sageTax, 'operaciones no sujetas');
await page.autocompleteSearch(selectors.clientFiscalData.sageTransaction, 'regularización de inversiones');
await page.autocompleteSearch(selectors.clientFiscalData.transferor, 'Max Eisenhardt');
await page.clearInput(selectors.clientFiscalData.postcode);
await page.write(selectors.clientFiscalData.postcode, '46000');
await page.waitToClick(selectors.clientFiscalData.activeCheckbox);
@ -188,6 +191,24 @@ describe('Client Edit fiscalData path', () => {
expect(result).toContain('46000');
});
it('should confirm the sageTax have been edited', async() => {
const result = await page.waitToGetProperty(selectors.clientFiscalData.sageTax, 'value');
expect(result).toEqual('Operaciones no sujetas');
});
it('should confirm the sageTransaction have been edited', async() => {
const result = await page.waitToGetProperty(selectors.clientFiscalData.sageTransaction, 'value');
expect(result).toEqual('Regularización de inversiones');
});
it('should confirm the transferor have been edited', async() => {
const result = await page.waitToGetProperty(selectors.clientFiscalData.transferor, 'value');
expect(result).toEqual('Max Eisenhardt');
});
it('should confirm the city have been autocompleted', async() => {
const result = await page.waitToGetProperty(selectors.clientFiscalData.city, 'value');

View File

@ -0,0 +1,70 @@
import ngModule from '../module';
export function stringifyParams(data) {
const params = Object.assign({}, data.params);
for (let param in params)
params[param] = JSON.stringify(params[param]);
return params;
}
export function changeState($state, event, data) {
const params = stringifyParams(data);
$state.go(data.state, params);
event.preventDefault();
event.stopPropagation();
}
export function openNewTab($state, $window, event, data) {
const params = stringifyParams(data);
const href = $state.href(data.state, params);
$window.open(href);
event.preventDefault();
event.stopPropagation();
}
/**
* Allows changing state for nested anchor
*
* @param {Object} $state
* @param {Object} $window
* @return {Object} The directive
*/
export function directive($state, $window) {
let ctrlPressed = false;
$window.addEventListener('keydown', event => {
if (event.key == 'Control')
ctrlPressed = true;
});
$window.addEventListener('keyup', event => {
if (event.key == 'Control')
ctrlPressed = false;
});
return {
restrict: 'A',
link: function($scope, $element, $attrs) {
const data = $scope.$eval($attrs.vnAnchor);
$element.on('click', event => {
if (ctrlPressed)
openNewTab($state, $window, event, data);
else
changeState($state, event, data);
});
$element.on('mousedown', event => {
const mouseWheel = 1;
if (event.button == mouseWheel)
openNewTab($state, $window, event, data);
});
}
};
}
directive.$inject = ['$state', '$window'];
ngModule.directive('vnAnchor', directive);

View File

@ -15,3 +15,4 @@ import './smart-table';
import './droppable';
import './http-click';
import './http-submit';
import './anchor';

View File

@ -29,7 +29,6 @@ describe('Client updateFiscalData', () => {
const ctx = {req: {accessToken: {userId: 5}}};
ctx.args = {postcode: 46680};
const client = await app.models.Client.findById(clientId);
expect(client.postcode).toEqual('46460');

View File

@ -43,6 +43,18 @@ module.exports = Self => {
arg: 'provinceFk',
type: 'number'
},
{
arg: 'sageTaxTypeFk',
type: 'number'
},
{
arg: 'sageTransactionTypeFk',
type: 'number'
},
{
arg: 'transferorFk',
type: 'number'
},
{
arg: 'hasToInvoiceByAddress',
type: 'boolean'

View File

@ -83,6 +83,12 @@
"SmsConfig": {
"dataSource": "vn"
},
"SageTaxType": {
"dataSource": "vn"
},
"SageTransactionType": {
"dataSource": "vn"
},
"TpvError": {
"dataSource": "vn"
},

View File

@ -118,6 +118,18 @@
},
"created": {
"type": "Date"
},
"sageTaxTypeFk": {
"type": "number",
"mysql": {
"columnName": "taxTypeSageFk"
}
},
"sageTransactionTypeFk": {
"type": "number",
"mysql": {
"columnName": "transactionTypeSageFk"
}
}
},
"relations": {
@ -200,6 +212,20 @@
"type": "hasOne",
"model": "ClaimRatio",
"foreignKey": "clientFk"
},
"transferor": {
"type": "belongsTo",
"model": "Client",
"foreignKey": "transferorFk"
}
},
"scopes": {
"isActive": {
"where": {
"isActive": {
"neq": false
}
}
}
}
}

View File

@ -0,0 +1,33 @@
{
"name": "SageTaxType",
"base": "VnModel",
"options": {
"mysql": {
"table": "sage.TiposIva"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier",
"mysql": {
"columnName": "CodigoIva"
}
},
"vat": {
"type": "string",
"mysql": {
"columnName": "Iva"
}
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -0,0 +1,33 @@
{
"name": "SageTransactionType",
"base": "VnModel",
"options": {
"mysql": {
"table": "sage.TiposTransacciones"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier",
"mysql": {
"columnName": "CodigoTransaccion"
}
},
"transaction": {
"type": "string",
"mysql": {
"columnName": "Transaccion"
}
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -1,6 +1,6 @@
<vn-watcher
vn-id="watcher"
url="CreditClassifications/{{post.params.classificationId}}/insurances"
url="CreditClassifications/{{$ctrl.$params.classificationId}}/insurances"
data="$ctrl.insurance"
insert-mode="true"
form="form">
@ -34,7 +34,7 @@
<vn-submit label="Save"></vn-submit>
<vn-button
label="Cancel"
ui-sref="client.card.creditInsurance.insurance.index({classificationId: post.params.classificationId})">
ui-sref="client.card.creditInsurance.insurance.index({classificationId: $ctrl.$params.classificationId})">
</vn-button>
</vn-button-bar>
</form>

View File

@ -2,3 +2,4 @@ Simple ticket: Ticket simple
View consumer report: Ver informe de consumo
From date: Fecha desde
To date: Fecha hasta
Go to user: Ir al usuario

View File

@ -18,6 +18,18 @@
data="countries"
order="country">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="SageTaxTypes"
data="sageTaxTypes"
order="vat">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="SageTransactionTypes"
data="sageTransactionTypes"
order="transaction">
</vn-crud-model>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-horizontal>
@ -44,6 +56,35 @@
rule>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
ng-model="$ctrl.client.sageTaxTypeFk"
data="sageTaxTypes"
show-field="vat"
value-field="id"
label="Sage tax type"
rule>
</vn-autocomplete>
<vn-autocomplete vn-one
ng-model="$ctrl.client.sageTransactionTypeFk"
data="sageTransactionTypes"
show-field="transaction"
value-field="id"
label="Sage transaction type"
rule>
</vn-autocomplete>
<vn-autocomplete vn-one
ng-model="$ctrl.client.transferorFk"
url="Clients/isActive"
search-function="$ctrl.transferorSearchFunction($search)"
where="{id: {neq: $ctrl.client.id}}"
show-field="name"
value-field="id"
label="Previous client"
info="In case of a company succession, specify the grantor company"
rule>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-datalist vn-one
label="Postcode"

View File

@ -163,6 +163,12 @@ export default class Controller extends Section {
this.client.provinceFk = response.provinceFk;
this.client.countryFk = response.countryFk;
}
transferorSearchFunction($search) {
return /^\d+$/.test($search)
? {id: $search}
: {name: {like: '%' + $search + '%'}};
}
}
ngModule.vnComponent('vnClientFiscalData', {

View File

@ -6,3 +6,7 @@ In order to invoice, this field is not consulted, but the consignee's ET. When m
You can use letters and spaces: Se pueden utilizar letras y espacios
Found a client with this data: Se ha encontrado un cliente con estos datos
Found a client with this phone or email: El cliente con id <a href="#!/client/{{clientId}}/summary" target="_blank">{{clientId}}</a> ya tiene este teléfono o email. <br/> ¿Quieres continuar?
Sage tax type: Tipo de impuesto Sage
Sage transaction type: Tipo de transacción Sage
Previous client: Cliente anterior
In case of a company succession, specify the grantor company: En el caso de que haya habido una sucesión de empresa, indicar la empresa cedente

View File

@ -40,8 +40,7 @@
vn-tooltip="Client frozen"
icon="icon-frozen">
</vn-icon-button>
<vn-icon-button
ng-click="$ctrl.filterTickets(client, $event)"
<vn-icon-button vn-anchor="{state: 'ticket.index', params: {q: {clientFk: client.id}}}"
vn-tooltip="Client tickets"
icon="icon-ticket">
</vn-icon-button>

View File

@ -119,7 +119,7 @@
</vn-td>
<vn-td actions>
<vn-icon-button
vn-click-stop="$ctrl.goToLines(ticket.id)"
vn-anchor="{state: 'ticket.card.sale', params: {id: ticket.id}}"
vn-tooltip="Go to lines"
icon="icon-lines">
</vn-icon-button>

View File

@ -114,11 +114,6 @@ export default class Controller extends Section {
return 'warning';
}
goToLines(ticketFk) {
let url = this.$state.href('ticket.card.sale', {id: ticketFk}, {absolute: true});
window.open(url, '_blank');
}
preview(ticket) {
this.selectedTicket = ticket;
this.$.summary.show();

View File

@ -29,7 +29,7 @@
<vn-item-section side>
<vn-icon-button
ng-click="$ctrl.goToTimeControl($event, worker.id)"
vn-tooltip="Preview"
vn-tooltip="Time control"
icon="access_time">
</vn-icon-button>
<vn-icon-button

View File

@ -53,7 +53,7 @@
"babel-preset-es2015": "^6.24.1",
"css-loader": "^2.1.0",
"del": "^2.2.2",
"eslint": "^5.14.0",
"eslint": "^7.11.0",
"eslint-config-google": "^0.11.0",
"eslint-plugin-jasmine": "^2.10.1",
"fancy-log": "^1.3.2",