瀏覽代碼

Se agregaron tablas merma, compra, compra producto, nomina

Jose Cienfuegos 7 月之前
父節點
當前提交
c15c27265c

+ 114 - 0
migrations/m240926_231003_tablas_compras_comprasProducto_mermas_nominas.php

@@ -0,0 +1,114 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m240926_231003_tablas_compras_comprasProducto_mermas_nominas
+ */
+class m240926_231003_tablas_compras_comprasProducto_mermas_nominas extends Migration {
+
+    public function safeUp() {
+        $this->createTable('Compra', [
+            "id" => $this->string(36),
+            "idObra" => $this->string(36),
+            "idUsuario" => $this->string(36),
+            "fechaCompra" => $this->timestamp()->append(" with time zone"),
+            "creado" => $this->timestamp()->append(" with time zone"),
+            "modificado" => $this->timestamp()->append(" with time zone"),
+            "eliminado" => $this->timestamp()->append(" with time zone"),
+        ]);
+
+        $this->addPrimaryKey('CompraPK', 'Compra', 'id');
+        
+        $this->addForeignKey('CompraObraFK', 'Compra', 'idObra', 'Obra', 'id');
+        $this->addForeignKey('CompraUsuarioFK', 'Compra', 'idUsuario', 'Usuario', 'id');
+
+        $this->createTable('CompraProducto', [
+            "id" => $this->string(36),
+            "idCompra" => $this->string(36),
+            "idUnidadMedida" => $this->string(36),
+            "idPartida" => $this->string(36),
+            "producto" => $this->string(),
+            "cantidad" => $this->string(),
+            "precio" => $this->decimal(10, 2),
+            "descripcion" => $this->text(),
+            "creado" => $this->timestamp()->append(" with time zone"),
+            "modificado" => $this->timestamp()->append(" with time zone"),
+            "eliminado" => $this->timestamp()->append(" with time zone"),
+        ]);
+
+        $this->addPrimaryKey('CompraProductoPK','CompraProducto', 'id');
+
+        $this->addForeignKey('CompraProductoCompraFK', 'CompraProducto', 'idCompra', 'Compra', 'id');
+        $this->addForeignKey('CompraProductoMedidaFK', 'CompraProducto', 'idUnidadMedida', 'UnidadMedida', 'id');
+        $this->addForeignKey('CompraProductoPartidaFK', 'CompraProducto', 'idPartida', 'Partida', 'id');
+
+        $this->createTable('Merma', [
+            "id" => $this->string(36),
+            "idObra" => $this->string(36),
+            "idUnidadMedida" => $this->string(36),
+            "idPartida" => $this->string(36),
+            "idUsuario" => $this->string(36),
+            "producto" => $this->string(),
+            "descripcion" => $this->text(),
+            "cantidad" => $this->string(),
+            "precio" => $this->decimal(10, 2),
+            "creado" => $this->timestamp()->append(" with time zone"),
+            "modificado" => $this->timestamp()->append(" with time zone"),
+            "eliminado" => $this->timestamp()->append(" with time zone"),
+        ]);
+
+        $this->addPrimaryKey('MermaPK', 'Merma', 'id');
+
+        $this->addForeignKey('MermaObraFK', 'Merma', 'idObra', 'Obra', 'id');
+        $this->addForeignKey('MermaUnidadMedidaFK', 'Merma', 'idUnidadMedida', 'UnidadMedida', 'id');
+        $this->addForeignKey('MermaPartidaFK', 'Merma', 'idPartida', 'Partida', 'id');
+        $this->addForeignKey('MermaUsuarioFK', 'Merma', 'idUsuario', 'Usuario', 'id');
+
+        $this->createTable('Nomina', [
+            "id" => $this->string(36),
+            "idEmpleado" => $this->string(36),
+            "idObra" => $this->string(36),
+            "idUsuario" => $this->string(36),
+            "montoPagado" => $this->decimal(10,2),
+            "descuento" => $this->decimal(10,2),
+            "creado" => $this->timestamp()->append(" with time zone"),
+            "fechaPago" => $this->timestamp()->append(" with time zone"),
+            "modificado" => $this->timestamp()->append(" with time zone"),
+            "eliminado" => $this->timestamp()->append(" with time zone"),
+        ]);
+
+        $this->addPrimaryKey('NominaPK', 'Nomina', 'id');
+
+        $this->addForeignKey('NominaObraFK', 'Nomina', 'idObra', 'Obra', 'id');
+        $this->addForeignKey('NominaEmpleadoFK', 'Nomina', 'idEmpleado', 'Empleado', 'id');
+        $this->addForeignKey('NominaUsuarioFK', 'Nomina', 'idUsuario', 'Usuario', 'id');
+
+    }
+
+    public function safeDown() {
+        $this->dropForeignKey('NominaObraFK', 'Nomina');
+        $this->dropForeignKey('NominaEmpleadoFK', 'Nomina');
+        $this->dropForeignKey('NominaUsuarioFK', 'Nomina');
+
+        $this->dropTable('Nomina');
+
+        $this->dropForeignKey('MermaObraFK', 'Merma');
+        $this->dropForeignKey('MermaUnidadMedidaFK', 'Merma');
+        $this->dropForeignKey('MermaPartidaFK', 'Merma');
+        $this->dropForeignKey('MermaUsuarioFK', 'Merma');
+
+        $this->dropTable('Merma');
+
+        $this->dropForeignKey('CompraProductoCompraFK', 'CompraProducto');
+        $this->dropForeignKey('CompraProductoMedidaFK', 'CompraProducto');
+        $this->dropForeignKey('CompraProductoPartidaFK', 'CompraProducto');
+
+        $this->dropTable('CompraProducto');
+
+        $this->dropForeignKey('CompraObraFK', 'Compra');
+        $this->dropForeignKey('CompraUsuarioFK', 'Compra');
+
+        $this->dropTable('Compra');
+    }
+}

+ 77 - 0
models/Compra.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "Compra".
+ *
+ * @property string $id
+ * @property string|null $idObra
+ * @property string|null $idUsuario
+ * @property string|null $fechaCompra
+ * @property string|null $creado
+ * @property string|null $modificado
+ * @property string|null $eliminado
+ *
+ * @property CompraProducto[] $compraProductos
+ * @property Obra $idObra0
+ * @property Usuario $idUsuario0
+ */
+class Compra extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'Compra';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['id'], 'required'],
+            [['fechaCompra', 'creado', 'modificado', 'eliminado'], 'safe'],
+            [['id', 'idObra', 'idUsuario'], 'string', 'max' => 36],
+            [['id'], 'unique'],
+            [['idObra'], 'exist', 'skipOnError' => true, 'targetClass' => Obra::class, 'targetAttribute' => ['idObra' => 'id']],
+            [['idUsuario'], 'exist', 'skipOnError' => true, 'targetClass' => Usuario::class, 'targetAttribute' => ['idUsuario' => 'id']],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'idObra' => 'Id Obra',
+            'idUsuario' => 'Id Usuario',
+            'fechaCompra' => 'Fecha Compra',
+            'creado' => 'Creado',
+            'modificado' => 'Modificado',
+            'eliminado' => 'Eliminado',
+        ];
+    }
+
+    public function getCompraProducto()
+    {
+        return $this->hasMany(CompraProducto::class, ['idCompra' => 'id']);
+    }
+
+    public function getObra()
+    {
+        return $this->hasOne(Obra::class, ['id' => 'idObra']);
+    }
+
+    public function getUsuario()
+    {
+        return $this->hasOne(Usuario::class, ['id' => 'idUsuario']);
+    }
+}

+ 89 - 0
models/CompraProducto.php

