Skip to content

Instantly share code, notes, and snippets.

@s1037989
Created January 10, 2019 02:41
Show Gist options
  • Select an option

  • Save s1037989/ea2d06e341dcbcfc395ddc3c84095b7a to your computer and use it in GitHub Desktop.

Select an option

Save s1037989/ea2d06e341dcbcfc395ddc3c84095b7a to your computer and use it in GitHub Desktop.
use Mojo::Base -strict;
use Mojo::Util 'dumper';
use Mojo::File 'path';
use Mojo::ByteStream 'b';
my ($at, $qb) = map { b(path($_)->slurp)->split("\n") } @ARGV[0,1];
my %recon;
$at->grep(qr/^\d+\t/)->each(sub {
my ($batchid, $invoiceid, $invoice, $amount) = (/^(\d+)\t(\d+)\t(\d+)\.00\t(\d+\.\d{2})\r?\n?$/);
$invoice ||= 0;
$amount ||= 0;
#warn "$batchid, $invoiceid, $invoice, $amount";
my $amount_qb = $qb->grep(qr/\tInvoice\t/)->map(sub{@_ = split /\t/, $_; $_[18] =~ s/,//g; $_[18] =~ s/\r?//; $_=[$_[8],$_[14]?0:$_[18]]})->grep(sub{$_->[0] eq $invoice})->first;
$recon{$invoice} ||= [0,0];
$recon{$invoice}->[0] += $amount;
$recon{$invoice}->[1] += $amount_qb->[1]||0;
});
foreach ( sort keys %recon ) {
say "$_ => [$recon{$_}->[0], $recon{$_}->[1]]" unless $recon{$_}->[0] eq $recon{$_}->[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment