diff --git a/src/pages/POS/Inventory/CreateModal.vue b/src/pages/POS/Inventory/CreateModal.vue
index f8198a3..aea0884 100644
--- a/src/pages/POS/Inventory/CreateModal.vue
+++ b/src/pages/POS/Inventory/CreateModal.vue
@@ -23,7 +23,6 @@ const form = useForm({
sku: '',
barcode: '',
category_id: '',
- cost: 0,
retail_price: 0,
tax: 16
});
@@ -157,22 +156,6 @@ watch(() => props.show, (newValue) => {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -211,13 +346,13 @@ watch(() => form.warehouse_from_id, (newWarehouseId, oldWarehouseId) => {
PRODUCTOS
-
- Agregar producto
-
+
+ Agregar producto
+
@@ -228,23 +363,82 @@ watch(() => form.warehouse_from_id, (newWarehouseId, oldWarehouseId) => {
>
-
+
-
+
+
+
+
+ {{ item.product_name }}
+
+
{{ item.product_sku }}
+
+
+
+
+
+
+
+
{ currentSearchIndex = index; productSuggestions.length > 0 && (showProductSuggestions = true); }"
+ type="text"
+ placeholder="Buscar por código de barras o nombre..."
+ class="w-full px-2 py-1.5 pr-8 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
+ :class="{
+ 'border-red-500 focus:ring-red-500 focus:border-red-500': productNotFound && currentSearchIndex === index
+ }"
+ :disabled="searchingProduct"
+ />
+
+
+
+
+
+
+
+
+
+
+
+ {{ product.name }}
+
+
+ SKU: {{ product.sku }}
+
+
+
+
+
+
+
+
+
+ Producto no encontrado
+
+
+
+
-
+
@@ -258,6 +452,21 @@ watch(() => form.warehouse_from_id, (newWarehouseId, oldWarehouseId) => {
/>
+
+
+
+
+
+
@@ -272,18 +481,31 @@ watch(() => form.warehouse_from_id, (newWarehouseId, oldWarehouseId) => {
+
+
+
+
+ Subtotal:
+
+ {{ formatCurrency(item.quantity * item.unit_cost) }}
+
+
+
-
+
Total de productos: {{ selectedProducts.length }}
-
+
Cantidad total: {{ totalQuantity }}
+
+ Costo total: {{ formatCurrency(totalCost) }}
+
diff --git a/src/services/reportService.js b/src/services/reportService.js
index 0c0f015..127ff7d 100644
--- a/src/services/reportService.js
+++ b/src/services/reportService.js
@@ -74,6 +74,9 @@ const reportService = {
if (filters.category_id) params.push(`category_id=${filters.category_id}`);
if (filters.with_serials_only !== undefined) params.push(`with_serials_only=${filters.with_serials_only ? 'true' : 'false'}`);
if (filters.low_stock_threshold) params.push(`low_stock_threshold=${filters.low_stock_threshold}`);
+ if (filters.fecha_inicio) params.push(`fecha_inicio=${encodeURIComponent(filters.fecha_inicio)}`);
+ if (filters.fecha_fin) params.push(`fecha_fin=${encodeURIComponent(filters.fecha_fin)}`);
+ if (filters.q) params.push(`q=${encodeURIComponent(filters.q)}`);
if (params.length > 0) {
url += `?${params.join('&')}`;
@@ -126,6 +129,74 @@ const reportService = {
}
}
+ return Promise.reject(error);
+ }
+ },
+
+ /**
+ * Exports kardex report to Excel file.
+ * @param {Object} filters - Filters for the export.
+ * @param {number} filters.inventory_id - Product ID (required).
+ * @param {string} filters.fecha_inicio - Start date YYYY-MM-DD (required).
+ * @param {string} filters.fecha_fin - End date YYYY-MM-DD (required).
+ * @param {number|null} filters.warehouse_id - Filter by warehouse.
+ * @param {string|null} filters.movement_type - Filter by type: entry, exit, transfer, sale, return.
+ * @returns {Promise
}
+ */
+ async exportKardexToExcel(filters = {}) {
+ try {
+ let url = apiURL('reports/kardex/excel');
+ const params = [];
+
+ if (filters.inventory_id) params.push(`inventory_id=${filters.inventory_id}`);
+ if (filters.fecha_inicio) params.push(`fecha_inicio=${encodeURIComponent(filters.fecha_inicio)}`);
+ if (filters.fecha_fin) params.push(`fecha_fin=${encodeURIComponent(filters.fecha_fin)}`);
+ if (filters.warehouse_id) params.push(`warehouse_id=${filters.warehouse_id}`);
+ if (filters.movement_type) params.push(`movement_type=${encodeURIComponent(filters.movement_type)}`);
+
+ if (params.length > 0) {
+ url += `?${params.join('&')}`;
+ }
+
+ const response = await window.axios.get(url, {
+ responseType: 'blob',
+ headers: {
+ 'Authorization': `Bearer ${sessionStorage.token}`,
+ }
+ });
+
+ const blob = new Blob([response.data], {
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
+ });
+
+ const now = new Date();
+ const timestamp = now.toISOString().split('T')[0];
+ const filename = `kardex_${timestamp}.xlsx`;
+
+ const downloadUrl = window.URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ link.href = downloadUrl;
+ link.download = filename;
+ document.body.appendChild(link);
+ link.click();
+
+ document.body.removeChild(link);
+ window.URL.revokeObjectURL(downloadUrl);
+
+ return Promise.resolve();
+ } catch (error) {
+ console.error('Error al exportar kardex:', error);
+
+ if (error.response && error.response.data instanceof Blob) {
+ const text = await error.response.data.text();
+ try {
+ const json = JSON.parse(text);
+ return Promise.reject(new Error(json.message || 'Error al exportar el kardex'));
+ } catch {
+ return Promise.reject(new Error('Error al exportar el kardex'));
+ }
+ }
+
return Promise.reject(error);
}
}