2118 - Create new intrastat
gitea/salix/2113-item_data_add_instrastat There was a failure building this commit
Details
gitea/salix/2113-item_data_add_instrastat There was a failure building this commit
Details
This commit is contained in:
parent
d9ed7cda38
commit
844b27acb9
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES ('Intrastat', '*', '*', 'ALLOW', 'ROLE', 'buyer');
|
|
@ -0,0 +1,23 @@
|
|||
ALTER TABLE `vn`.`taxClassCode`
|
||||
DROP FOREIGN KEY `taxClassCode_ibfk_2`,
|
||||
DROP FOREIGN KEY `taxClassCode_ibfk_1`;
|
||||
ALTER TABLE `vn`.`taxClassCode`
|
||||
ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST,
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`id`),
|
||||
DROP INDEX `iva_codigo_id` ;
|
||||
|
||||
ALTER TABLE `vn`.`taxClassCode`
|
||||
ADD UNIQUE INDEX `taxClassCode_unique` (`taxClassFk` ASC, `effectived` ASC, `taxCodeFk` ASC) VISIBLE;
|
||||
|
||||
ALTER TABLE `vn`.`taxClassCode`
|
||||
ADD CONSTRAINT `taxClassCode_taxClassFk`
|
||||
FOREIGN KEY (`taxClassFk`)
|
||||
REFERENCES `vn`.`taxClass` (`id`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `taxClassCode_taxCodeFk`
|
||||
FOREIGN KEY (`taxCodeFk`)
|
||||
REFERENCES `vn`.`taxCode` (`id`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
|
@ -687,6 +687,12 @@ INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`)
|
|||
(1, 'Reduced VAT', 'R'),
|
||||
(2, 'General VAT', 'G');
|
||||
|
||||
INSERT INTO `vn`.`taxClassCode`(`id`, `taxClassFk`, `effectived`, `taxCodeFk`)
|
||||
VALUES
|
||||
(1, 1, CURDATE(), 1),
|
||||
(2, 1, CURDATE(), 21),
|
||||
(3, 2, CURDATE(), 2);
|
||||
|
||||
INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`)
|
||||
VALUES
|
||||
(05080000, 'Coral y materiales similares', 2, 2),
|
||||
|
|
|
@ -262,6 +262,10 @@ export default {
|
|||
longName: 'vn-textfield[ng-model="$ctrl.item.longName"]',
|
||||
isActiveCheckbox: 'vn-check[label="Active"]',
|
||||
priceInKgCheckbox: 'vn-check[label="Price in kg"]',
|
||||
newIntrastatButton: 'vn-item-basic-data vn-icon-button[vn-tooltip="New intrastat"] > button',
|
||||
newIntrastatId: '.vn-dialog.shown vn-input-number[ng-model="$ctrl.newIntrastat.intrastatId"]',
|
||||
newIntrastatDescription: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newIntrastat.description"]',
|
||||
acceptIntrastatButton: '.vn-dialog.shown button[response="accept"]',
|
||||
submitBasicDataButton: `button[type=submit]`
|
||||
},
|
||||
itemTags: {
|
||||
|
|
|
@ -39,6 +39,26 @@ describe('Item Edit basic data path', () => {
|
|||
expect(result).toEqual('Data saved!');
|
||||
}, 20000);
|
||||
|
||||
it(`should create a new intrastat`, async() => {
|
||||
await page.waitToClick(selectors.itemBasicData.newIntrastatButton);
|
||||
await page.write(selectors.itemBasicData.newIntrastatId, '588420239');
|
||||
await page.write(selectors.itemBasicData.newIntrastatDescription, 'Tropical Flowers');
|
||||
await page.waitToClick(selectors.itemBasicData.acceptIntrastatButton);
|
||||
await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers');
|
||||
let newcode = await page.waitToGetProperty(selectors.itemBasicData.intrastat, 'value');
|
||||
|
||||
expect(newcode).toEqual('588420239 Tropical Flowers');
|
||||
});
|
||||
|
||||
it(`should save with the new intrastat`, async() => {
|
||||
await page.waitFor(250);
|
||||
await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers');
|
||||
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
|
||||
const result = await page.waitForLastSnackbar();
|
||||
|
||||
expect(result).toEqual('Data saved!');
|
||||
});
|
||||
|
||||
it(`should confirm the item name was edited`, async() => {
|
||||
await page.reloadSection('item.card.basicData');
|
||||
const result = await page.waitToGetProperty(selectors.itemBasicData.name, 'value');
|
||||
|
@ -53,11 +73,11 @@ describe('Item Edit basic data path', () => {
|
|||
expect(result).toEqual('Anthurium');
|
||||
});
|
||||
|
||||
it(`should confirm the item intrastad was edited`, async() => {
|
||||
it(`should confirm the item intrastat was edited`, async() => {
|
||||
const result = await page
|
||||
.waitToGetProperty(selectors.itemBasicData.intrastat, 'value');
|
||||
|
||||
expect(result).toEqual('5080000 Coral y materiales similares');
|
||||
expect(result).toEqual('588420239 Tropical Flowers');
|
||||
});
|
||||
|
||||
it(`should confirm the item relevancy was edited`, async() => {
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
let UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('createIntrastat', {
|
||||
description: 'Creates a new item intrastat',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The item id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'intrastatId',
|
||||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'description',
|
||||
type: 'string',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/createIntrastat`,
|
||||
verb: 'PATCH'
|
||||
}
|
||||
});
|
||||
|
||||
Self.createIntrastat = async(id, intrastatId, description) => {
|
||||
const models = Self.app.models;
|
||||
const country = await models.Country.findOne({
|
||||
where: {code: 'ES'}
|
||||
});
|
||||
|
||||
const itemTaxCountry = await models.ItemTaxCountry.findOne({
|
||||
where: {
|
||||
itemFk: id,
|
||||
countryFk: country.id
|
||||
},
|
||||
order: 'effectived DESC'
|
||||
});
|
||||
const taxClassCode = await models.TaxClassCode.findOne({
|
||||
where: {
|
||||
taxClassFk: itemTaxCountry.taxClassFk
|
||||
},
|
||||
order: 'effectived DESC'
|
||||
});
|
||||
|
||||
return models.Intrastat.create({
|
||||
id: intrastatId,
|
||||
description: description,
|
||||
taxClassFk: itemTaxCountry.taxClassFk,
|
||||
taxCodeFk: taxClassCode.taxCodeFk
|
||||
});
|
||||
};
|
||||
};
|
|
@ -55,9 +55,6 @@ module.exports = Self => {
|
|||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'taxClass'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('createIntrastat()', () => {
|
||||
let newIntrastat;
|
||||
|
||||
afterAll(async done => {
|
||||
await app.models.Intrastat.destroyById(newIntrastat.id);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should create a new intrastat', async() => {
|
||||
const intrastatId = 588420239;
|
||||
const description = 'Tropical Flowers';
|
||||
const itemId = 9;
|
||||
newIntrastat = await app.models.Item.createIntrastat(itemId, intrastatId, description);
|
||||
|
||||
expect(newIntrastat.description).toEqual(description);
|
||||
expect(newIntrastat.taxClassFk).toEqual(1);
|
||||
expect(newIntrastat.taxCodeFk).toEqual(21);
|
||||
});
|
||||
});
|
|
@ -62,6 +62,9 @@
|
|||
"TaxClass": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"TaxClassCode": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"TaxCode": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -12,6 +12,7 @@ module.exports = Self => {
|
|||
require('../methods/item/getVisibleAvailable')(Self);
|
||||
require('../methods/item/new')(Self);
|
||||
require('../methods/item/getWasteDetail')(Self);
|
||||
require('../methods/item/createIntrastat')(Self);
|
||||
|
||||
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "TaxClassCode",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "taxClassCode"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"effectived": {
|
||||
"type": "date",
|
||||
"required": true
|
||||
},
|
||||
"taxClassFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"taxCodeFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"taxClass": {
|
||||
"type": "belongsTo",
|
||||
"model": "TaxClass",
|
||||
"foreignKey": "taxClassFk"
|
||||
},
|
||||
"taxCode": {
|
||||
"type": "belongsTo",
|
||||
"model": "TaxCode",
|
||||
"foreignKey": "taxCodeFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`vnItemBasicData Component vnItemBasicData $onChanges() should pass the data to the watcher 1`] = `"the current value of an item"`;
|
|
@ -149,27 +149,19 @@
|
|||
<tpl-body>
|
||||
<h5 class="vn-py-sm" translate>New intrastat</h5>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one vn-focus
|
||||
<vn-input-number vn-one vn-focus
|
||||
label="Identifier"
|
||||
ng-model="$ctrl.newIntrastat.id"
|
||||
ng-model="$ctrl.newIntrastat.intrastatId"
|
||||
required="true">
|
||||
</vn-textfield>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one
|
||||
label="Description"
|
||||
ng-model="$ctrl.newIntrastat.description"
|
||||
required="true">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
url="TaxClasses"
|
||||
label="Tax class"
|
||||
show-field="description"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.newIntrastat.taxClassFk"
|
||||
initial-data="$ctrl.item.taxClass">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
|
|
|
@ -11,9 +11,10 @@ class Controller extends Component {
|
|||
this.$.intrastat.show();
|
||||
}
|
||||
|
||||
onCustomAgentAccept() {
|
||||
return this.$http.post(`CustomsAgents`, this.newCustomsAgent)
|
||||
.then(res => this.address.customsAgentFk = res.data.id);
|
||||
onIntrastatAccept() {
|
||||
const query = `Items/${this.$params.id}/createIntrastat`;
|
||||
return this.$http.patch(query, this.newIntrastat)
|
||||
.then(res => this.item.intrastatFk = res.data.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue