From bd46a77cb7160325f373d141720f53bccd9b60cd Mon Sep 17 00:00:00 2001
From: carlossa
Date: Tue, 3 Oct 2023 10:15:16 +0200
Subject: [PATCH] refs #5768 incoterms addressFk
---
modules/client/front/sample/create/index.html | 29 ++++++++--
modules/client/front/sample/create/index.js | 56 ++++++++++++++++++-
.../incoterms-authorization.html | 5 +-
.../incoterms-authorization.js | 5 +-
.../incoterms-authorization/locale/es.yml | 2 +-
.../incoterms-authorization/sql/address.sql | 9 +++
.../incoterms-authorization/sql/company.sql | 4 +-
7 files changed, 95 insertions(+), 15 deletions(-)
create mode 100644 print/templates/reports/incoterms-authorization/sql/address.sql
diff --git a/modules/client/front/sample/create/index.html b/modules/client/front/sample/create/index.html
index 134c097e8..f9db03036 100644
--- a/modules/client/front/sample/create/index.html
+++ b/modules/client/front/sample/create/index.html
@@ -13,6 +13,7 @@
'description',
'model',
'hasCompany',
+ 'hasAddress',
'hasPreview',
'datepickerEnabled'
]"
@@ -69,15 +70,31 @@
ng-if="sampleType.selection.hasCompany"
required="true">
-
+ ng-model="$ctrl.addressId"
+ model="ClientSample.addressFk"
+ order="isActive DESC">
+
+ {{::!isActive ? '(Inactive)' : ''}}
+ {{::nickname}}
+
+ , {{::street}}, {{::city}}, {{::province.name}} - {{::agencyMode.name}}
+
+
+
+
+
+
+
{
+ if (res.data)
+ this.addresses = res.data;
+ });
+ }
+
+ getClientDefaultAddress(value) {
+ let query = `Clients/${value}`;
+ this.$http.get(query).then(res => {
+ if (res.data)
+ this.addressId = res.data.defaultAddressFk;
+ });
+ }
}
Controller.$inject = ['$element', '$scope', 'vnEmail'];
diff --git a/print/templates/reports/incoterms-authorization/incoterms-authorization.html b/print/templates/reports/incoterms-authorization/incoterms-authorization.html
index 5b4e7829b..e4e4635f3 100644
--- a/print/templates/reports/incoterms-authorization/incoterms-authorization.html
+++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.html
@@ -5,7 +5,7 @@
v-html="$t('description', {
socialName: client.socialName,
name: client.name,
- address: client.street,
+ addressId: address.street,
country: client.country,
fiscalID: client.fi
})"
@@ -21,8 +21,7 @@
companyName: company.name,
companyCity: company.city,
socialName: client.socialName,
- destinationCountry: client.country,
- incotermsFk: address.incotermsFk
+ destinationCountry: client.country
})"
>
diff --git a/print/templates/reports/incoterms-authorization/incoterms-authorization.js b/print/templates/reports/incoterms-authorization/incoterms-authorization.js
index 0fbbd10d2..e50cd99ec 100755
--- a/print/templates/reports/incoterms-authorization/incoterms-authorization.js
+++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.js
@@ -7,6 +7,7 @@ module.exports = {
this.client = await this.findOneFromDef('client', [this.id]);
this.checkMainEntity(this.client);
this.company = await this.findOneFromDef('company', [this.companyId]);
+ this.address = await this.findOneFromDef('address', [this.addressId]);
},
props: {
id: {
@@ -18,8 +19,8 @@ module.exports = {
type: Number,
required: true
},
- address: {
- type: String
+ addressId: {
+ type: Number
}
}
};
diff --git a/print/templates/reports/incoterms-authorization/locale/es.yml b/print/templates/reports/incoterms-authorization/locale/es.yml
index 8bdce7085..ef63e9e3c 100644
--- a/print/templates/reports/incoterms-authorization/locale/es.yml
+++ b/print/templates/reports/incoterms-authorization/locale/es.yml
@@ -6,7 +6,7 @@ issued: 'En {0}, a {1} de {2} de {3}'
client: 'Cliente {0}'
declaration: '{socialName} declara por la presente que:'
declarations:
- - 'Todas las compras realizadas por {socialName} con {companyName} se entregan según las condiciones definidas en el incoterm {incotermsFk} ({Incoterm description}).'
+ - 'Todas las compras realizadas por {socialName} con {companyName} se entregan según las condiciones definidas en el incoterm.'
- '{socialName} reconoce que es importante para {companyName} tener
comprobante de la entrega intracomunitaria de la mercancía a {destinationCountry} para
poder facturar con 0% de IVA.'
diff --git a/print/templates/reports/incoterms-authorization/sql/address.sql b/print/templates/reports/incoterms-authorization/sql/address.sql
new file mode 100644
index 000000000..a432c5e53
--- /dev/null
+++ b/print/templates/reports/incoterms-authorization/sql/address.sql
@@ -0,0 +1,9 @@
+SELECT
+ a.nickname,
+ a.street,
+ a.postalCode,
+ a.city,
+ p.name province
+FROM address a
+ LEFT JOIN province p ON p.id = a.provinceFk
+WHERE a.id = ?
diff --git a/print/templates/reports/incoterms-authorization/sql/company.sql b/print/templates/reports/incoterms-authorization/sql/company.sql
index 39c3290d1..8d94859e1 100644
--- a/print/templates/reports/incoterms-authorization/sql/company.sql
+++ b/print/templates/reports/incoterms-authorization/sql/company.sql
@@ -1,8 +1,8 @@
-SELECT
+SELECT
s.name,
s.city,
cl.name AS manager
FROM company c
JOIN supplier s ON s.id = c.id
JOIN client cl ON cl.id = c.workerManagerFk
-WHERE c.id = ?
\ No newline at end of file
+WHERE c.id = ?