This commit is contained in:
parent
c37bbfbe75
commit
2a6b7b02a2
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref, computed, onMounted, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
|
@ -16,12 +16,19 @@ const { t } = useI18n();
|
|||
|
||||
const route = useRoute();
|
||||
const invoiceId = computed(() => +route.params.id);
|
||||
|
||||
const defaultState = ref();
|
||||
const states = ref();
|
||||
const companies = ref([]);
|
||||
const companiesRef = ref();
|
||||
const warehouses = ref([]);
|
||||
const warehousesRef = ref();
|
||||
const deliveryNoteRef = ref({});
|
||||
|
||||
function setDefaultState(data) {
|
||||
states.value = data;
|
||||
console.log('data: ', data);
|
||||
defaultState.value = data.find((d) => d.state === 'RECIBIDO');
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -40,6 +47,12 @@ const deliveryNoteRef = ref({});
|
|||
@on-fetch="(data) => (warehouses = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="DeliveryNoteStates"
|
||||
:filter="{ fields: ['id', 'state'] }"
|
||||
@on-fetch="(data) => setDefaultState(data)"
|
||||
auto-load
|
||||
/>
|
||||
<FormModel
|
||||
ref="deliveryNoteRef"
|
||||
model="DeliveryNote"
|
||||
|
@ -52,11 +65,11 @@ const deliveryNoteRef = ref({});
|
|||
:label="t('globals.supplier')"
|
||||
v-model="data.supplierFk"
|
||||
/>
|
||||
<!-- por defecto recibido-->
|
||||
<!-- v-model="defaultState" -->
|
||||
<VnSelect
|
||||
:label="t('globals.state')"
|
||||
v-model="data.stateFk"
|
||||
url="DeliveryNoteStates"
|
||||
:options="states"
|
||||
option-label="state"
|
||||
option-value="id"
|
||||
/>
|
||||
|
|
|
@ -48,6 +48,7 @@ defineProps({ dataKey: { type: String, required: true } });
|
|||
option-label="name"
|
||||
option-value="id"
|
||||
filled
|
||||
data-cy="deliveryNote-supplier-filter"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
|
|
@ -47,6 +47,7 @@ const columns = computed(() => [
|
|||
name: 'shipped',
|
||||
label: t('globals.shipped'),
|
||||
component: 'date',
|
||||
cardVisible: true,
|
||||
format: (row) => toDate(row.shipped),
|
||||
},
|
||||
{
|
||||
|
@ -95,7 +96,6 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
name: 'amount',
|
||||
label: t('globals.amount'),
|
||||
isTitle: true,
|
||||
columnFilter: {
|
||||
inWhere: true,
|
||||
},
|
||||
|
@ -183,7 +183,7 @@ watch(
|
|||
</span>
|
||||
</template>
|
||||
<template #column-footer-amount>
|
||||
<span class="q-pr-xs">
|
||||
<span class="q-pr-xs" data-cy="deliveryNote-total-amount">
|
||||
{{}}
|
||||
{{ toCurrency(round(totalAmount ?? 0)) }}
|
||||
</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