Compare commits

...

5 Commits

Author SHA1 Message Date
Javi Gallego 1963cc2265 log en tablas invoiceIn
gitea/salix/pipeline/head There was a failure building this commit Details
2023-01-25 07:49:51 +01:00
Javi Gallego 3c1f86f171 falta selection
gitea/salix/pipeline/head There was a failure building this commit Details
2022-11-14 17:58:44 +01:00
Javi Gallego bed85c7ddb refs #3074 taxableBase
gitea/salix/pipeline/head This commit looks good Details
2022-11-14 17:27:58 +01:00
Javi Gallego 998f00da49 Merge branch 'dev' into 3074-invoiceIn-Tax-crear-total
gitea/salix/pipeline/head This commit looks good Details
2022-11-14 09:30:13 +01:00
Javi Gallego 00d7ebaabc invoicein tab totalBox
gitea/salix/pipeline/head This commit looks good Details
2022-02-15 08:45:06 +01:00
4 changed files with 47 additions and 17 deletions

View File

@ -1,6 +1,10 @@
{ {
"name": "InvoiceInDueDay", "name": "InvoiceInDueDay",
"base": "VnModel", "base": "Loggable",
"log": {
"model": "InvoiceInLog",
"relation": "invoiceIn"
},
"options": { "options": {
"mysql": { "mysql": {
"table": "invoiceInDueDay" "table": "invoiceInDueDay"
@ -12,9 +16,6 @@
"type": "number", "type": "number",
"description": "Identifier" "description": "Identifier"
}, },
"invoiceInFk": {
"type": "number"
},
"dueDated": { "dueDated": {
"type": "date" "type": "date"
}, },
@ -32,6 +33,11 @@
} }
}, },
"relations": { "relations": {
"invoiceIn": {
"type": "belongsTo",
"model": "InvoiceIn",
"foreignKey": "invoiceInFk"
},
"bank": { "bank": {
"type": "belongsTo", "type": "belongsTo",
"model": "Bank", "model": "Bank",

View File

@ -1,6 +1,10 @@
{ {
"name": "InvoiceInIntrastat", "name": "InvoiceInIntrastat",
"base": "VnModel", "base": "Loggable",
"log": {
"model": "InvoiceInLog",
"relation": "invoiceIn"
},
"options": { "options": {
"mysql": { "mysql": {
"table": "invoiceInIntrastat" "table": "invoiceInIntrastat"
@ -12,9 +16,6 @@
"type": "number", "type": "number",
"description": "Identifier" "description": "Identifier"
}, },
"invoiceInFk": {
"type": "number"
},
"net": { "net": {
"type": "number" "type": "number"
}, },
@ -35,6 +36,11 @@
} }
}, },
"relations": { "relations": {
"invoiceIn": {
"type": "belongsTo",
"model": "InvoiceIn",
"foreignKey": "invoiceInFk"
},
"intrastat": { "intrastat": {
"type": "belongsTo", "type": "belongsTo",
"model": "Intrastat", "model": "Intrastat",

View File

@ -9,6 +9,10 @@
'foreignValue', 'foreignValue',
'taxTypeSageFk', 'taxTypeSageFk',
'transactionTypeSageFk']" 'transactionTypeSageFk']"
include="{
relation: 'taxTypeSage',
scope: {fields: ['id', 'rate']}
}"
link="{invoiceInFk: $ctrl.$params.id}" link="{invoiceInFk: $ctrl.$params.id}"
data="$ctrl.taxes" data="$ctrl.taxes"
auto-load="true"> auto-load="true">
@ -25,6 +29,12 @@
</vn-watcher> </vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()"> <form name="form" ng-submit="$ctrl.onSubmit()">
<vn-card class="vn-pa-lg"> <vn-card class="vn-pa-lg">
<vn-horizontal>
<vn-auto class="totalBox">
<span td class="chip"><vn-label translate>Taxable base</vn-label> {{$ctrl.taxableBase | currency: 'EUR':2 | dashIfEmpty}}</span>
<p><vn-label translate>Total</vn-label> {{$ctrl.totalVat | currency: 'EUR':2 | dashIfEmpty}}</p>
</vn-auto>
</vn-horizontal>
<vn-horizontal ng-repeat="invoiceInTax in $ctrl.taxes"> <vn-horizontal ng-repeat="invoiceInTax in $ctrl.taxes">
<vn-autocomplete vn-three vn-id="expense" vn-focus <vn-autocomplete vn-three vn-id="expense" vn-focus
label="Expense" label="Expense"
@ -55,7 +65,6 @@
show-field="vat" show-field="vat"
fields="['id', 'vat', 'rate']" fields="['id', 'vat', 'rate']"
search-function="{or: [{id: $search}, {vat: {like: '%'+ $search +'%'}}]}" search-function="{or: [{id: $search}, {vat: {like: '%'+ $search +'%'}}]}"
selection="taxRateSelection"
rule> rule>
<tpl-item>{{id}}: {{vat}}</tpl-item> <tpl-item>{{id}}: {{vat}}</tpl-item>
</vn-autocomplete> </vn-autocomplete>
@ -71,7 +80,7 @@
<vn-textfield <vn-textfield
disabled="true" disabled="true"
label="Rate" label="Rate"
field="$ctrl.taxRate(invoiceInTax, taxRateSelection) | currency:'EUR':2"> field="$ctrl.taxRate(invoiceInTax) | currency:'EUR':2">
</vn-textfield> </vn-textfield>
<vn-input-number <vn-input-number
disabled="$ctrl.invoiceIn.currency.code == 'EUR'" disabled="$ctrl.invoiceIn.currency.code == 'EUR'"

View File

@ -3,18 +3,27 @@ import Section from 'salix/components/section';
import UserError from 'core/lib/user-error'; import UserError from 'core/lib/user-error';
class Controller extends Section { class Controller extends Section {
constructor($element, $, vnWeekDays) { constructor($element, $) {
super($element, $); super($element, $);
this.expense = {}; this.expense = {};
} }
taxRate(invoiceInTax, taxRateSelection) {
const taxTypeSage = taxRateSelection && taxRateSelection.rate;
const taxableBase = invoiceInTax && invoiceInTax.taxableBase;
if (taxTypeSage && taxableBase) taxRate(tax) {
return (taxTypeSage / 100) * taxableBase; if (!tax || !tax.taxTypeSage) return 0;
return (tax.taxTypeSage.rate / 100) * tax.taxableBase;
}
return 0; get taxableBase() {
if (!this.taxes) return;
return this.taxes.reduce(
(a, tax) => a + (tax.taxableBase || 0), 0);
}
get totalVat() {
if (!this.taxes) return;
const tax = this.taxes.reduce(
(a, tax) => a + this.taxRate(tax), 0);
return this.taxableBase + tax;
} }
add() { add() {