159 |
INSERT INTO own_document_tax (tax, amount, taxed_amount, own_document) SELECT tax, SUM(own_item_tax.amount) AS amount, SUM( round( (own_descriptive_item.amount - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, own_document FROM own_document, own_descriptive_item, own_item, own_item_tax WHERE own_descriptive_item.own_item = own_item.id AND own_document.id = own_item.own_document AND own_item.id = own_item_tax.own_item GROUP BY own_item.own_document, own_item_tax.tax; |
INSERT INTO own_document_tax (tax, amount, taxed_amount, own_document) SELECT tax, SUM(own_item_tax.amount) AS amount, SUM( round( (own_descriptive_item.amount - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, own_document FROM own_document, own_descriptive_item, own_item, own_item_tax WHERE own_descriptive_item.own_item = own_item.id AND own_document.id = own_item.own_document AND own_item.id = own_item_tax.own_item GROUP BY own_item.own_document, own_item_tax.tax; |