|
@@ -524,6 +524,7 @@ function report_sale_utility_vendor(reporting){
|
|
|
_.each(AccountJournal,function(item) {
|
|
|
|
|
|
var total_price = 0;
|
|
|
+ var price_unit = 0;
|
|
|
var total_cost = 0;
|
|
|
|
|
|
var utility = 0;
|
|
@@ -537,30 +538,35 @@ function report_sale_utility_vendor(reporting){
|
|
|
var AccountInvoiceLine = self.getAccountInvoiceLine(item2.id);
|
|
|
_.each(AccountInvoiceLine, function(line_item){
|
|
|
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;
|
|
|
+ // if(line_item.product_id.standard_price != 0){
|
|
|
+ if(line_item.product_id.standard_price >= 0){
|
|
|
+ price_unit = line_item.product_id.standard_price;
|
|
|
+ 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{
|
|
|
+ price_unit = 0;
|
|
|
total_sale = (line_item.price_unit);
|
|
|
- total_cost = (line_item.product_id.standard_price*(1.1)) * line_item.quantity;
|
|
|
+ total_cost = 0;
|
|
|
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){
|
|
|
+ if(line_item.product_id.standard_price >= 0){
|
|
|
+ price_unit = line_item.product_id.standard_price;
|
|
|
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{
|
|
|
+ price_unit = line_item.product_id.standard_price;
|
|
|
total_sale = (line_item.price_unit);
|
|
|
- total_cost = -(line_item.product_id.standard_price*(1.1)) * line_item.quantity;
|
|
|
+ total_cost = 0;
|
|
|
total_price = -(total_sale * line_item.quantity);
|
|
|
utility = (total_price - total_cost);
|
|
|
porc_utility = (0/total_cost)*100;
|
|
@@ -579,7 +585,7 @@ function report_sale_utility_vendor(reporting){
|
|
|
product_code : self.valorNull(line_item.product_id.default_code),
|
|
|
barcode : self.valorNull(line_item.product_id.ean13),
|
|
|
product_name : line_item.product_id.name,
|
|
|
- item_cost : accounting.formatMoney((line_item.product_id.standard_price*(1.1)),'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ item_cost : accounting.formatMoney((price_unit*(1.1)),'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
item_price : accounting.formatMoney(total_sale,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
qty : line_item.quantity,
|
|
|
total_price : accounting.formatMoney(total_price,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
@@ -590,7 +596,7 @@ function report_sale_utility_vendor(reporting){
|
|
|
user_name : item2.user_id[1],
|
|
|
|
|
|
//VALORES SIN FORMATEAR
|
|
|
- item_cost_no_format : (line_item.product_id.standard_price*(1.1)),
|
|
|
+ item_cost_no_format : (price_unit*(1.1)),
|
|
|
item_price_no_format : total_sale,
|
|
|
total_price_no_format : total_price,
|
|
|
total_cost_no_format : total_cost,
|