This commit is contained in:
parent
c37bbfbe75
commit
2a6b7b02a2
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, onMounted, watch } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
@ -16,12 +16,19 @@ const { t } = useI18n();
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const invoiceId = computed(() => +route.params.id);
|
const invoiceId = computed(() => +route.params.id);
|
||||||
|
const defaultState = ref();
|
||||||
|
const states = ref();
|
||||||
const companies = ref([]);
|
const companies = ref([]);
|
||||||
const companiesRef = ref();
|
const companiesRef = ref();
|
||||||
const warehouses = ref([]);
|
const warehouses = ref([]);
|
||||||
const warehousesRef = ref();
|
const warehousesRef = ref();
|
||||||
const deliveryNoteRef = ref({});
|
const deliveryNoteRef = ref({});
|
||||||
|
|
||||||
|
function setDefaultState(data) {
|
||||||
|
states.value = data;
|
||||||
|
console.log('data: ', data);
|
||||||
|
defaultState.value = data.find((d) => d.state === 'RECIBIDO');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -40,6 +47,12 @@ const deliveryNoteRef = ref({});
|
||||||
@on-fetch="(data) => (warehouses = data)"
|
@on-fetch="(data) => (warehouses = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="DeliveryNoteStates"
|
||||||
|
:filter="{ fields: ['id', 'state'] }"
|
||||||
|
@on-fetch="(data) => setDefaultState(data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<FormModel
|
<FormModel
|
||||||
ref="deliveryNoteRef"
|
ref="deliveryNoteRef"
|
||||||
model="DeliveryNote"
|
model="DeliveryNote"
|
||||||
|
@ -52,11 +65,11 @@ const deliveryNoteRef = ref({});
|
||||||
:label="t('globals.supplier')"
|
:label="t('globals.supplier')"
|
||||||
v-model="data.supplierFk"
|
v-model="data.supplierFk"
|
||||||
/>
|
/>
|
||||||
<!-- por defecto recibido-->
|
<!-- v-model="defaultState" -->
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('globals.state')"
|
:label="t('globals.state')"
|
||||||
v-model="data.stateFk"
|
v-model="data.stateFk"
|
||||||
url="DeliveryNoteStates"
|
:options="states"
|
||||||
option-label="state"
|
option-label="state"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -48,6 +48,7 @@ defineProps({ dataKey: { type: String, required: true } });
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
filled
|
filled
|
||||||
|
data-cy="deliveryNote-supplier-filter"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
|
|
@ -47,6 +47,7 @@ const columns = computed(() => [
|
||||||
name: 'shipped',
|
name: 'shipped',
|
||||||
label: t('globals.shipped'),
|
label: t('globals.shipped'),
|
||||||
component: 'date',
|
component: 'date',
|
||||||
|
cardVisible: true,
|
||||||
format: (row) => toDate(row.shipped),
|
format: (row) => toDate(row.shipped),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -95,7 +96,6 @@ const columns = computed(() => [
|
||||||
align: 'left',
|
align: 'left',
|
||||||
name: 'amount',
|
name: 'amount',
|
||||||
label: t('globals.amount'),
|
label: t('globals.amount'),
|
||||||
isTitle: true,
|
|
||||||
columnFilter: {
|
columnFilter: {
|
||||||
inWhere: true,
|
inWhere: true,
|
||||||
},
|
},
|
||||||
|
@ -183,7 +183,7 @@ watch(
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template #column-footer-amount>
|
<template #column-footer-amount>
|
||||||
<span class="q-pr-xs">
|
<span class="q-pr-xs" data-cy="deliveryNote-total-amount">
|
||||||
{{}}
|
{{}}
|
||||||
{{ toCurrency(round(totalAmount ?? 0)) }}
|
{{ toCurrency(round(totalAmount ?? 0)) }}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
describe('DelieryNote list', () => {
|
||||||
|
const supplier = 'PLANTS SL';
|
||||||
|
let totalSelectedAmount = 0;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.login('developer');
|
||||||
|
cy.visit('/#/delivery-note/list');
|
||||||
|
cy.dataCy('vn-searchbar_input').type('{enter}');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should show data and then filter by supplier', () => {
|
||||||
|
cy.selectOption('[data-cy="deliveryNote-supplier-filter"]', supplier);
|
||||||
|
cy.dataCy('vnFilterPanel_search').click();
|
||||||
|
cy.validateVnTableRows({ cols: [{ name: 'supplierFk', val: supplier }] });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('click the first two checkboxes and the table footer quantity should match the sum of the checked rows', () => {
|
||||||
|
cy.selectRows([1, 2]);
|
||||||
|
|
||||||
|
[1, 2].forEach((index) => {
|
||||||
|
cy.get(
|
||||||
|
`.q-virtual-scroll__content > :nth-child(${index}) > :nth-child(1) > .q-checkbox > .q-checkbox__inner`,
|
||||||
|
).should('have.class', 'q-checkbox__inner--truthy');
|
||||||
|
});
|
||||||
|
|
||||||
|
const getAmountFromRow = (index) => {
|
||||||
|
return cy
|
||||||
|
.get(
|
||||||
|
`.q-virtual-scroll__content > :nth-child(${index}) [data-col-field="amount"]`,
|
||||||
|
)
|
||||||
|
.invoke('text')
|
||||||
|
.then((text) =>
|
||||||
|
parseFloat(text.replace(/[^\d.,-]/g, '').replace(',', '')),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
getAmountFromRow(1)
|
||||||
|
.then((amount1) => {
|
||||||
|
totalSelectedAmount += amount1;
|
||||||
|
return getAmountFromRow(2);
|
||||||
|
})
|
||||||
|
.then((amount2) => {
|
||||||
|
totalSelectedAmount += amount2;
|
||||||
|
|
||||||
|
cy.log('Total seleccionado:', totalSelectedAmount);
|
||||||
|
|
||||||
|
cy.dataCy('deliveryNote-total-amount')
|
||||||
|
.invoke('text')
|
||||||
|
.then((text) => {
|
||||||
|
const totalFooterAmount = parseFloat(
|
||||||
|
text.replace(/[^\d.,-]/g, '').replace(',', ''),
|
||||||
|
);
|
||||||
|
expect(totalFooterAmount).to.eq(totalSelectedAmount);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue