8524-devToTest #3415

Merged
alexm merged 343 commits from 8524-devToTest into test 2025-02-04 13:42:16 +00:00
6 changed files with 136 additions and 5 deletions
Showing only changes of commit f86bd1233b - Show all commits

View File

@ -52,7 +52,7 @@
}, },
"payMethod": { "payMethod": {
"type": "belongsTo", "type": "belongsTo",
"model": "PayMethodFk", "model": "PayMethod",
"foreignKey": "payMethodFk" "foreignKey": "payMethodFk"
}, },
"company": { "company": {
@ -61,4 +61,4 @@
"foreignKey": "companyFk" "foreignKey": "companyFk"
} }
} }
} }

View File

@ -0,0 +1,6 @@
module.exports = Self => {
require('./tillIn')(Self);
require('./tillOut')(Self);
require('./tiller')(Self);
};

View File

@ -0,0 +1,9 @@
module.exports = Self => {
Self.tillIn = async(ctx, options) => {
const query = `INSERT INTO vn.promissoryNote ( concept, paymentFk) VALUES(?, ? )`;
const pagareId = await Self.rawSql(query, [concept, paymentFk], myOptions);
if (pagareId) return pagareId;
throw new UserError('Till In');
};
};

View File

@ -0,0 +1,9 @@
module.exports = Self => {
Self.tillOut = async(ctx, options) => {
const query = `INSERT INTO vn.promissoryNote ( id, dated, serie, concept, in, out, bankFk, companyFk, isAccountable, InForeignValue, OutForeignValue, workerFk, calculatedCode, number, isLinked, created, isOk, warehouseFk, isConciliate, supplierAccountFk) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )`;
const pagareId = await Self.rawSql(query, [concept, paymentFk], myOptions);
if (pagareId) return pagareId;
throw new UserError('Till Out');
};
};

View File

@ -0,0 +1,6 @@
module.exports = Self => {
Self.tiller = async(ctx, options) => {
throw new UserError('Till In');
};
};

View File

