Anthony Posted September 28, 2018 Share Posted September 28, 2018 Bonjour, Pour mon comptable il faut que je fasse un export des factures dans la forme ci-jointe. Et je ne sais pas comment on fait une requête de produits avec le détail sur plusieurs lignes ? Avez-vous déja fais cela ? Link to comment Share on other sites More sharing options...
Anthony Posted September 28, 2018 Author Share Posted September 28, 2018 Voici le modèle Link to comment Share on other sites More sharing options...
Eolia Posted September 28, 2018 Share Posted September 28, 2018 requete multi-table sur: ps_orders o ps_order_invoice oi ps_order_slip os ps_order_detail od ORDER BY oi.date_add, os.date_add, oi.id_order_invoice, os.id_order_slip Link to comment Share on other sites More sharing options...
Anthony Posted September 28, 2018 Author Share Posted September 28, 2018 3 hours ago, Eolia said: requete multi-table sur: ps_orders o ps_order_invoice oi ps_order_slip os ps_order_detail od ORDER BY oi.date_add, os.date_add, oi.id_order_invoice, os.id_order_slip Merci de votre réponse mais je n'obtiens pas le bon résultat : Ma requête est la suivante : SELECT oi.`date_add` as Date_facture, oi.`id_order` as N_commande, oi.`total_products` as Total_produits_HT, (oi.`total_paid_tax_incl` - oi.`total_paid_tax_excl`) as TVA, t.rate AS TVA_rate, (oi.`total_paid_tax_incl` - oi.`total_shipping_tax_incl`) as Total_produits_TTC, oi.`total_shipping_tax_excl` FROM ps_order_invoice oi left outer join ps_orders o on oi.`id_order` = o.`id_order` left outer join ps_order_slip os on oi.`id_order` = os.`id_order` left outer join ps_order_detail od on oi.`id_order` = od.`id_order` left outer join ps_order_detail_tax odt on od.id_order_detail = odt.id_order_detail left outer join ps_tax t on odt.id_tax = t.id_tax ORDER BY oi.date_add, os.date_add, oi.id_order_invoice, os.id_order_slip Link to comment Share on other sites More sharing options...
Eolia Posted September 28, 2018 Share Posted September 28, 2018 Vous avez peut-être oublié les id_products d'order_detail dans votre select, non ? Link to comment Share on other sites More sharing options...
Anthony Posted September 28, 2018 Author Share Posted September 28, 2018 1 hour ago, Eolia said: Vous avez peut-être oublié les id_products d'order_detail dans votre select, non ? Même en le rajoutant je n'ai pas le détail de chaque taxe par ligne. Sur mon premier post il y a une seule commande et non plusieurs Link to comment Share on other sites More sharing options...
Eolia Posted September 28, 2018 Share Posted September 28, 2018 Vous ne voulez la requete que pour une commande ? Ajoutez where id_order = Si vous voulez les taxes il faut faire les calculs dans la requete (TTC - HT) Link to comment Share on other sites More sharing options...
Anthony Posted September 28, 2018 Author Share Posted September 28, 2018 37 minutes ago, Eolia said: Vous ne voulez la requete que pour une commande ? Ajoutez where id_order = Si vous voulez les taxes il faut faire les calculs dans la requete (TTC - HT) J'ai cette erreur : #1064 - Erreur de syntaxe près de 'GROUP BY t.rate Pourquoi ? vous avez une idée ? SELECT oi.`date_add` as Date_facture, od.product_id, oi.`id_order` as N_commande, oi.`total_products` as Total_produits_HT, ( oi.`total_paid_tax_incl` - oi.`total_paid_tax_excl` ) as TVA, t.rate AS TVA_rate, ( oi.`total_paid_tax_incl` - oi.`total_shipping_tax_incl` ) as Total_produits_TTC, oi.`total_shipping_tax_excl` FROM ps_order_invoice oi left outer join ps_orders o on oi.`id_order` = o.`id_order` left outer join ps_order_slip os on oi.`id_order` = os.`id_order` left outer join ps_order_detail od on oi.`id_order` = od.`id_order` left outer join ps_order_detail_tax odt on od.id_order_detail = odt.id_order_detail left outer join ps_tax t on odt.id_tax = t.id_tax ORDER BY oi.date_add, os.date_add, oi.id_order_invoice, os.id_order_slip Group By t.rate Link to comment Share on other sites More sharing options...
Eolia Posted September 28, 2018 Share Posted September 28, 2018 ce group by est inutile et incompatible avec votre select, par contre classez-les par commande^^ SELECT oi.`date_add` as Date_facture, od.product_id, oi.`id_order` as N_commande, oi.`total_products` as Total_produits_HT, ( oi.`total_paid_tax_incl` - oi.`total_paid_tax_excl` ) as TVA, t.rate AS TVA_rate, ( oi.`total_paid_tax_incl` - oi.`total_shipping_tax_incl` ) as Total_produits_TTC, oi.`total_shipping_tax_excl` FROM ps_order_invoice oi left outer join ps_orders o on oi.`id_order` = o.`id_order` left outer join ps_order_slip os on oi.`id_order` = os.`id_order` left outer join ps_order_detail od on oi.`id_order` = od.`id_order` left outer join ps_order_detail_tax odt on od.id_order_detail = odt.id_order_detail left outer join ps_tax t on odt.id_tax = t.id_tax ORDER BY N_commande, oi.date_add, os.date_add, oi.id_order_invoice, os.id_order_slip Link to comment Share on other sites More sharing options...
Anthony Posted September 28, 2018 Author Share Posted September 28, 2018 3 minutes ago, Eolia said: ce group by est inutile et incompatible avec votre select, par contre classez-les par commande^^ SELECT oi.`date_add` as Date_facture, od.product_id, oi.`id_order` as N_commande, oi.`total_products` as Total_produits_HT, ( oi.`total_paid_tax_incl` - oi.`total_paid_tax_excl` ) as TVA, t.rate AS TVA_rate, ( oi.`total_paid_tax_incl` - oi.`total_shipping_tax_incl` ) as Total_produits_TTC, oi.`total_shipping_tax_excl` FROM ps_order_invoice oi left outer join ps_orders o on oi.`id_order` = o.`id_order` left outer join ps_order_slip os on oi.`id_order` = os.`id_order` left outer join ps_order_detail od on oi.`id_order` = od.`id_order` left outer join ps_order_detail_tax odt on od.id_order_detail = odt.id_order_detail left outer join ps_tax t on odt.id_tax = t.id_tax ORDER BY N_commande, oi.date_add, os.date_add, oi.id_order_invoice, os.id_order_slip D'accord mais le but c'est que par commande il y est le total des TVA à 5,5% et le total des TVA à 20% alors que la il y a tous les produit par commande Link to comment Share on other sites More sharing options...
Eolia Posted September 28, 2018 Share Posted September 28, 2018 alors ne mettez plus les id_product dans le select, utilisez uniquement les éléments affichés au final Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now