This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var TipoCambio; | |
TipoCambio = (function () { | |
'use strict'; | |
var getAll, update, add, deleteTipoCambio, responseSuccess; | |
var url = '/api/v2/tipo_cambio'; | |
getAll = function (data, success, error) { | |
$.ajax({ | |
url: url, | |
type: 'GET', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe CatEmpresa, :type => :model do | |
describe "class methods" do | |
describe ".cat_empresa_array_by_invoices" do | |
# Aqui crear una empresa y varias facturas con esa empresa | |
before(:each) do | |
@tipo_cambio = FactoryGirl.create(:tipo_cambio) | |
end | |
context "when there are invoices between 2 companies" do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe CatEmpresa, :type => :model do | |
describe "class methods" do | |
describe ".cat_empresa_array_by_invoices" do | |
# Aqui crear una empresa y varias facturas con esa empresa | |
before(:each) do | |
@factura1 = FactoryGirl.create(:factura, rfc_em: "ABA920310QW0", | |
rfc_re: "CWG1011107T9", md5: "5681928685ae18e3b623d1d0f1910512", | |
uuid: "E8027172-A541-4707-8913-C7528D67FCF3", usuario_id: 21) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "class methods" do | |
describe ".calc_amount" do | |
context "get the calc_amount of an invoice" | |
it "returns 0 when the invoice status is 'Cancelado'" | |
end | |
it "returns 0 when the invoice amount is nil" | |
end | |
it "returns 0 when the invoice has policies from the current company" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_amount(factura, amount, rfc) | |
empresa = Empresa.find_by_rfc(rfc) | |
if (factura.estatus == "Cancelado" || !amount) && factura.polizas_of(empresa.id).blank? | |
return 0 | |
end | |
return 0 if factura.tipo_de_comprobante == 'traslado' | |
if factura.tipo_cambio_id.present? && factura.tipo_cambio.present? && Factura.getMoneda(factura.moneda) != "pesos" | |
vartotal = amount | |
tipo_cambio_p = factura.tipo_cambio.precio | |
return 0 if !amount #check for duplicates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Query cliente | |
SELECT dateinvoice, rfc_re, SUM(subtotal_calc) AS subtotal | |
FROM (SELECT *, | |
CASE | |
WHEN estatus = 'Cancelado' THEN (SELECT CASE | |
WHEN EXISTS (SELECT 1 FROM polizas WHERE factura_id = a.id) THEN subtotaltc | |
ELSE 0 | |
END) | |
ELSE (SELECT CASE | |
WHEN tipo_de_comprobante = 'egreso' AND tipo <> 'nomina' THEN subtotaltc*-1 |