|
@@ -536,19 +536,35 @@ function report_sale_utility_vendor(reporting){
|
|
|
|
|
|
var AccountInvoiceLine = self.getAccountInvoiceLine(item2.id);
|
|
|
_.each(AccountInvoiceLine, function(line_item){
|
|
|
-
|
|
|
- if(line_item.product_id.standard_price != 0){
|
|
|
- total_sale = (line_item.price_unit);
|
|
|
- total_cost = (line_item.product_id.standard_price*(1.1)) * line_item.quantity;
|
|
|
- total_price = total_sale * line_item.quantity;
|
|
|
- utility = total_price - total_cost;
|
|
|
- porc_utility = (utility/total_cost)*100;
|
|
|
- }else{
|
|
|
- total_sale = (line_item.price_unit);
|
|
|
- total_cost = (line_item.product_id.standard_price*(1.1)) * line_item.quantity;
|
|
|
- total_price = total_sale * line_item.quantity;
|
|
|
- utility = total_price - total_cost;
|
|
|
- porc_utility = (0/total_cost)*100;
|
|
|
+ if(item2.type == 'out_invoice'){
|
|
|
+ if(line_item.product_id.standard_price != 0){
|
|
|
+ total_sale = (line_item.price_unit);
|
|
|
+ total_cost = (line_item.product_id.standard_price*(1.1)) * line_item.quantity;
|
|
|
+ total_price = total_sale * line_item.quantity;
|
|
|
+ utility = total_price - total_cost;
|
|
|
+ porc_utility = (utility/total_cost)*100;
|
|
|
+ }else{
|
|
|
+ total_sale = (line_item.price_unit);
|
|
|
+ total_cost = (line_item.product_id.standard_price*(1.1)) * line_item.quantity;
|
|
|
+ total_price = total_sale * line_item.quantity;
|
|
|
+ utility = (total_price - total_cost) ;
|
|
|
+ porc_utility = (0/total_cost)*100;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(item2.type == 'out_refund'){
|
|
|
+ if(line_item.product_id.standard_price != 0){
|
|
|
+ total_sale = (line_item.price_unit);
|
|
|
+ total_cost = -(line_item.product_id.standard_price*(1.1)) * line_item.quantity;
|
|
|
+ total_price = -(total_sale * line_item.quantity);
|
|
|
+ utility = (total_price - total_cost) ;
|
|
|
+ porc_utility = -(utility/total_cost)*100;
|
|
|
+ }else{
|
|
|
+ total_sale = (line_item.price_unit);
|
|
|
+ total_cost = -(line_item.product_id.standard_price*(1.1)) * line_item.quantity;
|
|
|
+ total_price = -(total_sale * line_item.quantity);
|
|
|
+ utility = (total_price - total_cost);
|
|
|
+ porc_utility = (0/total_cost)*100;
|
|
|
+ }
|
|
|
}
|
|
|
data.push({
|
|
|
//IDS
|
|
@@ -569,7 +585,7 @@ function report_sale_utility_vendor(reporting){
|
|
|
total_price : accounting.formatMoney(total_price,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
total_cost : accounting.formatMoney(total_cost,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
utility_porcent : accounting.formatNumber((porc_utility),2, ".", ","),
|
|
|
- utility : accounting.formatMoney(utility,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ utility : accounting.formatMoney((utility),'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
user_id : self.valorNull(item2.user_id[0]),
|
|
|
user_name : item2.user_id[1],
|
|
|
|
|
@@ -578,7 +594,7 @@ function report_sale_utility_vendor(reporting){
|
|
|
item_price_no_format : total_sale,
|
|
|
total_price_no_format : total_price,
|
|
|
total_cost_no_format : total_cost,
|
|
|
- utility_no_format : utility,
|
|
|
+ utility_no_format : (utility),
|
|
|
utility_porcent_no_format : porc_utility,
|
|
|
|
|
|
//TOTAL FOOTER CONFIGURATION
|