@@ -0,0 +1,89 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "CompraProducto".
+ *
+ * @property string $id
+ * @property string|null $idCompra
+ * @property string|null $idUnidadMedida
+ * @property string|null $idPartida
+ * @property string|null $producto
+ * @property string|null $cantidad
+ * @property float|null $precio
+ * @property string|null $descripcion
+ * @property string|null $creado
+ * @property string|null $modificado
+ * @property string|null $eliminado
+ *
+ * @property Compra $idCompra0
+ * @property Partida $idPartida0
+ * @property UnidadMedida $idUnidadMedida0
+ */
+class CompraProducto extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'CompraProducto';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['id'], 'required'],
+            [['precio'], 'number'],
+            [['descripcion'], 'string'],
+            [['creado', 'modificado', 'eliminado'], 'safe'],
+            [['id', 'idCompra', 'idUnidadMedida', 'idPartida'], 'string', 'max' => 36],
+            [['producto', 'cantidad'], 'string', 'max' => 255],
+            [['id'], 'unique'],
+            [['idCompra'], 'exist', 'skipOnError' => true, 'targetClass' => Compra::class, 'targetAttribute' => ['idCompra' => 'id']],
+            [['idPartida'], 'exist', 'skipOnError' => true, 'targetClass' => Partida::class, 'targetAttribute' => ['idPartida' => 'id']],
+            [['idUnidadMedida'], 'exist', 'skipOnError' => true, 'targetClass' => UnidadMedida::class, 'targetAttribute' => ['idUnidadMedida' => 'id']],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'idCompra' => 'Id Compra',
+            'idUnidadMedida' => 'Id Unidad Medida',
+            'idPartida' => 'Id Partida',
+            'producto' => 'Producto',
+            'cantidad' => 'Cantidad',
+            'precio' => 'Precio',
+            'descripcion' => 'Descripcion',
+            'creado' => 'Creado',
+            'modificado' => 'Modificado',
+            'eliminado' => 'Eliminado',
+        ];
+    }
+
+    public function getCompra()
+    {
+        return $this->hasOne(Compra::class, ['id' => 'idCompra']);
+    }
+
+    public function getPartida()
+    {
+        return $this->hasOne(Partida::class, ['id' => 'idPartida']);
+    }
+
+    public function getUnidadMedida()
+    {
+        return $this->hasOne(UnidadMedida::class, ['id' => 'idUnidadMedida']);
+    }
+}

+ 98 - 0
models/Merma.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "Merma".
+ *
+ * @property string $id
+ * @property string|null $idObra
+ * @property string|null $idUnidadMedida
+ * @property string|null $idPartida
+ * @property string|null $idUsuario
+ * @property string|null $producto
+ * @property string|null $descripcion
+ * @property string|null $cantidad
+ * @property float|null $precio
+ * @property string|null $creado
+ * @property string|null $modificado
+ * @property string|null $eliminado
+ *
+ * @property Obra $idObra0
+ * @property Partida $idPartida0
+ * @property UnidadMedida $idUnidadMedida0
+ * @property Usuario $idUsuario0
+ */
+class Merma extends ModeloBase
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'Merma';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['id'], 'required'],
+            [['descripcion'], 'string'],
+            [['precio'], 'number'],
+            [['creado', 'modificado', 'eliminado'], 'safe'],
+            [['id', 'idObra', 'idUnidadMedida', 'idPartida', 'idUsuario'], 'string', 'max' => 36],
+            [['producto', 'cantidad'], 'string', 'max' => 255],
+            [['id'], 'unique'],
+            [['idObra'], 'exist', 'skipOnError' => true, 'targetClass' => Obra::class, 'targetAttribute' => ['idObra' => 'id']],
+            [['idPartida'], 'exist', 'skipOnError' => true, 'targetClass' => Partida::class, 'targetAttribute' => ['idPartida' => 'id']],
+            [['idUnidadMedida'], 'exist', 'skipOnError' => true, 'targetClass' => UnidadMedida::class, 'targetAttribute' => ['idUnidadMedida' => 'id']],
+            [['idUsuario'], 'exist', 'skipOnError' => true, 'targetClass' => Usuario::class, 'targetAttribute' => ['idUsuario' => 'id']],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'idObra' => 'Id Obra',
+            'idUnidadMedida' => 'Id Unidad Medida',
+            'idPartida' => 'Id Partida',
+            'idUsuario' => 'Id Usuario',
+            'producto' => 'Producto',
+            'descripcion' => 'Descripcion',
+            'cantidad' => 'Cantidad',
+            'precio' => 'Precio',
+            'creado' => 'Creado',
+            'modificado' => 'Modificado',
+            'eliminado' => 'Eliminado',
+        ];
+    }
+
+    public function getObra()
+    {
+        return $this->hasOne(Obra::class, ['id' => 'idObra']);
+    }
+
+    public function getPartida()
+    {
+        return $this->hasOne(Partida::class, ['id' => 'idPartida']);
+    }
+
+    public function getUnidadMedida()
+    {
+        return $this->hasOne(UnidadMedida::class, ['id' => 'idUnidadMedida']);
+    }
+
+    public function getUsuario()
+    {
+        return $this->hasOne(Usuario::class, ['id' => 'idUsuario']);
+    }
+}

