diff --git a/src/pages/Item/Card/ItemLastEntries.vue b/src/pages/Item/Card/ItemLastEntries.vue
index 22fb9adc7..57af032db 100644
--- a/src/pages/Item/Card/ItemLastEntries.vue
+++ b/src/pages/Item/Card/ItemLastEntries.vue
@@ -5,17 +5,29 @@ import { useRoute } from 'vue-router';
import { dateRange } from 'src/filters';
import EntryDescriptorProxy from 'src/pages/Entry/Card/EntryDescriptorProxy.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
+import VnDateBadge from 'src/components/common/VnDateBadge.vue';
import { useStateStore } from 'stores/useStateStore';
-import { toDateTimeFormat } from 'src/filters/date.js';
import { dashIfEmpty } from 'src/filters';
import { toCurrency } from 'filters/index';
import { useArrayData } from 'composables/useArrayData';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
+import axios from 'axios';
+import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue';
const { t } = useI18n();
const route = useRoute();
const stateStore = useStateStore();
+const from = ref();
+const to = ref();
+const hideInventory = ref(true);
+const inventorySupplierFk = ref();
+
+async function getInventorySupplier() {
+ inventorySupplierFk.value = (
+ await axios.get(`InventoryConfigs`)
+ )?.data[0]?.supplierFk;
+}
const exprBuilder = (param, value) => {
switch (param) {
@@ -36,25 +48,29 @@ const exprBuilder = (param, value) => {
}
};
-const from = ref();
-const to = ref();
+const where = {
+ itemFk: route.params.id,
+};
+
+if (hideInventory.value) {
+ console.log('entra');
+ where.supplierFk = { neq: inventorySupplierFk };
+ console.log('where: ', where.supplierFk);
+}
const arrayData = useArrayData('ItemLastEntries', {
url: 'Items/lastEntriesFilter',
order: ['landed DESC', 'buyFk DESC'],
exprBuilder: exprBuilder,
userFilter: {
- where: {
- itemFk: route.params.id,
- },
+ where: where,
},
});
-
const itemLastEntries = ref([]);
const columns = computed(() => [
{
- label: t('lastEntries.ig'),
+ label: 'Nv',
name: 'ig',
align: 'center',
},
@@ -62,33 +78,38 @@ const columns = computed(() => [
label: t('itemDiary.warehouse'),
name: 'warehouse',
field: 'warehouse',
- align: 'left',
+ align: 'center',
},
{
label: t('lastEntries.landed'),
- name: 'id',
+ name: 'date',
field: 'landed',
- align: 'left',
- format: (val) => toDateTimeFormat(val),
+ align: 'center',
},
{
label: t('lastEntries.entry'),
name: 'entry',
field: 'stateName',
- align: 'left',
+ align: 'center',
format: (val) => dashIfEmpty(val),
},
{
label: t('lastEntries.pvp'),
name: 'pvp',
field: 'reference',
- align: 'left',
+ align: 'center',
format: (_, row) => toCurrency(row.price2) + ' / ' + toCurrency(row.price3),
},
-
+ {
+ label: t('lastEntries.printedStickers'),
+ name: 'printedStickers',
+ field: 'printedStickers',
+ align: 'center',
+ format: (val) => dashIfEmpty(val),
+ },
{
label: t('lastEntries.label'),
- name: 'label',
+ name: 'stickers',
field: 'stickers',
align: 'center',
format: (val) => dashIfEmpty(val),
@@ -96,11 +117,13 @@ const columns = computed(() => [
{
label: t('shelvings.packing'),
name: 'packing',
+ field: 'packing',
align: 'center',
},
{
label: t('lastEntries.grouping'),
name: 'grouping',
+ field: 'grouping',
align: 'center',
},
{
@@ -111,18 +134,19 @@ const columns = computed(() => [
},
{
label: t('lastEntries.quantity'),
- name: 'stems',
+ name: 'quantity',
field: 'quantity',
align: 'center',
},
{
label: t('lastEntries.cost'),
name: 'cost',
- align: 'left',
+ field: 'cost',
+ align: 'center',
},
{
- label: t('lastEntries.kg'),
- name: 'stems',
+ label: 'Kg',
+ name: 'weight',
field: 'weight',
align: 'center',
},
@@ -134,9 +158,9 @@ const columns = computed(() => [
},
{
label: t('lastEntries.supplier'),
- name: 'stems',
+ name: 'supplier',
field: 'supplier',
- align: 'left',
+ align: 'center',
},
]);
@@ -155,16 +179,26 @@ const getDate = (date, type) => {
};
const updateFilter = async () => {
+ console.log('updateFilter: ');
+
let filter;
if (!from.value && to.value) filter = { lte: to.value };
else if (from.value && !to.value) filter = { gte: from.value };
else if (from.value && to.value) filter = { between: [from.value, to.value] };
- arrayData.store.userFilter.where.landed = filter;
+ const userFilter = arrayData.store.userFilter.where;
+
+ userFilter.landed = filter;
+ if (hideInventory.value) userFilter.supplierFk = { neq: inventorySupplierFk };
+ else delete userFilter.supplierFk;
+ console.log('userFilter: ', userFilter);
+
await fetchItemLastEntries();
};
onMounted(async () => {
+ await getInventorySupplier();
+
const _from = Date.vnNew();
_from.setDate(_from.getDate() - 75);
from.value = getDate(_from, 'from');
@@ -174,7 +208,7 @@ onMounted(async () => {
updateFilter();
- watch([from, to], ([nFrom, nTo], [oFrom, oTo]) => {
+ watch([from, to, hideInventory], ([nFrom, nTo], [oFrom, oTo]) => {
if (nFrom && nFrom != oFrom) nFrom = getDate(new Date(nFrom), 'from');
if (nTo && nTo != oTo) nTo = getDate(new Date(nTo), 'to');
updateFilter();
@@ -183,7 +217,6 @@ onMounted(async () => {
onUnmounted(() => (stateStore.rightDrawer = false));
-
@@ -192,27 +225,45 @@ onUnmounted(() => (stateStore.rightDrawer = false));
dense
v-model="from"
class="q-mr-lg"
+ data-cy="from"
+ />
+
+
-
-
-
+
+
+
+
+
+
@@ -234,8 +285,8 @@ onUnmounted(() => (stateStore.rightDrawer = false));
- {{ value }}
+
+ {{ value }}
{{ t('lastEntries.grouping') }}/{{ t('lastEntries.packing') }}
(stateStore.rightDrawer = false));
-
+
{{ toCurrency(row.cost, 'EUR', 3) }}
@@ -272,10 +323,25 @@ onUnmounted(() => (stateStore.rightDrawer = false));
+
+
+
+
+ {{ row.supplier }}
+
+
+
-
+
+ es:
+ Hide inventory supplier: Ocultar proveedor inventario
+
diff --git a/src/pages/Item/Card/ItemSummary.vue b/src/pages/Item/Card/ItemSummary.vue
index db90ba06f..e47d6358a 100644
--- a/src/pages/Item/Card/ItemSummary.vue
+++ b/src/pages/Item/Card/ItemSummary.vue
@@ -46,7 +46,7 @@ const getUrl = (id, param) => `#/Item/${id}/${param}`;
[
},
]);
-const getBadgeAttrs = (date) => {
- let today = Date.vnNew();
- today.setHours(0, 0, 0, 0);
- let timeTicket = new Date(date);
- timeTicket.setHours(0, 0, 0, 0);
-
- let timeDiff = today - timeTicket;
-
- if (timeDiff == 0) return { color: 'warning', 'text-color': 'black' };
- if (timeDiff < 0) return { color: 'success', 'text-color': 'black' };
- return { color: 'transparent', 'text-color': 'white' };
-};
-
let refreshTimer = null;
const autoRefreshHandler = (value) => {
@@ -282,14 +269,6 @@ const totalPriceColor = (ticket) => {
if (total > 0 && total < 50) return 'warning';
};
-const formatShippedDate = (date) => {
- if (!date) return '-';
- const dateSplit = date.split('T');
- const [year, month, day] = dateSplit[0].split('-');
- const newDate = new Date(year, month - 1, day);
- return toDateFormat(newDate);
-};
-
const openTab = (id) =>
window.open(`#/ticket/${id}/sale`, '_blank', 'noopener, noreferrer');
@@ -385,13 +364,7 @@ const openTab = (id) =>
-
- {{ formatShippedDate(row.shippedDate) }}
-
+
diff --git a/test/cypress/integration/item/itemLastEntries.spec.js b/test/cypress/integration/item/itemLastEntries.spec.js
new file mode 100644
index 000000000..c94cfa480
--- /dev/null
+++ b/test/cypress/integration/item/itemLastEntries.spec.js
@@ -0,0 +1,20 @@
+describe('ItemLastEntries', () => {
+ beforeEach(() => {
+ cy.viewport(1280, 720);
+ cy.login('buyer');
+ cy.visit('/#/item/1/last-entries');
+ cy.intercept('GET', /.*lastEntriesFilter/).as('item');
+ cy.waitForElement('tbody');
+ });
+
+ it('should filter by agency', () => {
+ cy.get('tbody > tr')
+ .its('length')
+ .then((rowCount) => {
+ cy.get('[data-cy="hideInventory"]').click();
+ cy.wait('@item');
+ cy.waitForElement('tbody');
+ cy.get('tbody > tr').should('have.length.greaterThan', rowCount);
+ });
+ });
+});