Compare commits
5 Commits
dev
...
3074-invoi
Author | SHA1 | Date |
---|---|---|
Javi Gallego | 1963cc2265 | |
Javi Gallego | 3c1f86f171 | |
Javi Gallego | bed85c7ddb | |
Javi Gallego | 998f00da49 | |
Javi Gallego | 00d7ebaabc |
|
@ -1,6 +1,10 @@
|
|||
{
|
||||
"name": "InvoiceInDueDay",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model": "InvoiceInLog",
|
||||
"relation": "invoiceIn"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "invoiceInDueDay"
|
||||
|
@ -12,9 +16,6 @@
|
|||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"invoiceInFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"dueDated": {
|
||||
"type": "date"
|
||||
},
|
||||
|
@ -32,6 +33,11 @@
|
|||
}
|
||||
},
|
||||
"relations": {
|
||||
"invoiceIn": {
|
||||
"type": "belongsTo",
|
||||
"model": "InvoiceIn",
|
||||
"foreignKey": "invoiceInFk"
|
||||
},
|
||||
"bank": {
|
||||
"type": "belongsTo",
|
||||
"model": "Bank",
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
{
|
||||
"name": "InvoiceInIntrastat",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model": "InvoiceInLog",
|
||||
"relation": "invoiceIn"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "invoiceInIntrastat"
|
||||
|
@ -12,9 +16,6 @@
|
|||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"invoiceInFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"net": {
|
||||
"type": "number"
|
||||
},
|
||||
|
@ -35,6 +36,11 @@
|
|||
}
|
||||
},
|
||||
"relations": {
|
||||
"invoiceIn": {
|
||||
"type": "belongsTo",
|
||||
"model": "InvoiceIn",
|
||||
"foreignKey": "invoiceInFk"
|
||||
},
|
||||
"intrastat": {
|
||||
"type": "belongsTo",
|
||||
"model": "Intrastat",
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
'foreignValue',
|
||||
'taxTypeSageFk',
|
||||
'transactionTypeSageFk']"
|
||||
include="{
|
||||
relation: 'taxTypeSage',
|
||||
scope: {fields: ['id', 'rate']}
|
||||
}"
|
||||
link="{invoiceInFk: $ctrl.$params.id}"
|
||||
data="$ctrl.taxes"
|
||||
auto-load="true">
|
||||
|
@ -25,6 +29,12 @@
|
|||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()">
|
||||
<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-autocomplete vn-three vn-id="expense" vn-focus
|
||||
label="Expense"
|
||||
|
@ -55,7 +65,6 @@
|
|||
show-field="vat"
|
||||
fields="['id', 'vat', 'rate']"
|
||||
search-function="{or: [{id: $search}, {vat: {like: '%'+ $search +'%'}}]}"
|
||||
selection="taxRateSelection"
|
||||
rule>
|
||||
<tpl-item>{{id}}: {{vat}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
|
@ -71,7 +80,7 @@
|
|||
<vn-textfield
|
||||
disabled="true"
|
||||
label="Rate"
|
||||
field="$ctrl.taxRate(invoiceInTax, taxRateSelection) | currency:'EUR':2">
|
||||
field="$ctrl.taxRate(invoiceInTax) | currency:'EUR':2">
|
||||
</vn-textfield>
|
||||
<vn-input-number
|
||||
disabled="$ctrl.invoiceIn.currency.code == 'EUR'"
|
||||
|
|
|
@ -3,18 +3,27 @@ import Section from 'salix/components/section';
|
|||
import UserError from 'core/lib/user-error';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $, vnWeekDays) {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.expense = {};
|
||||
}
|
||||
taxRate(invoiceInTax, taxRateSelection) {
|
||||
const taxTypeSage = taxRateSelection && taxRateSelection.rate;
|
||||
const taxableBase = invoiceInTax && invoiceInTax.taxableBase;
|
||||
|
||||
if (taxTypeSage && taxableBase)
|
||||
return (taxTypeSage / 100) * taxableBase;
|
||||
taxRate(tax) {
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue