Merge pull request '3585-invoiceIn_dueDate' (#872) from 3585-invoiceIn_dueDate into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #872
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
Joan Sanchez 2022-02-08 08:43:40 +00:00
commit b9c83cba1b
10 changed files with 219 additions and 3 deletions

View File

@ -46,6 +46,24 @@ module.exports = Self => {
fields: ['withholding']
}
},
{
relation: 'invoiceInDueDay',
scope: {
fields: [
'id',
'invoiceInFk',
'dueDated',
'bankFk',
'amount',
'foreignValue'],
include: [{
relation: 'bank',
scope: {
fields: ['bank']
}
}]
}
},
{
relation: 'invoiceInTax',
scope: {

View File

@ -30,6 +30,13 @@
"created": {
"type": "date"
}
},
"relations": {
"bank": {
"type": "belongsTo",
"model": "Bank",
"foreignKey": "bankFk"
}
}
}

View File

@ -0,0 +1,68 @@
<vn-crud-model
vn-id="model"
url="InvoiceInDueDays"
data="InvoiceInDueDaysData"
link="{invoiceInFk: $ctrl.$params.id}"
auto-load="true">
</vn-crud-model>
<vn-watcher
vn-id="watcher"
data="InvoiceInDueDaysData"
form="form">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()">
<vn-card class="vn-pa-lg">
<vn-horizontal ng-repeat="invoiceInDueDay in InvoiceInDueDaysData">
<vn-date-picker
vn-one
label="Date"
ng-model="invoiceInDueDay.dueDated"
vn-focus
rule>
</vn-date-picker>
<vn-autocomplete vn-three
label="Bank"
ng-model="invoiceInDueDay.bankFk"
url="Banks"
show-field="bank"
rule>
<tpl-item>{{id}}: {{bank}}</tpl-item>
</vn-autocomplete>
<vn-input-number vn-one
label="Amount"
ng-model="invoiceInDueDay.amount"
step="0.01"
rule
vn-focus>
</vn-input-number>
<vn-input-number
disabled="$ctrl.invoiceIn.currency.code == 'EUR'"
label="Foreign value"
ng-model="invoiceInDueDay.foreignValue"
rule>
</vn-input-number>
<vn-none>
<vn-icon-button
vn-tooltip="Remove due day"
icon="delete"
ng-click="model.remove($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>

View File

@ -0,0 +1,31 @@
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
add() {
this.$.model.insert({
dueDated: new Date(),
bankFk: this.vnConfig.local.bankFk
});
}
onSubmit() {
this.$.watcher.check();
this.$.model.save().then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
this.card.reload();
});
}
}
ngModule.vnComponent('vnInvoiceInDueDay', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnInvoiceInCard'
},
bindings: {
invoiceIn: '<'
}
});

View File

@ -0,0 +1,44 @@
import './index.js';
import watcher from 'core/mocks/watcher';
import crudModel from 'core/mocks/crud-model';
describe('InvoiceIn', () => {
describe('Component due day', () => {
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-due-day></vn-invoice-in-due-day>');
controller = $componentController('vnInvoiceInDueDay', {$element, $scope});
controller.invoiceIn = {id: 1};
}));
describe('onSubmit()', () => {
it('should make HTTP POST request to save due day 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();
});
});
});
});

View File

@ -9,5 +9,6 @@ import './descriptor-popover';
import './summary';
import './basic-data';
import './tax';
import './dueDay';
import './create';
import './log';

View File

@ -1,4 +1,5 @@
Add tax: Añadir iva
Add due day: Añadir vencimiento
Amounts do not match: La BI no coincide con el vencimiento ni con el total
Due day: Vencimiento
Entries list: Listado de entradas
@ -9,6 +10,7 @@ InvoiceIn deleted: Factura eliminada
Invoice list: Listado de facturas recibidas
InvoiceIn booked: Factura contabilizada
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

View File

@ -21,7 +21,11 @@
},
{
"state": "invoiceIn.card.tax",
"icon": "icon-lines"
"icon": "icon-tax"
},
{
"state": "invoiceIn.card.dueDay",
"icon": "icon-calendar"
},
{
"state": "invoiceIn.card.log",
@ -95,6 +99,16 @@
},
"acl": ["administrative"]
},
{
"url": "/dueDay",
"state": "invoiceIn.card.dueDay",
"component": "vn-invoice-in-due-day",
"description": "Due day",
"params": {
"invoice-in": "$ctrl.invoiceIn"
},
"acl": ["administrative"]
},
{
"url": "/log",
"state": "invoiceIn.card.log",

View File

@ -58,7 +58,7 @@
</vn-one>
</vn-horizontal>
</vn-auto>
<vn-one ng-if="$ctrl.summary.invoiceInTax.length != 0">
<h4>
<a
@ -91,6 +91,35 @@
</vn-table>
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one ng-if="$ctrl.summary.invoiceInDueDay.length != 0">
<h4>
<a
ui-sref="invoiceIn.card.dueDay({id:$ctrl.invoiceIn.id})"
target="_self">
<span translate vn-tooltip="Go to">Due day</span>
</a>
</h4>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th>Date</vn-th>
<vn-th>Bank</vn-th>
<vn-th>Amount</vn-th>
<vn-th>Foreign value</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="dueDay in $ctrl.summary.invoiceInDueDay">
<vn-td shrink-date>{{::dueDay.dueDated | date:'dd/MM/yyyy'}}</vn-td>
<vn-td>{{::dueDay.bank.bank}}</vn-td>
<vn-td>{{::dueDay.amount | currency: 'EUR':2}}</vn-td>
<vn-td shrink>{{::dueDay.foreignValue}}</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</vn-one>
</vn-horizontal>
</vn-card>
<vn-supplier-descriptor-popover
vn-id="supplierDescriptor">

View File

@ -8,4 +8,6 @@ Accounted date: Fecha contable
Doc number: Numero documento
Sage withholding: Retención sage
Undeductible VAT: Iva no deducible
Do not match: No coinciden
Do not match: No coinciden
VAT: IVA
Due day: Vencimiento