+ 85 - 0
models/Nomina.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "Nomina".
+ *
+ * @property string $id
+ * @property string|null $idEmpleado
+ * @property string|null $idObra
+ * @property string|null $idUsuario
+ * @property float|null $montoPagado
+ * @property float|null $descuento
+ * @property string|null $creado
+ * @property string|null $fechaPago
+ * @property string|null $modificado
+ * @property string|null $eliminado
+ *
+ * @property Empleado $idEmpleado0
+ * @property Obra $idObra0
+ * @property Usuario $idUsuario0
+ */
+class Nomina extends ModeloBase
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'Nomina';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['id'], 'required'],
+            [['montoPagado', 'descuento'], 'number'],
+            [['creado', 'fechaPago', 'modificado', 'eliminado'], 'safe'],
+            [['id', 'idEmpleado', 'idObra', 'idUsuario'], 'string', 'max' => 36],
+            [['id'], 'unique'],
+            [['idEmpleado'], 'exist', 'skipOnError' => true, 'targetClass' => Empleado::class, 'targetAttribute' => ['idEmpleado' => 'id']],
+            [['idObra'], 'exist', 'skipOnError' => true, 'targetClass' => Obra::class, 'targetAttribute' => ['idObra' => 'id']],
+            [['idUsuario'], 'exist', 'skipOnError' => true, 'targetClass' => Usuario::class, 'targetAttribute' => ['idUsuario' => 'id']],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'idEmpleado' => 'Id Empleado',
+            'idObra' => 'Id Obra',
+            'idUsuario' => 'Id Usuario',
+            'montoPagado' => 'Monto Pagado',
+            'descuento' => 'Descuento',
+            'creado' => 'Creado',
+            'fechaPago' => 'Fecha Pago',
+            'modificado' => 'Modificado',
+            'eliminado' => 'Eliminado',
+        ];
+    }
+
+    public function getEmpleado()
+    {
+        return $this->hasOne(Empleado::class, ['id' => 'idEmpleado']);
+    }
+
+    public function getObra()
+    {
+        return $this->hasOne(Obra::class, ['id' => 'idObra']);
+    }
+
+    public function getUsuario()
+    {
+        return $this->hasOne(Usuario::class, ['id' => 'idUsuario']);
+    }
+}

