Merge branch 'main' into streamline_reconciliation_jar_process_#69
This commit is contained in:
commit
eaf1afdcb4
@ -2,36 +2,34 @@
|
|||||||
<v-container>
|
<v-container>
|
||||||
<v-form ref="purchase" v-model="valid" @change="onFormChange">
|
<v-form ref="purchase" v-model="valid" @change="onFormChange">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
v-model="purchase.customer"
|
v-model="purchase.customer"
|
||||||
:items="filteredClients"
|
:items="filteredClients"
|
||||||
:search="client_search"
|
:search="client_search"
|
||||||
no-data-text="No se hallaron clientes"
|
no-data-text="No se hallaron clientes"
|
||||||
item-title="name"
|
item-title="name"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
@update:model-value="onFormChange"
|
@update:model-value="onFormChange"
|
||||||
label="Cliente"
|
label="Cliente"
|
||||||
:rules="[rules.required]"
|
:rules="[rules.required]"
|
||||||
required
|
required
|
||||||
class="mr-4"
|
class="mr-4"
|
||||||
></v-autocomplete>
|
></v-autocomplete>
|
||||||
<v-btn color="primary" @click="openModal">Agregar Cliente</v-btn>
|
<v-btn color="primary" @click="openModal">Agregar Cliente</v-btn>
|
||||||
<CreateCustomerModal ref="customerModal" @customerCreated="handleNewCustomer"/>
|
<CreateCustomerModal ref="customerModal" @customerCreated="handleNewCustomer"/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col
|
<v-col lg="4">
|
||||||
lg="2"
|
<v-text-field
|
||||||
>
|
v-model="purchase.date"
|
||||||
<v-text-field
|
label="Fecha"
|
||||||
v-model="purchase.date"
|
type="datetime-local"
|
||||||
label="Fecha"
|
:rules="[rules.required]"
|
||||||
type="date"
|
required
|
||||||
:rules="[rules.required]"
|
readonly
|
||||||
required
|
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model="purchase.notes"
|
v-model="purchase.notes"
|
||||||
label="Notas"
|
label="Notas"
|
||||||
@ -44,7 +42,8 @@
|
|||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
<v-container v-for="(line, index) in purchase.saleline_set" :key="line.id">
|
<v-container v-for="(line, index) in purchase.saleline_set" :key="line.id">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col
|
||||||
|
lg="9">
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
v-model="line.product"
|
v-model="line.product"
|
||||||
:items="filteredProducts"
|
:items="filteredProducts"
|
||||||
@ -63,6 +62,19 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-autocomplete>
|
</v-autocomplete>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
<v-col
|
||||||
|
lg="2"
|
||||||
|
>
|
||||||
|
<v-text-field
|
||||||
|
v-model.number="line.quantity"
|
||||||
|
label="Cantidad"
|
||||||
|
type="number"
|
||||||
|
:rules="[rules.required,rules.positive]"
|
||||||
|
required
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model.number="line.unit_price"
|
v-model.number="line.unit_price"
|
||||||
@ -74,15 +86,6 @@
|
|||||||
readonly
|
readonly
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
|
||||||
<v-text-field
|
|
||||||
v-model.number="line.quantity"
|
|
||||||
label="Cantidad"
|
|
||||||
type="number"
|
|
||||||
:rules="[rules.required]"
|
|
||||||
required
|
|
||||||
></v-text-field>
|
|
||||||
</v-col>
|
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="line.measuring_unit"
|
v-model="line.measuring_unit"
|
||||||
@ -171,17 +174,18 @@
|
|||||||
saleline_set: [{product:'', unit_price: 0, quantity: 0, unit: ''}],
|
saleline_set: [{product:'', unit_price: 0, quantity: 0, unit: ''}],
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
required: value => !!value || 'Requerido.',
|
required: value => !!value || 'Requerido.',
|
||||||
|
positive: value => value > 0 || 'La cantidad debe ser mayor que 0.',
|
||||||
},
|
},
|
||||||
menuItems: [
|
menuItems: [
|
||||||
{ title: 'Inicio', route: '/'},
|
{ title: 'Inicio', route: '/'},
|
||||||
{ title: 'Compras', route:'/compras'},
|
{ title: 'Compras', route:'/compras'},
|
||||||
],
|
],
|
||||||
clients: [],
|
clients: [],
|
||||||
products: [],
|
products: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.fetchClients();
|
this.fetchClients();
|
||||||
this.fetchProducts();
|
this.fetchProducts();
|
||||||
this.fetchPaymentMethods();
|
this.fetchPaymentMethods();
|
||||||
@ -241,15 +245,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getCurrentDate() {
|
getCurrentDate() {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const yyyy = today.getFullYear();
|
const gmtOffSet = -5;
|
||||||
const mm = String(today.getMonth() + 1).padStart(2, '0');
|
const localDate = new Date(today.getTime() + (gmtOffSet * 60 * 60 * 1000));
|
||||||
const dd = String(today.getDate()).padStart(2, '0');
|
// Formatear la fecha y hora en el formato YYYY-MM-DDTHH:MM
|
||||||
return `${yyyy}-${mm}-${dd}`;
|
const formattedDate = localDate.toISOString().slice(0,16);
|
||||||
|
return formattedDate;
|
||||||
},
|
},
|
||||||
|
onProductChange(index) {
|
||||||
onProductChange(index) {
|
const selectedProductId = this.purchase.saleline_set[index].product;
|
||||||
const selectedProductId = this.purchase.saleline_set[index].product;
|
|
||||||
const selectedProduct = this.products.find(p => p.id == selectedProductId);
|
const selectedProduct = this.products.find(p => p.id == selectedProductId);
|
||||||
this.purchase.saleline_set[index].unit_price = selectedProduct.price;
|
this.purchase.saleline_set[index].unit_price = selectedProduct.price;
|
||||||
this.purchase.saleline_set[index].measuring_unit = selectedProduct.measuring_unit;
|
this.purchase.saleline_set[index].measuring_unit = selectedProduct.measuring_unit;
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
{{ currencyFormat(calculateSubtotal(item.unit_price, item.quantity)) }}
|
{{ currencyFormat(calculateSubtotal(item.unit_price, item.quantity)) }}
|
||||||
</template>
|
</template>
|
||||||
</v-data-table-virtual>
|
</v-data-table-virtual>
|
||||||
|
<div class="text-center">
|
||||||
|
<v-btn :to="{ path: 'comprar' }" color="green">Ir a Comprar</v-btn>
|
||||||
|
</div>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 5.0.6 on 2024-11-16 20:55
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('don_confiao', '0033_sale_payment_method'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='payment',
|
||||||
|
name='type_payment',
|
||||||
|
field=models.CharField(choices=[('CASH', 'Efectivo'), ('CONFIAR', 'Confiar'), ('BANCOLOMBIA', 'Bancolombia')], default='CASH', max_length=30),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sale',
|
||||||
|
name='date',
|
||||||
|
field=models.DateTimeField(verbose_name='Date'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sale',
|
||||||
|
name='payment_method',
|
||||||
|
field=models.CharField(choices=[('CASH', 'Efectivo'), ('CONFIAR', 'Confiar'), ('BANCOLOMBIA', 'Bancolombia')], default='CASH', max_length=30),
|
||||||
|
),
|
||||||
|
]
|
@ -89,7 +89,7 @@ class ReconciliationJar(models.Model):
|
|||||||
|
|
||||||
class Sale(models.Model):
|
class Sale(models.Model):
|
||||||
customer = models.ForeignKey(Customer, on_delete=models.PROTECT)
|
customer = models.ForeignKey(Customer, on_delete=models.PROTECT)
|
||||||
date = models.DateField("Date")
|
date = models.DateTimeField("Date")
|
||||||
phone = models.CharField(max_length=13, null=True, blank=True)
|
phone = models.CharField(max_length=13, null=True, blank=True)
|
||||||
description = models.CharField(max_length=255, null=True, blank=True)
|
description = models.CharField(max_length=255, null=True, blank=True)
|
||||||
payment_method = models.CharField(
|
payment_method = models.CharField(
|
||||||
|
@ -19,7 +19,7 @@ class ConfiaoTest(TestCase):
|
|||||||
def test_create_sale(self):
|
def test_create_sale(self):
|
||||||
sale = Sale()
|
sale = Sale()
|
||||||
sale.customer = self.customer
|
sale.customer = self.customer
|
||||||
sale.date = "2024-06-22"
|
sale.date = "2024-06-22 12:05:00"
|
||||||
sale.phone = '666666666'
|
sale.phone = '666666666'
|
||||||
sale.description = "Description"
|
sale.description = "Description"
|
||||||
sale.save()
|
sale.save()
|
||||||
@ -29,7 +29,7 @@ class ConfiaoTest(TestCase):
|
|||||||
def test_can_create_sale_without_payment_method(self):
|
def test_can_create_sale_without_payment_method(self):
|
||||||
sale = Sale()
|
sale = Sale()
|
||||||
sale.customer = self.customer
|
sale.customer = self.customer
|
||||||
sale.date = "2024-06-22"
|
sale.date = "2024-06-22 12:05:00"
|
||||||
sale.phone = '666666666'
|
sale.phone = '666666666'
|
||||||
sale.description = "Description"
|
sale.description = "Description"
|
||||||
sale.payment_method = ''
|
sale.payment_method = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user