You are on page 1of 3

/**

* Copyright (c) 1988-PRESENT deister software, All Rights Reserved.


*
* All information contained herein is, and remains the property of deister
software.
* The intellectual and technical concepts contained herein are proprietary to
* deister software and may be covered by trade secret or copyright law.
* Dissemination of this information or reproduction of this material is strictly
* forbidden unless prior written permission is obtained from deister software.
* Access to the source code contained herein is hereby forbidden to anyone except
* current deister software employees, managers or contractors who have executed
* Confidentiality and Non-disclosure' agreements explicitly covering such access.
* The notice above does not evidence any actual or intended publication
* for disclosure of this source code, which includes information that is
confidential
* and/or proprietary, and is a trade secret, of deister software
*
* ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE,
* OR PUBLIC DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE
* EXPRESS WRITTEN CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION
* OF APPLICABLE LAWS AND INTERNATIONAL TREATIES.THE RECEIPT OR POSSESSION OF
* THIS SOURCE CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY
* RIGHTS TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE,
* USE, OR SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART.
*
* -----------------------------------------------------------------------------
*
* JS: Name Function
* Version : Version
* Date : 17-02-2022
* Description : Describe lo que hace la funcion
*
*
* LOCAL FUNCTIONS:
* ==================
*
*
* CALLED FROM:
* ==================
*
*
* PARAMETERS:
* ==================
*
*
**/
function labcoGmovprohServir(pIntType, pRsData) {

let mRsGvenpedl = new Ax.rs.Reader().memory(options => {


options.setColumnNames(["linori", "canmov"]);
options.setColumnTypes([
Ax.sql.Types.INTEGER,
Ax.sql.Types.INTEGER
]);
});

let mArrLinori = [];

try {
Ax.db.beginWork();

pRsData.forEach(row => {

Ax.db.executeQuery(`
<select>
<columns>
linid,
linori,
canmov - canrea canmov
</columns>
<from table='gmovprol'/>
<where>
cabid = ?
AND codart = ?
AND udmori = ?
AND ubiori = ?
</where>
</select>
`, row.cabid, row.codart, row.udmori, row.ubiori).forEach(elem => {

mArrLinori.push(elem.linori);

Ax.db.call('gmovproh_Serve', elem.cabid, elem.linid);

mRsGvenpedl.rows().add([elem.linori, elem.canmov]);

let mIntCabid = Ax.db.executeGet(`


<select>
<columns>
gvenmovh.cabid
</columns>
<from table='gvenmovl'>
<join table='gvenmovh'>
<on>gvenmovl.cabid = gvenmovh.cabid</on>
<join table='gvenmovd'>
<on>gvenmovh.tipdoc = gvenmovd.codigo</on>
</join>
</join>
</from>
<where>
gvenmovl.linext = ? AND
gvenmovd.tabori = 'gmovproh'
</where>
</select>
`, elem.linid);

if(mIntCabid != null) {
Ax.db.call('gvenmovh_Valida', mIntCabid);
}
});
});

Ax.db.commitWork();
} catch (error) {
Ax.db.rollbackWork();
throw new Ax.ext.Exception(error.message);
}
let mIntCont = 0;

// Marcar como servidas líneas origen.


if(pIntType == 1){
pRsData.forEach(row =>{
let mObjGvenpedl = Ax.db.executeQuery(`
<select>
<columns>
cabid,
canped - canext - canser canpen
</columns>
<from table='gvenpedl' />
<where>
linid = ${mArrLinori[mIntCont]}
</where>
</select>
`).toOne();

if(mObjGvenpedl.canpen > 0){


if(row.canmov > 0) {
Ax.db.insert("gvenpeda",
{
cabid : mObjGvenpedl.cabid,
linid : mArrLinori[mIntCont],
errnum: 29130,
cananu: mObjGvenpedl.canped
}
);
}
}

mIntCont++;
});
}
}

You might also like