+ 93 - 0
modules/v1/controllers/MermaController.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace v1\controllers;
+
+use common\data\Respuesta;
+use common\rest\AuthController;
+use yii\db\Expression;
+
+class MermaController extends AuthController
+{
+
+  public $modelClass = "v1\models\Merma";
+
+  public function actionIndex()
+  {
+    $id = trim($this->req->get("id", ""));
+    $idObra = trim($this->req->get("idObra", ""));
+    $idPartida = trim($this->req->get("idPartida", ""));
+    $buscar = trim($this->req->get("q", ""));
+
+    $query = $this->queryInicial;
+
+
+    if ($id !== "") {
+      $query->andWhere(["id" => $id]);
+    }
+
+    if ($idObra !== "") {
+      $query->andWhere(["idObra" => $idObra]);
+    }
+
+    if ($idPartida !== "") {
+      $query->andWhere(["idPartida" => $idPartida]);
+    }
+
+    if($buscar !==""){
+      $query->andWhere(["nombre"=>$buscar]);
+    }
+
+    return new Respuesta($query, $this->limite, $this->pagina, $this->ordenar);
+  }
+
+  public function actionGuardar()
+  {
+    $id = trim($this->req->getBodyParam("id", ""));
+    $modelo = null;
+
+    if ($id !== "") {
+      $modelo = $this->modelClass::findOne($id);
+    }
+    if ($modelo === null) {
+      $modelo = new $this->modelClass();
+      $modelo->uuid();
+      $modelo->creado = new Expression('now()');
+    } else {
+      $modelo->modificado = new Expression('now()');
+    }
+    $modelo->load($this->req->getBodyParams(), '');
+
+  
+    if (!$modelo->save()) {
+      return (new Respuesta($modelo))
+        ->mensaje("Hubo un problema al guardar la Merma");
+    }
+
+    $modelo->refresh();
+    return (new Respuesta($modelo))
+      ->mensaje("Merma guardada");
+  }
+
+  public function actionEliminar()
+  {
+    $id = trim($this->req->getBodyParam("id", ""));
+    $modelo = null;
+
+    if ($id !== "") {
+      $modelo = $this->modelClass::findOne(["id" => $id]);
+    }
+    if ($modelo === null) {
+      return (new Respuesta())
+        ->esError()
+        ->mensaje("Merma no encontrado");
+    }
+    $modelo->eliminado = new Expression('now()');
+    if (!$modelo->save()) {
+      return (new Respuesta($modelo))
+        ->mensaje("No se pudo eliminar la Merma");
+    }
+
+    return (new Respuesta())
+      ->mensaje("Merma eliminada");
+  }
+}

+ 93 - 0
modules/v1/controllers/NominaController.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace v1\controllers;
+
+use common\data\Respuesta;
+use common\rest\AuthController;
+use yii\db\Expression;
+
+class NominaController extends AuthController
+{
+
+  public $modelClass = "v1\models\Nomina";
+
+  public function actionIndex()
+  {
+    $id = trim($this->req->get("id", ""));
+    $idEmpleado = trim($this->req->get("idEmpleado", ""));
+    $idObra = trim($this->req->get("idObra", ""));
+    $buscar = trim($this->req->get("q", ""));
+
+    $query = $this->queryInicial;
+
+
+    if ($id !== "") {
+      $query->andWhere(["id" => $id]);
+    }
+    
+    if ($idEmpleado !== "") {
+        $query->andWhere(["idEmpleado" => $idEmpleado]);
+    }
+
+    if ($idObra !== "") {
+        $query->andWhere(["idObra" => $idObra]);
+    }
+
+    if($buscar !==""){
+      $query->andWhere(["nombre"=>$buscar]);
+    }
+
+    return new Respuesta($query, $this->limite, $this->pagina, $this->ordenar);
+  }
+
+  public function actionGuardar()
+  {
+    $id = trim($this->req->getBodyParam("id", ""));
+    $modelo = null;
+
+    if ($id !== "") {
+      $modelo = $this->modelClass::findOne($id);
+    }
+    if ($modelo === null) {
+      $modelo = new $this->modelClass();
+      $modelo->uuid();
+      $modelo->creado = new Expression('now()');
+    } else {
+      $modelo->modificado = new Expression('now()');
+    }
+    $modelo->load($this->req->getBodyParams(), '');
+
+  
+    if (!$modelo->save()) {
+      return (new Respuesta($modelo))
+        ->mensaje("Hubo un problema al guardar la Nomina");
+    }
+
+    $modelo->refresh();
+    return (new Respuesta($modelo))
+      ->mensaje("Nomina guardada");
+  }
+
+  public function actionEliminar()
+  {
+    $id = trim($this->req->getBodyParam("id", ""));
+    $modelo = null;
+
+    if ($id !== "") {
+      $modelo = $this->modelClass::findOne(["id" => $id]);
+    }
+    if ($modelo === null) {
+      return (new Respuesta())
+        ->esError()
+        ->mensaje("Nomina no encontrado");
+    }
+    $modelo->eliminado = new Expression('now()');
+    if (!$modelo->save()) {
+      return (new Respuesta($modelo))
+        ->mensaje("No se pudo eliminar la Nomina");
+    }
+
+    return (new Respuesta())
+      ->mensaje("Nomina eliminada");
+  }
+}

