Bonjour à tous.
Je reviens encore avec des problèmes concernant des stocks.
Cette fois-ci, j'arrive bien à calculer les quantités, mais j'ai un problème au moment de calculer la valeur du stock résiduel.
Voici le code que j'utilise pour calculer les stocks:
1 2 3 4 5 6
| PARAMETERS [A telle date] DateTime;
SELECT PrDesc.UID AS RefPrd, PrDesc.productName AS nom, Sum(Prd.qtyNet) AS KgEntrés, Sum(Prd.cartons) AS [Cartons entrés], (SELECT sum(pr2.qtyNet) FROM Products AS pr2, Contracts AS ctr2 WHERE ((pr2.ledger="Sale") and (pr2.namedescription=prdesc.uid) and (ctr2.contractNumber=pr2.contractAssignment) and (ctr2.ETL<=[A telle date]))) AS KgSortis, (SELECT sum(pr2.cartons) FROM Products AS pr2, Contracts AS ctr2 WHERE ((pr2.ledger="Sale") and (pr2.namedescription=prdesc.uid) and (ctr2.contractNumber=pr2.contractAssignment) and (ctr2.ETL<=[A telle date]))) AS [Cartons sortis], [Kgentrés]-(IIf(IsNull([kgsortis]),0,[kgsortis])) AS StockKg, [cartons entrés]-(IIf(IsNull([Cartons sortis]),0,[Cartons sortis])) AS StockCartons
FROM Organisations AS Org INNER JOIN (ProductDescriptions AS PrDesc INNER JOIN (Products AS Prd INNER JOIN Contracts AS Ctr ON Prd.contractAssignment=Ctr.contractNumber) ON PrDesc.UID=Prd.nameDescription) ON Org.UID=Prd.coldstore
WHERE (((Prd.dateOfPurchase)<=[A telle date]) AND ((Prd.ledger)="purchase"))
GROUP BY PrDesc.UID, PrDesc.productName
ORDER BY PrDesc.productName; |
J'ai ensuite essayé d'en obtenir la valeur avec cette ligne:
Sum(CDbl(prd.price)*((Prd.qtyNet)-(SELECT sum((pr2.qtyNet)) FROM Products AS pr2, Contracts AS ctr2 WHERE ((pr2.ledger="Sale") and (pr2.namedescription=prdesc.uid) and (ctr2.contractNumber=pr2.contractAssignment) and (ctr2.ETL<=[A telle date])))) AS Expr1
Mais cela ne fonctionne pas...
Quelqu'un aurait'il une idée?
Merci
Fred
Partager