0
1
Fork 0

Merge pull request 'master' (!23) from master into test

Reviewed-on: verdnatura/hedera-web#23
This commit is contained in:
Juan Ferrer 2023-02-23 13:35:17 +00:00
commit 592f79fcbd
12 changed files with 104 additions and 51 deletions

View File

@ -6,19 +6,35 @@ export default new Class({
async open() {
await Hedera.Form.prototype.open.call(this);
this.basket = new Hedera.Basket(this.app);
const basket = new Hedera.Basket(this.app);
this.orderId = this.$.params.$.id || this.basket.orderId;
if (!this.orderId)
return this.hash.setAll({form: 'ecomerce/checkout'});
if (this.$.params.$.id) {
this.orderId = this.$.params.$.id;
} else if (await basket.check()) {
this.orderId = basket.orderId;
}
this.$.lot.assign({id: this.orderId});
if (this.orderId)
this.$.lot.assign({id: this.orderId});
},
activate() {
this.$.items.setInfo('bi', 'myOrderRow', 'hedera');
},
onOrderReady(form) {
if (form.row < 0)
return;
if (form.$.method != 'PICKUP') {
Vn.Node.show(this.$.address);
Vn.Node.setText(this.$.method, _('Agency'));
} else {
Vn.Node.hide(this.$.address);
Vn.Node.setText(this.$.method, _('Warehouse'));
}
},
onConfigureClick() {
Htk.Toast.showWarning(_('RememberReconfiguringImpact'));
this.hash.setAll({

View File

@ -1,13 +1,16 @@
ShoppingBasket: Cistella de la compra
Order: Encàrrec
ShippingInformation: Dades d'enviament
DeliveryAddress: Adreça de lliurament
Delivery at: Lliurament el
Agency: Agència
Warehouse: Magatzem
Delete: Borrar encàrrec
GoToCatalog: Anar al catàleg
ConfigureOrder: Configurar encàrrec
Checkout: Tramitar encàrrec
OrderNumber: N encàrec
DateExit: Data d'eixida
Warehouse: Magatzem
OrderTotal: Total encàrrec
Amount: Quant
Pack: Pack

View File

@ -1,13 +1,16 @@
ShoppingBasket: Shopping basket
Order: Order
ShippingInformation: Shipping information
DeliveryAddress: Delivery address
Delivery at: Delivery at
Agency: Agency
Warehouse: Store
Delete: Delete order
GoToCatalog: Go to catalog
ConfigureOrder: Configure order
Checkout: Checkout
OrderNumber: Order number
DateExit: Shipping date
Warehouse: Store
OrderTotal: Total
Amount: Amount
Pack: Pack

View File

@ -1,13 +1,16 @@
ShoppingBasket: Cesta de la compra
Order: Pedido
ShippingInformation: Datos de envío
DeliveryAddress: Dirección de entrega
Delivery at: Entrega el
Agency: Agencia
Warehouse: Almacén
Delete: Borrar pedido
GoToCatalog: Ir al catálogo
ConfigureOrder: Configurar pedido
Checkout: Finalizar pedido
OrderNumber: Nº pedido
DateExit: Fecha de salida
Warehouse: Almacén
OrderTotal: Total
Amount: Cantidad
Pack: Pack

View File

@ -1,13 +1,16 @@
ShoppingBasket: Panier
Order: Commande
ShippingInformation: Informations sur la livraison
DeliveryAddress: Addresse de livraison
Delivery at: Livraison à
Agency: Agence
Warehouse: Entrepôt
Delete: Effacer
GoToCatalog: Aller au catalogue
ConfigureOrder: Définissez l'ordre
Checkout: Caisse
OrderNumber: Numéro de commande
DateExit: Date de sortie
Warehouse: Magasin
OrderTotal: Total commande
Amount: Quant
Pack: Pack

View File

@ -1,13 +1,16 @@
ShoppingBasket: Cesta da compra
Order: Encomenda
ShippingInformation: Dados de envio
DeliveryAddress: Endereço de entrega
Delivery at: Entrega na
Agency: Agência
Warehouse: Armazém
Delete: Eliminar encomenda
GoToCatalog: Ir ao catálogo
ConfigureOrder: Configurar encomenda
Checkout: Finalizar encomenda
OrderNumber: Nº encomenda
DateExit: Data de saída
Warehouse: Armazém
OrderTotal: Total
Amount: Quantidade
Pack: Pack

View File

@ -21,13 +21,14 @@
</div>
<vn-group>
<vn-lot id="lot"/>
<db-form v-model="order">
<db-form v-model="order" on-ready="onOrderReady">
<db-model property="model" lot="lot">
SELECT o.id, o.sent,
ag.description agency, v.code method, ad.nickname
ag.description agency, v.code method,
ad.nickname, ad.postalCode, ad.city, ad.street
FROM myOrder o
JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk
LEFT JOIN myAddress ad ON ad.id = o.addressFk
JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk
LEFT JOIN myAddress ad ON ad.id = o.addressFk
JOIN vn.deliveryMethod v ON v.id = o.deliveryMethodFk
WHERE o.id = #id;
</db-model>
@ -37,12 +38,21 @@
<div class="box vn-w-sm vn-pa-lg">
<div class="head vn-pb-lg">
<h5>#{{order.id}}</h5>
<div class="vn-mt-md">
<div class="delivery">
<h6><t>ShippingInformation</t></h6>
<p></p>
<p><t>Delivery at</t> {{Vn.Value.format(order.sent, _('%D'))}}</p>
<p><span id="method"><t>Agency</t></span> {{order.agency}}</p>
<p>{{order.nickname}}</p>
<p>
<t>Delivery at</t> {{Vn.Value.format(order.sent, _('%D'))}}
</p>
<p>
<span id="method"><t>Agency</t></span> {{order.agency}}
</p>
</div>
<div id="address" class="address vn-mt-md">
<h6><t>DeliveryAddress</t></h6>
<p>{{order.nickname}}</p>
<p>{{order.street}}</p>
<p>{{order.postalCode}}, {{order.city}}</p>
</div>
<p class="total">
<t>Total</t>

View File

@ -7,15 +7,11 @@ const Catalog = new Class({
,_menuShown: false
,async open() {
let isOk = true;
const basket = new Hedera.Basket(this.app);
this.orderId = basket.orderId;
if (!localStorage.getItem('hederaGuest')) {
if (!this.orderId)
return this.hash.setAll({form: 'ecomerce/checkout'});
else
isOk = await basket.checkRedirect(this.orderId);
if (await basket.check())
this.orderId = basket.orderId;
} else {
const resultSet = await this.conn.execQuery(
'CALL myOrder_configureForGuest(@orderId); SELECT @orderId;');
@ -24,7 +20,8 @@ const Catalog = new Class({
this.orderId = resultSet.fetchValue();
}
if (isOk) await Hedera.Form.prototype.open.call(this);
if (this.orderId)
await Hedera.Form.prototype.open.call(this);
}
,activate() {

View File

@ -94,10 +94,9 @@
<vn-lot id="order-lot"/>
<db-form v-model="basket">
<db-model property="model" lot="order-lot">
SELECT o.id, o.sent, a.description agency, m.code method
SELECT o.id, o.sent, ad.nickname
FROM myOrder o
JOIN vn.agencyMode a ON a.id = o.agencyModeFk
JOIN vn.deliveryMethod m ON m.id = o.deliveryMethodFk
LEFT JOIN myAddress ad ON ad.id = o.addressFk
WHERE o.id = #orderId
</db-model>
</db-form>
@ -207,11 +206,8 @@
</div>
<div id="right-panel" class="catalog-panel right-panel side-panel" on-click="onRightPanelClick">
<div class="basket-info">
<p>{{basket.nickname}}</p>
<p>{{Vn.Value.format(basket.sent, '%D')}}</p>
<p>
{{_(basket.method != 'PICKUP' ? 'Agency' : 'Warehouse')}}
{{basket.agency}}
</p>
<button class="thin" on-click="this.onConfigureClick()">
<t>Modify</t>
</button>

View File

@ -7,7 +7,7 @@ export default new Class({
async open() {
const basket = new Hedera.Basket(this.app);
try {
await basket.check(this.hash.$.id);
await basket.checkOrder(this.hash.$.id);
} catch (err) {
Htk.Toast.showError(err.message);
}

View File

@ -6,9 +6,9 @@
<db-form v-model="order" on-ready="onOrderReady">
<db-model property="model" result-index="1" lot="params">
CALL myOrder_getTax(#id);
SELECT o.id, o.sent, o.notes, o.companyFk,
ag.description agency, v.code method,
ad.nickname, ad.postalCode, ad.city, ad.street,
SELECT o.id, o.sent, o.notes, o.companyFk,
ag.description agency, v.code method,
ad.nickname, ad.postalCode, ad.city, ad.street,
t.*, c.credit, myClient_getDebt(NULL) debt
FROM myOrder o
JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk
@ -35,8 +35,10 @@
<div class="vn-w-sm">
<div class="box vn-pa-lg summary">
<div>
<h5>#{{order.id}}</h5>
<div class="delivery">
<h6><t>ShippingInformation</t></h6>
<p>{{order.nickname}}</p>
<p>
<t>Delivery at</t> {{Vn.Value.format(order.sent, _('%D'))}}
</p>
@ -46,7 +48,6 @@
</div>
<div id="address" class="address vn-mt-md">
<h6><t>DeliveryAddress</t></h6>
<p>{{order.nickname}}</p>
<p>{{order.street}}</p>
<p>{{order.postalCode}}, {{order.city}}</p>
</div>

View File

@ -6,33 +6,51 @@ module.exports = class {
if (orderId) orderId = parseInt(orderId);
this.orderId = orderId;
}
async check(orderId) {
async checkOrder(orderId) {
const resultSet = await this.app.conn.execQuery(
'CALL myOrder_checkConfig(#id)',
{id: orderId}
);
resultSet.fetchValue();
}
async checkRedirect(orderId) {
async check() {
if (this.orderId) {
return await this.checkRedirect();
} else {
this.app.hash.setAll({form: 'ecomerce/checkout'});
return false;
}
}
async checkRedirect() {
try {
await this.check(orderId);
await this.checkOrder(this.orderId);
return true;
} catch(err) {
Htk.Toast.showError(err.message);
this.app.hash.setAll({
form: 'ecomerce/checkout',
id: orderId,
continue: 'catalog'
});
return false;
if (err.exception == 'Vn.Lib.UserError') {
const dst = {
form: 'ecomerce/checkout',
continue: 'catalog'
};
if (err.code == 'orderNotOwnedByUser') {
this.constructor.unload();
} else {
dst.id = this.orderId;
Htk.Toast.showError(err.message);
}
this.app.hash.setAll(dst);
return false;
} else
throw err;
}
}
async load(orderId) {
this.loadIntoBasket(orderId);
if (!await this.checkRedirect(orderId)) return;
this.app.hash.setAll({
form: 'ecomerce/catalog'
});
if (await this.checkRedirect())
this.app.hash.setAll({
form: 'ecomerce/catalog'
});
}
loadIntoBasket(orderId) {
if (this.orderId != orderId) {