delivery seemds to work.

This commit is contained in:
seb
2026-07-13 03:40:14 +02:00
parent 03dde8eff8
commit 955fe2c164
12 changed files with 985 additions and 573 deletions

View File

@@ -0,0 +1,34 @@
import sql from 'mssql';
import { xmlTag, xmlElement } from './xml.js';
/**
* Commits this session's reservations into "real" Picklisten (bumps
* dbo.tPicklistePos.nStatus from <10 to 10/20 for this session). Mirrors
* AuslieferungContext.PicklistenCommitten -> Auslieferung.spPicklistenUebernehmen.
*
* nTeillieferung = 0: partial delivery is forbidden, matching create-order.js
* always delivering the full ordered quantity (see delivery.md §6).
*
* XML is passed as NVarChar and CONVERT()ed to xml inside the batch, and
* @xResult is read back via SELECT rather than a true XML OUTPUT parameter
* (tedious does not reliably round-trip xml OUTPUT params for this proc).
*/
export async function commitPicklists(transaction, kBenutzer, kSessionId, kAuftrag) {
const bestellungen = xmlElement('Bestellung', [xmlTag('kBestellung', kAuftrag)]);
await new sql.Request(transaction)
.input('Bestellungen', sql.NVarChar(sql.MAX), bestellungen)
.input('kBenutzer', sql.Int, kBenutzer)
.input('nTeillieferung', sql.Bit, false)
.input('kSessionId', sql.Int, kSessionId)
.query(`
DECLARE @xBestellungen XML = CONVERT(XML, @Bestellungen);
DECLARE @xResult XML;
EXEC Auslieferung.spPicklistenUebernehmen
@Bestellungen = @xBestellungen,
@kBenutzer = @kBenutzer,
@nTeillieferung = @nTeillieferung,
@kSessionId = @kSessionId,
@xResult = @xResult OUTPUT;
`);
}