+ 44 - 0
modules/v1/models/Compra.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace v1\models;
+
+use app\models\Compra as ModeloCompra;
+
+class Compra extends ModeloCompra
+{
+
+    public function fields()
+    {
+        return [
+            'id',
+            'idObra',
+            'idUsuario',
+            'fechaCompra',
+            'creado',
+            'modificado',
+
+        ];
+    }
+    public function extraFields() {
+        return [
+            'compraProducto',
+            'obra',
+            'usuario',
+        ];
+    }
+
+    public function getCompraProducto()
+    {
+        return $this->hasMany(CompraProducto::class, ['idCompra' => 'id']);
+    }
+
+    public function getObra()
+    {
+        return $this->hasOne(Obra::class, ['id' => 'idObra']);
+    }
+
+    public function getUsuario()
+    {
+        return $this->hasOne(Usuario::class, ['id' => 'idUsuario']);
+    }
+}

+ 48 - 0
modules/v1/models/CompraProducto.php

@@ -0,0 +1,48 @@
+<?php
+
+namespace v1\models;
+
+use app\models\CompraProducto as ModeloCompraProducto;
+
+class CompraProducto extends ModeloCompraProducto
+{
+
+    public function fields()
+    {
+        return [
+            'id',
+            'idCompra',
+            'idUnidadMedida',
+            'idPartida',
+            'producto',
+            'descripcion',
+            'cantidad',
+            'precio',
+            'creado',
+            'modificado',
+
+        ];
+    }
+    public function extraFields() {
+        return [
+            'compra',
+            'partida',
+            'unidadMedida',
+        ];
+    }
+
+    public function getCompra()
+    {
+        return $this->hasOne(Compra::class, ['id' => 'idCompra']);
+    }
+
+    public function getPartida()
+    {
+        return $this->hasOne(Partida::class, ['id' => 'idPartida']);
+    }
+
+    public function getUnidadMedida()
+    {
+        return $this->hasOne(UnidadMedida::class, ['id' => 'idUnidadMedida']);
+    }
+}

+ 55 - 0
modules/v1/models/Merma.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace v1\models;
+
+use app\models\Merma as ModeloMerma;
+
+class Merma extends ModeloMerma
+{
+
+    public function fields()
+    {
+        return [
+            'id',
+            'idObra',
+            'idUnidadMedida',
+            'idPartida',
+            'idUsuario',
+            'producto',
+            'descripcion',
+            'cantidad',
+            'precio',
+            'creado',
+            'modificado',
+
+        ];
+    }
+    public function extraFields() {
+        return [
+            'obra',
+            'partida',
+            'unidadMedida',
+            'usuario',
+        ];
+    }
+
+    public function getObra()
+    {
+        return $this->hasOne(Obra::class, ['id' => 'idObra']);
+    }
+
+    public function getPartida()
+    {
+        return $this->hasOne(Partida::class, ['id' => 'idPartida']);
+    }
+
+    public function getUnidadMedida()
+    {
+        return $this->hasOne(UnidadMedida::class, ['id' => 'idUnidadMedida']);
+    }
+
+    public function getUsuario()
+    {
+        return $this->hasOne(Usuario::class, ['id' => 'idUsuario']);
+    }
+}

+ 47 - 0
modules/v1/models/Nomina.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace v1\models;
+
+use app\models\Nomina as ModeloNomina;
+
+class Nomina extends ModeloNomina
+{
+
+    public function fields()
+    {
+        return [
+            'id',
+            'idEmpleado',
+            'idObra',
+            'idUsuario',
+            'montoPagado',
+            'descuento',
+            'fechaPago',
+            'creado',
+            'modificado',
+
+        ];
+    }
+    public function extraFields() {
+        return [
+            'obra',
+            'empleado',
+            'usuario',
+        ];
+    }
+
+    public function getEmpleado()
+    {
+        return $this->hasOne(Empleado::class, ['id' => 'idEmpleado']);
+    }
+
+    public function getObra()
+    {
+        return $this->hasOne(Obra::class, ['id' => 'idObra']);
+    }
+
+    public function getUsuario()
+    {
+        return $this->hasOne(Usuario::class, ['id' => 'idUsuario']);
+    }
+}