feat(invoiceIn): add section intrastat
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3e33436bf6
commit
d7f252a57d
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO salix.ACL
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,22 @@
|
|||
DROP VIEW `vn`.`invoiceInIntrastat__`;
|
||||
RENAME TABLE `vn`.`invoiceInIntrastat` TO `vn`.`invoiceInIntrastat__`;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER=`root`@`localhost`
|
||||
VIEW `vn`.`invoiceInIntrastat` AS
|
||||
SELECT
|
||||
`id`.`id` AS `id`,
|
||||
`id`.`recibida_id` AS `invoiceInFk`,
|
||||
`id`.`neto` AS `net`,
|
||||
`id`.`intrastat_id` AS `intrastatFk`,
|
||||
`id`.`importe` AS `amount`,
|
||||
`id`.`unidades` AS `stems`,
|
||||
`id`.`Paises_Id` AS `countryFk`,
|
||||
`id`.`odbc_date` AS `dated`,
|
||||
`id`.`valorestadistico` AS `statisticalValue`
|
||||
FROM
|
||||
`vn2008`.`intrastat_data` `id`;
|
||||
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee');
|
|
@ -64,6 +64,34 @@ module.exports = Self => {
|
|||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'invoiceInIntrastat',
|
||||
scope: {
|
||||
fields: [
|
||||
'id',
|
||||
'invoiceInFk',
|
||||
'net',
|
||||
'intrastatFk',
|
||||
'amount',
|
||||
'stems',
|
||||
'countryFk',
|
||||
'statisticalValue'],
|
||||
include: [{
|
||||
relation: 'intrastat',
|
||||
scope: {
|
||||
fields: [
|
||||
'id',
|
||||
'description']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
fields: ['code']
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'invoiceInTax',
|
||||
scope: {
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
"InvoiceInDueDay": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"InvoiceInIntrastat": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"InvoiceInLog": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "InvoiceInIntrastat",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "invoiceInIntrastat"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"invoiceInFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"net": {
|
||||
"type": "number"
|
||||
},
|
||||
"intrastatFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"amount": {
|
||||
"type": "number"
|
||||
},
|
||||
"stems": {
|
||||
"type": "number"
|
||||
},
|
||||
"countryFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"statisticalValue": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"intrastat": {
|
||||
"type": "belongsTo",
|
||||
"model": "Intrastat",
|
||||
"foreignKey": "intrastatFk"
|
||||
},
|
||||
"country": {
|
||||
"type": "belongsTo",
|
||||
"model": "Country",
|
||||
"foreignKey": "countryFk"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -64,6 +64,11 @@
|
|||
"model": "InvoiceInDueDay",
|
||||
"foreignKey": "invoiceInFk"
|
||||
},
|
||||
"invoiceInIntrastat": {
|
||||
"type": "hasMany",
|
||||
"model": "InvoiceInIntrastat",
|
||||
"foreignKey": "invoiceInFk"
|
||||
},
|
||||
"invoiceInTax": {
|
||||
"type": "hasMany",
|
||||
"model": "InvoiceInTax",
|
||||
|
|
|
@ -10,5 +10,6 @@ import './summary';
|
|||
import './basic-data';
|
||||
import './tax';
|
||||
import './dueDay';
|
||||
import './intrastat';
|
||||
import './create';
|
||||
import './log';
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="InvoiceInIntrastats"
|
||||
data="$ctrl.invoceInIntrastat"
|
||||
link="{invoiceInFk: $ctrl.$params.id}"
|
||||
auto-load="true"
|
||||
on-data-change="$ctrl.calculateTotals()">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Countries"
|
||||
data="countries"
|
||||
order="country">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Intrastats"
|
||||
data="intrastats"
|
||||
order="id">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.invoceInIntrastat"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<vn-card
|
||||
class="vn-mb-md vn-pa-lg vn-w-lg"
|
||||
style="text-align: right"
|
||||
ng-if="$ctrl.invoceInIntrastat.length > 0">
|
||||
<vn-label-value label="Total amount"
|
||||
value="{{$ctrl.amountTotal | currency: 'EUR':2}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Total net"
|
||||
value="{{$ctrl.netTotal}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Total stems"
|
||||
value="{{$ctrl.stemsTotal}}">
|
||||
</vn-label-value>
|
||||
</vn-card>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal ng-repeat="intrastat in $ctrl.invoceInIntrastat">
|
||||
<vn-autocomplete vn-three
|
||||
label="Code"
|
||||
data="intrastats"
|
||||
ng-model="intrastat.intrastatFk"
|
||||
show-field="description"
|
||||
rule>
|
||||
<tpl-item>{{id | zeroFill:8}}: {{description}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-input-number
|
||||
label="Amount"
|
||||
ng-model="intrastat.amount"
|
||||
step="0.01"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
label="Net"
|
||||
ng-model="intrastat.net"
|
||||
step="0.01"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
label="Units"
|
||||
ng-model="intrastat.stems"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-input-number>
|
||||
<vn-autocomplete
|
||||
label="Country"
|
||||
data="countries"
|
||||
ng-model="intrastat.countryFk"
|
||||
show-field="code"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-none>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove due day"
|
||||
icon="delete"
|
||||
ng-click="$ctrl.deleteIntrastat($index)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-icon-button
|
||||
vn-bind="+"
|
||||
vn-tooltip="Add due day"
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.add()">
|
||||
</vn-icon-button>
|
||||
</vn-one>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -0,0 +1,60 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
set invoceInIntrastat(value) {
|
||||
this._invoceInIntrastat = value;
|
||||
|
||||
if (value) this.calculateTotals();
|
||||
}
|
||||
|
||||
get invoceInIntrastat() {
|
||||
return this._invoceInIntrastat;
|
||||
}
|
||||
|
||||
calculateTotals() {
|
||||
this.amountTotal = 0.0;
|
||||
this.netTotal = 0.0;
|
||||
this.stemsTotal = 0.0;
|
||||
if (!this._invoceInIntrastat) return;
|
||||
|
||||
this._invoceInIntrastat.forEach(intrastat => {
|
||||
this.amountTotal += intrastat.amount;
|
||||
this.netTotal += intrastat.net;
|
||||
this.stemsTotal += intrastat.stems;
|
||||
});
|
||||
}
|
||||
|
||||
add() {
|
||||
this.$.model.insert({});
|
||||
}
|
||||
|
||||
deleteIntrastat($index) {
|
||||
this.$.model.remove($index);
|
||||
this.$.model.save().then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.calculateTotals();
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.check();
|
||||
this.$.model.save().then(() => {
|
||||
this.$.watcher.notifySaved();
|
||||
this.$.watcher.updateOriginalData();
|
||||
this.calculateTotals();
|
||||
this.card.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnInvoiceInIntrastat', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
require: {
|
||||
card: '^vnInvoiceInCard'
|
||||
},
|
||||
bindings: {
|
||||
invoiceIn: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,55 @@
|
|||
import './index.js';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('InvoiceIn', () => {
|
||||
describe('Component intrastat', () => {
|
||||
let controller;
|
||||
let $scope;
|
||||
let vnApp;
|
||||
|
||||
beforeEach(ngModule('invoiceIn'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _vnApp_) => {
|
||||
vnApp = _vnApp_;
|
||||
jest.spyOn(vnApp, 'showError');
|
||||
$scope = $rootScope.$new();
|
||||
$scope.model = crudModel;
|
||||
$scope.watcher = watcher;
|
||||
|
||||
const $element = angular.element('<vn-invoice-in-intrastat></vn-invoice-in-intrastat>');
|
||||
controller = $componentController('vnInvoiceInIntrastat', {$element, $scope});
|
||||
controller.invoiceIn = {id: 1};
|
||||
}));
|
||||
|
||||
describe('calculateTotals()', () => {
|
||||
it('should set amountTotal, netTotal and stemsTotal to 0 if salesClaimed has no data', () => {
|
||||
controller.invoceInIntrastat = [];
|
||||
controller.calculateTotals();
|
||||
|
||||
expect(controller.amountTotal).toEqual(0);
|
||||
expect(controller.netTotal).toEqual(0);
|
||||
expect(controller.stemsTotal).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should make HTTP POST request to save intrastat values', () => {
|
||||
controller.card = {reload: () => {}};
|
||||
jest.spyOn($scope.watcher, 'check');
|
||||
jest.spyOn($scope.watcher, 'notifySaved');
|
||||
jest.spyOn($scope.watcher, 'updateOriginalData');
|
||||
jest.spyOn(controller.card, 'reload');
|
||||
jest.spyOn($scope.model, 'save');
|
||||
|
||||
controller.onSubmit();
|
||||
|
||||
expect($scope.model.save).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.check).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.notifySaved).toHaveBeenCalledWith();
|
||||
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -9,10 +9,14 @@ InvoiceIn cloned: Factura clonada
|
|||
InvoiceIn deleted: Factura eliminada
|
||||
Invoice list: Listado de facturas recibidas
|
||||
InvoiceIn booked: Factura contabilizada
|
||||
Net: Neto
|
||||
Remove tax: Quitar iva
|
||||
Remove due day: Quitar vencimiento
|
||||
Sage tax: Sage iva
|
||||
Sage transaction: Sage transaccion
|
||||
Search invoices in by reference: Buscar facturas recibidas por referencia
|
||||
To book: Contabilizar
|
||||
|
||||
Total amount: Total importe
|
||||
Total net: Total neto
|
||||
Total stems: Total unidades
|
||||
Units: Unidades
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
"state": "invoiceIn.card.dueDay",
|
||||
"icon": "icon-calendar"
|
||||
},
|
||||
{
|
||||
"state": "invoiceIn.card.intrastat",
|
||||
"icon": "icon-lines"
|
||||
},
|
||||
{
|
||||
"state": "invoiceIn.card.log",
|
||||
"icon": "history"
|
||||
|
@ -109,6 +113,16 @@
|
|||
},
|
||||
"acl": ["administrative"]
|
||||
},
|
||||
{
|
||||
"url": "/intrastat",
|
||||
"state": "invoiceIn.card.intrastat",
|
||||
"component": "vn-invoice-in-intrastat",
|
||||
"description": "Intrastat",
|
||||
"params": {
|
||||
"invoice-in": "$ctrl.invoiceIn"
|
||||
},
|
||||
"acl": ["administrative"]
|
||||
},
|
||||
{
|
||||
"url": "/log",
|
||||
"state": "invoiceIn.card.log",
|
||||
|
|
|
@ -120,6 +120,37 @@
|
|||
</vn-table>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-one ng-if="$ctrl.summary.invoiceInIntrastat.length != 0">
|
||||
<h4>
|
||||
<a
|
||||
ui-sref="invoiceIn.card.intrastat({id:$ctrl.invoiceIn.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Intrastat</span>
|
||||
</a>
|
||||
</h4>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th>Code</vn-th>
|
||||
<vn-th>Amount</vn-th>
|
||||
<vn-th>Net</vn-th>
|
||||
<vn-th>Units</vn-th>
|
||||
<vn-th>Country</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="intrastat in $ctrl.summary.invoiceInIntrastat">
|
||||
<vn-td>{{::intrastat.intrastatFk | zeroFill:8}}: {{::intrastat.intrastat.description}}</vn-td>
|
||||
<vn-td>{{::intrastat.amount | currency: 'EUR':2}}</vn-td>
|
||||
<vn-td>{{::intrastat.net}}</vn-td>
|
||||
<vn-td>{{::intrastat.stems}}</vn-td>
|
||||
<vn-td>{{::intrastat.country.code}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-supplier-descriptor-popover
|
||||
vn-id="supplierDescriptor">
|
||||
|
|
Loading…
Reference in New Issue