@ -34,8 +34,7 @@ module.exports = function(Self) {
required: true required: true
}, { }, {
arg: 'divisa', arg: 'divisa',
type: 'number', type: 'any',
required: true
}, },
{ {
arg: 'bankFk', arg: 'bankFk',
@ -174,7 +173,11 @@ module.exports = function(Self) {
); );
} }
*/ */
const newPayment = await models.Payment.create(args, myOptions); const bodyPayment = {
...args,
dueDate: args.received,
};
const newPayment = await models.Payment.create(bodyPayment, myOptions);
// if (/* Supplier is client*/ false) { // if (/* Supplier is client*/ false) {
// const newReceipt = await models.Receipt.create({ // const newReceipt = await models.Receipt.create({
// invoiceFk: newPayment.id, // invoiceFk: newPayment.id,
@ -185,8 +188,99 @@ module.exports = function(Self) {
// clientFk: args.supplierFk, // clientFk: args.supplierFk,
// }, myOptions); // }, myOptions);
// } // }
// const supplier = await Self.app.models.Supplier.findById(args.supplierFk, {fields: ['nif'], include: {
// relation: 'client'
// }}, myOptions);
// const client = await Self.app.models.Client.findOne({where: {nif: supplier.fi}}, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();
switch (bodyPayment.payMethodFk) {
case 1:
case 10:
case 20:
await models.Till.tillIn(args, myOptions);
throw new UserError('Metálico');
// Call Salidadecaja(
// strCONCEPTO & " : " & DFirst("[Proveedor]", "Proveedores",
// " [Id_Proveedor] = " & vSupplierFk),
// "R",
// _ "0",
// _ Replace(str(Me.n_pago), ",", "."), _
// Me.n_fecha, _
// DFirst("[oficial]", "Proveedores", "[Id_Proveedor] =" & vSupplierFk),
// _ Me.n_caja, Me.empresa)
// Call sql(msql("UPDATE pago SET conciliado = TRUE WHERE id = %", pagoId), False, True)
// Public Function Salidadecaja(strCONCEPTE As String, strSERIE As String, strREF As String, strSALIDA As String, _
// datfecha As Date, strCOLOR As String, strCAJA As String, intEmp As Integer)
// Select Case Trim(strCAJA)
// Case "11", "12", "13"
// Call abrecajon
// End Select
// Call sql(msql("INSERT INTO Cajas ( Concepto, Serie, Numero, Salida, Cajafecha, Partida, Id_Banco, Id_Trabajador,empresa_id ) " & _
// "SELECT %,%,%,%,%,%,%,%,%", strCONCEPTE, strSERIE, Nz(strREF, 0), strSALIDA, datfecha, strCOLOR, strCAJA, workerId, intEmp), _
// False, True)
// End Function
// break;
case 2:
// Call emitir_pagare(pagoId, strCONCEPTO)
await emitPagare(args.concept, newPayment.id);
// Public Function emitir_pagare(pagoId As Long, strCONCEPTO As String)
// Call sql(msql("INSERT INTO Pagares(pago_id,Concepto) " & _
// "VALUES (%,%)", pagoId, strCONCEPTO), False, True)
// Call sql("SELECT LAST_INSERT_ID() as id", True, False)
// Call sql("SELECT Pagares.Id_Pagare, Pagares.Concepto, Proveedores.Proveedor, Proveedores.Domicilio,empresa.logo, " & _
// "Proveedores.codpos, Proveedores.Localidad, [importe] AS texto, Pagares.Fechaemision, pago.importe,pago.fecha, " & _
// "pago.empresa_id, Proveedores.postcode_id AS CP FROM ((Proveedores INNER JOIN pago ON Proveedores.Id_Proveedor = pago.id_proveedor) " & _
// "INNER JOIN Pagares ON pago.id = Pagares.pago_id) INNER JOIN empresa ON pago.empresa_id = empresa.id " & _
// "WHERE Pagares.Id_Pagare = " & DFirst("[id]", "cstSQL"), True, False, "pagareultimo")
// DoCmd.openReport "Pagare", acViewPreview
// End Function
// break;
case 3:
throw new UserError('Compensación');
// Dim vOriginalAccount As String
// vOriginalAccount = db.getValueV("SELECT account FROM vn.supplier WHERE id = #", vSupplierFk)
// 'Call compensar(Me.n_caja, Me.n_fecha, strCONCEPTO, Me.empresa, Me.n_pago, vOriginalAccount, pagoId)
// db.execV "CALL vn.ledger_doCompensation(#, #, #, #, #, #, #)", Me.n_fecha, vCompensationAccount, Me.n_caja, strCONCEPTO, Me.n_pago, Me.empresa, vOriginalAccount
// db.execV "UPDATE pago SET conciliado = TRUE, concepte = CONCAT(concepte, ' ', #) WHERE id = #", vCompensationAccount, pagoId
// break;
case 8:
throw new UserError('SEPA-CORE/B2B');
// If db.getValueFromDefV("paymentHasIban", vSupplierFk) = 0 Then
// MsgBox "Rellene los campos iban y entidad.", vbCritical
// Exit Sub
// End If
// Dim isUeeMember As Boolean
// isUeeMember = db.getValueV("SELECT c.isUeeMember FROM vn.supplier s JOIN vn.country c ON c.id = s.countryFk WHERE s.id = #", vSupplierFk)
// Call GenerarPagoSEPA( _
// Me.n_fecha, _
// Me.empresa, _
// Replace(Format(IIf(Me.n_moneda.column(1) = "EUR", Me.n_pago, Me.n_cambio), "0.00"), ",", "."), _
// Me.n_caja, _
// isUeeMember, _
// "TRANSFER_" & DFirst("alias", "Proveedores", "[Id_Proveedor] =" & vSupplierFk), _
// 1, _
// Me.n_moneda.column(1), _
// vSupplierFk)
// MsgBox "Fichero Generado CORRECTAMENTE", vbInformation
// break;
default:
break;
}
return newPayment; return newPayment;
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
@ -194,3 +288,10 @@ module.exports = function(Self) {
} }
}; };
}; };
async function emitPagare(concept, paymentFk) {
const query = `INSERT INTO vn.promissoryNote ( concept, paymentFk) VALUES(?, ? )`;
const pagareId = await Self.rawSql(query, [concept, paymentFk], myOptions);
if (pagareId) return pagareId;
throw new UserError('Pagaré');
}