139 |
insert into _tax_formula_data (id,_table,from_profile,to_profile,graft)values (6,6,6,7,'def graft(amount,taxPercent):\n\treturn amount * taxPercent / 100 /2 \n'); |
insert into _tax_formula_data (id,_table,from_profile,to_profile,graft)values (6,6,6,7,'def graft(amount,taxPercent):\n\treturn amount * taxPercent / 100 /2 \n'); |
140 |
|
|
141 |
ALTER TABLE alien_document_tax ADD COLUMN taxed_amount numeric(12,4); |
ALTER TABLE alien_document_tax ADD COLUMN taxed_amount numeric(12,4); |
142 |
|
ALTER TABLE own_document_tax ADD COLUMN taxed_amount numeric(12,4); |
143 |
|
|
144 |
DROP TABLE own_service_item; |
DROP TABLE own_service_item; |
145 |
DROP TABLE alien_service_item; |
DROP TABLE alien_service_item; |
150 |
UPDATE alien_document SET discount_percent=0; |
UPDATE alien_document SET discount_percent=0; |
151 |
UPDATE own_document SET discount_percent=0; |
UPDATE own_document SET discount_percent=0; |
152 |
|
|
|
INSERT INTO alien_document_tax (tax, amount, taxed_amount, alien_document) |
|
|
|
|
153 |
INSERT INTO alien_document_tax (tax, amount, taxed_amount, alien_document) SELECT tax, SUM(amount) AS amount, SUM( ROUND( (qty * unit_price - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, alien_document FROM alien_document, alien_product_item, alien_item, alien_item_tax WHERE alien_product_item.alien_item = alien_item.id AND alien_document.id = alien_item.alien_document AND alien_item.id = alien_item_tax.alien_item GROUP BY alien_item.alien_document, alien_item_tax.tax; |
INSERT INTO alien_document_tax (tax, amount, taxed_amount, alien_document) SELECT tax, SUM(amount) AS amount, SUM( ROUND( (qty * unit_price - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, alien_document FROM alien_document, alien_product_item, alien_item, alien_item_tax WHERE alien_product_item.alien_item = alien_item.id AND alien_document.id = alien_item.alien_document AND alien_item.id = alien_item_tax.alien_item GROUP BY alien_item.alien_document, alien_item_tax.tax; |
154 |
|
|
155 |
INSERT INTO alien_document_tax (tax, amount, taxed_amount, alien_document) SELECT tax, SUM(alien_item_tax.amount) AS amount, SUM( round( (alien_service_item.amount - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, alien_document FROM alien_document, alien_service_item, alien_item, alien_item_tax WHERE alien_service_item.alien_item = alien_item.id AND alien_document.id = alien_item.alien_document AND alien_item.id = alien_item_tax.alien_item GROUP BY alien_item.alien_document, alien_item_tax.tax; |
INSERT INTO alien_document_tax (tax, amount, taxed_amount, alien_document) SELECT tax, SUM(alien_item_tax.amount) AS amount, SUM( round( (alien_service_item.amount - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, alien_document FROM alien_document, alien_service_item, alien_item, alien_item_tax WHERE alien_service_item.alien_item = alien_item.id AND alien_document.id = alien_item.alien_document AND alien_item.id = alien_item_tax.alien_item GROUP BY alien_item.alien_document, alien_item_tax.tax; |
156 |
|
|
157 |
INSERT INTO own_document_tax (tax, amount, taxed_amount, own_document) SELECT tax, SUM(amount) AS amount, SUM( ROUND( (qty * unit_price - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, own_document FROM own_document, own_product_item, own_item, own_item_tax WHERE own_product_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(amount) AS amount, SUM( ROUND( (qty * unit_price - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, own_document FROM own_document, own_product_item, own_item, own_item_tax WHERE own_product_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; |
158 |
|
|
159 |
INSERT INTO own_document_tax (tax, amount, taxed_amount, own_document) SELECT tax, SUM(own_item_tax.amount) AS amount, SUM( round( (own_service_item.amount - bonus - discount)*(1-discount_percent/100) ,2) ) AS taxed_amount, own_document FROM own_document, own_service_item, own_item, own_item_tax WHERE own_service_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; |
160 |
|
|
161 |
INSERT INTO own_document_tax (tax, amount, own_document) SELECT tax, sum(amount), own_document FROM own_item_tax, own_item WHERE own_item_tax.own_item = own_item.id GROUP BY own_document, tax; |
INSERT INTO own_document_tax (tax, amount, own_document) SELECT tax, sum(amount), own_document FROM own_item_tax, own_item WHERE own_item_tax.own_item = own_item.id GROUP BY own_document, tax; |
162 |
|
|