1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-16 15:52:47 +01:00
This commit is contained in:
Nick Bebout 2012-04-16 17:31:15 -05:00
parent ae3e0f4870
commit 74ca16d8c6
23 changed files with 404 additions and 2734 deletions

13
CREDITS
View File

@ -1,5 +1,5 @@
#!/bin/cat
# $Id: CREDITS,v 1.165 2011/12/10 02:25:01 gilles Exp gilles $
# $Id: CREDITS,v 1.167 2012/02/07 00:22:01 gilles Exp gilles $
If you want to make a donation to the author, Gilles LAMIRAL,
use any of the following ways:
@ -30,6 +30,16 @@ I thank very much all of these people.
I thank also very much all people who bought imapsync from the homepage
but I don't cite them here.
? (Found no card in the packet may be lost since book is damaged, amazon and paper box for an international transported book ...)
Contributed by giving the book
87.18 "Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp"
Christophe Kern
Bugfix in the invoice ("paiement à réception de facture")
GSSAPI proposition
--useuid --nousecache creates duplicates and should be documented.
--usecache creates many inodes
Thomas Edgar
Gave a FAQ item "from Exchange 2003 to Cyrus Imap 2.4"
@ -1037,6 +1047,7 @@ Eric Yung
Total amount of book prices :
c \
87.18+\
19.90+\
13.59+\
32.65+\

View File

@ -1,17 +1,36 @@
RCS file: RCS/imapsync,v
Working file: imapsync
head: 1.480
head: 1.484
branch:
locks: strict
gilles: 1.480
gilles: 1.484
access list:
symbolic names:
keyword substitution: kv
total revisions: 480; selected revisions: 480
total revisions: 484; selected revisions: 484
description:
----------------------------
revision 1.480 locked by: gilles;
revision 1.484 locked by: gilles;
date: 2012/02/07 00:19:33; author: gilles; state: Exp; lines: +8 -7
Just a comment about examine versus select on host1.
----------------------------
revision 1.483
date: 2012/02/06 23:16:06; author: gilles; state: Exp; lines: +7 -7
Bug fix. Read-only mode on host1 can't be done with --delete (back to select instead of examine).
----------------------------
revision 1.482
date: 2012/01/23 00:39:12; author: gilles; state: Exp; lines: +25 -10
Added --exitwhenover option to avoid locking when transfers exceed maximum limit,
See for example http://support.google.com/a/bin/answer.py?hl=en&answer=1071518
--exitwhenover 2500000000 if host1 is Gmail
--exitwhenover 500000000 if host2 is Gmail
----------------------------
revision 1.481
date: 2012/01/22 23:43:02; author: gilles; state: Exp; lines: +24 -9
Check if a message exists before fetching it (could have been deleted recently)
----------------------------
revision 1.480
date: 2012/01/08 05:11:03; author: gilles; state: Exp; lines: +8 -7
a1.net fix.
----------------------------

19
INSTALL
View File

@ -1,4 +1,4 @@
# $Id: INSTALL,v 1.22 2011/12/10 02:27:04 gilles Exp gilles $
# $Id: INSTALL,v 1.23 2012/01/30 19:23:36 gilles Exp gilles $
#
# INSTALL file for imapsync
# imapsync : IMAP sync or copy tool.
@ -95,7 +95,7 @@ Here is some individual module help:
- Term::ReadKey
perl -mTerm::ReadKey -e ''
- IO:Socket:SSL.pm
- IO::Socket::SSL
perl -mIO::Socket::SSL -e ''
- File::Spec
@ -115,7 +115,7 @@ Test everything in one command:
perl -mMail::IMAPClient -mDigest::MD5 -mTerm::ReadKey -mIO::Socket::SSL \
-mFile::Spec -mDigest::HMAC_MD5 -mAuthen::NTLM -e ''
You can install automatically those Perl modules via the
You can install easily those Perl modules in latest release via the
following commands (with root permissions)
perl -MCPAN -e 'install Mail::IMAPClient'
@ -126,6 +126,19 @@ following commands (with root permissions)
perl -MCPAN -e 'install Digest::HMAC_MD5'
perl -MCPAN -e 'install Authen::NTLM'
You can install them easily too by using the standard install
command on your system if the packages have been made on it
(so you may not have the latest but most of the time it
doesn't care).
Example on Debian/Ubuntu:
aptitude install libmail-imapclient-perl # Mail::IMAPClient'
aptitude install libdigest-md5-file-perl # Digest::MD5'
aptitude install libterm-readkey-perl # Term::ReadKey'
aptitude install libio-socket-ssl-perl # IO::Socket::SSL'
aptitude install libfile-spec-perl # File::Spec'
aptitude install libdigest-hmac-perl # Digest::HMAC_MD5'
aptitude install ? # (not free?) # Authen::NTLM
INSTALLING on Unix
------------------

View File

@ -1,5 +1,5 @@
# $Id: Makefile,v 1.90 2012/01/08 06:39:38 gilles Exp gilles $
# $Id: Makefile,v 1.93 2012/02/07 10:55:04 gilles Exp gilles $
.PHONY: help usage all
@ -134,8 +134,8 @@ testf: clean_test test
.PHONY: lfo upload_lfo niouze_lfo niouze_fm public imapsync_cidone
.dosify_bat: build_exe.bat test_exe.bat test.bat test2.bat
unix2dos build_exe.bat test.bat test_exe.bat test2.bat
.dosify_bat: build_exe.bat test_exe.bat test.bat test2.bat imapsync_example.bat.txt
unix2dos build_exe.bat test.bat test_exe.bat test2.bat imapsync_example.bat.txt
touch .dosify_bat
dosify_bat: .dosify_bat
@ -264,7 +264,8 @@ PUBLIC_FILES = ./ChangeLog ./COPYING ./CREDITS ./FAQ \
./index.shtml ./INSTALL ./TIME \
./logo_imapsync.png ./logo_imapsync_s.png \
./paypal.shtml ./paypal_return.shtml ./paypal_return_support.shtml \
./README ./style.css ./TODO ./VERSION ./VERSION_EXE ./memo ./file.txt
./README ./style.css ./TODO ./VERSION ./VERSION_EXE ./memo ./file.txt \
./imapsync_example.bat.txt
upload_ks:
rsync -lptvHzP $(PUBLIC_FILES) \
@ -284,7 +285,7 @@ upload_lfo:
upload_index: index.shtml FAQ
validate --verbose index.shtml
rcsdiff index.shtml
rsync -avH index.shtml root@ks.lamiral.info:/var/www/imapsync/
rsync -avH index.shtml FAQ root@ks.lamiral.info:/var/www/imapsync/
rsync -avH index.shtml FAQ \
../../public_html/www.linux-france.org/html/prj/imapsync/
sh $(HOME)/memo/lfo-rsync

4
README
View File

@ -3,7 +3,7 @@ NAME
Synchronise mailboxes between two imap servers. Good at IMAP migration.
More than 44 different IMAP server softwares supported with success.
$Revision: 1.480 $
$Revision: 1.484 $
SYNOPSIS
To synchronise imap account "foo" on "imap.truc.org" to imap account
@ -444,5 +444,5 @@ SIMILAR SOFTWARES
Feedback (good or bad) will often be welcome.
$Id: imapsync,v 1.480 2012/01/08 05:11:03 gilles Exp gilles $
$Id: imapsync,v 1.484 2012/02/07 00:19:33 gilles Exp gilles $

2
TIME
View File

@ -1,4 +1,4 @@
240 Fixed long names in invoices. + january invoices.
180 Release 1.476 --addheader
15 Added start and end dates in the final statistics.
210 Added statistics on ks and lfo, % Operating systems, ip per year .Updated index.shtml

25
TODO
View File

@ -1,5 +1,5 @@
#!/bin/cat
# $Id: TODO,v 1.108 2011/12/07 23:59:32 gilles Exp gilles $
# $Id: TODO,v 1.110 2012/02/07 00:20:32 gilles Exp gilles $
TODO file for imapsync
----------------------
@ -30,18 +30,12 @@ Think about Digest::SHA or Digest::SHA::PurePerl.
Try to use imapsync with cygwin.
Change default --useheader 'Message-ID' --useheader Date to
--useheader 'Message-ID' --useheader 'Received'
because Exchange changes Date header! (but not Received:)
Add an option to solve syncing Sent folder when no good header
are available:
http://www.linux-france.org/prj/imapsync_list/msg01151.html
http://www.linux-france.org/prj/imapsync_list/msg01158.html
Check message exists before fetching it (could have been deleted recently)
Find a way to avoid passwords in --debugimap unless needed.
Explain that users can win time/bandwidth by using --expunge
@ -63,9 +57,6 @@ e-mail when it gets synced, rather than just the message ID and the date/time.
Add a well described problem for each problem detected
and counted in error counter statistics.
Add "output to reflect everything that imapsync was doing".
Not everything but flag synchronization will be nice"
Add sync imap keywords. Sync gmail labels to imap keyword
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=503159
http://www.linux-france.org/prj/imapsync_list/msg00022.html
@ -167,6 +158,20 @@ http://asg.web.cmu.edu/cyrus/download/imapd/altnamespace.html
===========================================================================
DONE. Add an option --exitwhenover 2500000000 to avoid to be banned or locked
http://support.google.com/a/bin/answer.py?hl=en&answer=1071518
DONE. Check if a message exists before fetching it (could have been deleted recently)
(Check avoided when UID mode is not available)
DONE. Change default --useheader 'Message-ID' --useheader Date to
--useheader 'Message-ID' --useheader 'Received'
because Exchange changes Date header! (but not Received:)
DONE. Add "output to reflect everything that imapsync was doing".
Not everything but flag synchronization will be nice"
--debugflags does this.
DONE. Add a script to install automaticaly all needed Perl modules
if needed. Not a script but command lines in INSTALL file.

View File

@ -1 +1 @@
1.480
1.484

View File

@ -1 +1 @@
1.480
1.484

View File

@ -2,7 +2,38 @@
# $Id: memo,v 1.5 2011/05/20 12:57:31 gilles Exp gilles $
echo paypal_bilan_tests_refact_4
echo paypal_bilan_tests_invoice
paypal_bilan_tests_invoice() {
# DID output no diff between paypal_bilan_1.43 and 1.??
(
#set -x
/g/public_html/imapsync/W/paypal_reply/paypal_bilan_1.44 --bnc --debug --debug_invoice --first_in 147 --avoid_numbers '292 293 643 644 731 732 1093 1330 1331 1332 1333 1334' /g/paypal/paypal_201?_??_complet.csv \
> /g/var/paypal_bilan/tests/paypal_invoice.out1 2>&1
/g/public_html/imapsync/W/paypal_reply/paypal_bilan --bnc --debug --debug_invoice --first_in 147 --avoid_numbers '292 293 643 644 731 732 1093 1330 1331 1332 1333 1334' /g/paypal/paypal_201?_??_complet.csv \
> /g/var/paypal_bilan/tests/paypal_invoice.out2 2>&1
echo diff /g/var/paypal_bilan/tests/paypal_invoice.out1 /g/var/paypal_bilan/tests/paypal_invoice.out2
diff /g/var/paypal_bilan/tests/paypal_invoice.out1 /g/var/paypal_bilan/tests/paypal_invoice.out2
)
}
#echo paypal_bilan_tests_Etat_Province
paypal_bilan_tests_Etat_Province() {
# DID output no diff between paypal_bilan_1.41 and 1.42
(
#set -x
/g/public_html/imapsync/W/paypal_reply/paypal_bilan_1.41 --bnc --debug --first_in 147 --avoid_numbers '292 293 643 644 731 732 1093 1330 1331 1332 1333 1334' /g/paypal/paypal_201?_??_complet.csv \
> /g/var/paypal_bilan/tests/paypal_Etat_Province.out1 2>&1
/g/public_html/imapsync/W/paypal_reply/paypal_bilan --bnc --debug --first_in 147 --avoid_numbers '292 293 643 644 731 732 1093 1330 1331 1332 1333 1334' /g/paypal/paypal_201?_??_complet.csv \
> /g/var/paypal_bilan/tests/paypal_Etat_Province.out2 2>&1
echo diff /g/var/paypal_bilan/tests/paypal_Etat_Province.out1 /g/var/paypal_bilan/tests/paypal_Etat_Province.out2
diff /g/var/paypal_bilan/tests/paypal_Etat_Province.out1 /g/var/paypal_bilan/tests/paypal_Etat_Province.out2
)
}
#echo paypal_bilan_tests_refact_4
paypal_bilan_tests_refact_4() {
# DID output no diff between paypal_bilan_1.33 and 1.??
(

View File

@ -1,6 +1,6 @@
#!/usr/bin/perl
# $Id: paypal_bilan,v 1.39 2011/11/30 07:59:11 gilles Exp gilles $
# $Id: paypal_bilan,v 1.45 2012/01/30 03:12:55 gilles Exp gilles $
use strict;
use warnings;
@ -32,6 +32,9 @@ my ( $tests, $testeur ) ;
my $debug ;
my $debug_csv ;
my $debug_dev ;
my $debug_invoice ;
my $debug_invoice_utf8 ;
my $first_invoice = 1 ;
my $print_details = '' ;
my $bnc = '' ;
@ -49,6 +52,9 @@ my $option_ret = GetOptions (
'debug' => \$debug,
'debug_csv' => \$debug_csv,
'debug_dev' => \$debug_dev,
'debug_invoice' => \$debug_invoice,
'debug_invoice_utf8' => \$debug_invoice_utf8,
'first_invoice=i' => \$first_invoice,
'print_details|details' => \$print_details,
'bnc' => \$bnc,
@ -95,6 +101,7 @@ foreach my $file ( @files ) {
'Devise', 'Montant', "Numéro d'avis de réception", 'Solde',
'Pays', 'Nom Option 1', 'Valeur Option 1', 'Hors taxe', "Titre de l'objet") } ;
#print "$Nom\n" ;
( $Etat ) = @action{ ( 'Etat', ) } || @action{ ( 'État' ) } ;
my $invoice = 'NONE' ;
$Montant = $action->{ Net } if not defined $Montant;
compute_line($action, $invoice, $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
@ -130,6 +137,7 @@ foreach my $invoice ( @invoices_wanted ) {
if ( $invoice_sent ) {
$invoice_sent{ $invoice }++ ;
#build_invoice( $invoice ) ;
}else{
$invoice_not_sent{ $invoice }++ ;
build_invoice( $invoice ) ;
@ -313,22 +321,22 @@ sub keyval {
sub tests_next_invoice {
ok( 1 == next_invoice( ) ) ;
ok( 2 == next_invoice( ) ) ;
ok( 1 == next_invoice( ), 'next_invoice: 1' ) ;
ok( 2 == next_invoice( ), 'next_invoice: 2' ) ;
@avoid_numbers{ (3, 4, 6, 8 ) } = ( ) ;
ok( 5 == next_invoice( ) ) ;
ok( 7 == next_invoice( ) ) ;
ok( 9 == next_invoice( ) ) ;
ok( 5 == next_invoice( ), 'next_invoice: 7' ) ;
ok( 7 == next_invoice( ), 'next_invoice: 8' ) ;
ok( 9 == next_invoice( ), 'next_invoice: 9' ) ;
%invoice_paypal = () ;
$first_invoice = 7 ;
ok( 7 == next_invoice( ) ) ;
ok( 7 == next_invoice( ), 'next_invoice: 7' ) ;
}
sub tests {
tests_next_invoice( ) ;
#tests_half( ) ;
tests_cut( ) ;
}
sub compute_line {
@ -480,6 +488,13 @@ sub build_invoice {
'Adresse 1', 'Adresse 2/district/quartier', 'Ville',
'Etat/Province/Région/Comté/Territoire/Préfecture/République', 'Code postal', 'Pays', 'line_number', 'line_csv', 'file_csv' ) } ;
my( $Etat_Province1 ) = @action{ ( 'Etat/Province/Région/Comté/Territoire/Préfecture/République' ) } ;
my( $Etat_Province2 ) = @action{ ( 'État/Province/Région/Comté/Territoire/Préfecture/République' ) } ;
$Etat_Province = @action{ ( 'Etat/Province/Région/Comté/Territoire/Préfecture/République' ) }
|| @action{ ( 'État/Province/Région/Comté/Territoire/Préfecture/République' ) }
|| '' ;
#print "$Hors_taxe $Devise\n" ;
my $Hors_taxe_num = $Hors_taxe ;
$Hors_taxe_num =~ s{,}{.} ;
@ -510,7 +525,7 @@ sub build_invoice {
$clientAdrE,
$clientAdrF,
)
= build_adress(
= build_address(
$Nom,
$Adresse_1,
$Adresse_2_district_quartier,
@ -564,10 +579,11 @@ sub build_invoice {
my ( $urlSrc, $urlExe ) = download_urls( $Date, $object_type ) ;
#print "ZZZ $object_type ( $urlSrc, $urlExe )\n" ;
my ( $Nom1 ) = cut( $Nom, 42 ) ;
my $tex_variables = qq{
%% Begin input from $0
%% Begin input from paypal_bilan
\\providecommand{\\invoiceNumber}{$invoice}
\\providecommand{\\clientName}{$Nom}
\\providecommand{\\clientName}{$Nom1}
\\providecommand{\\clientEmail}{$De_l_adresse_email}
\\providecommand{\\clientAdrA}{$clientAdrA}
\\providecommand{\\clientAdrB}{$clientAdrB}
@ -594,15 +610,17 @@ sub build_invoice {
\\providecommand{\\messageTVAEN}{$messageTVAEN}
\\providecommand{\\urlSrc}{\\url{$urlSrc}}
\\providecommand{\\urlExe}{\\url{$urlExe}}
%% End input from $0
%% End input from paypal_bilan
} ;
my $tex_variables_utf8 = to_utf8( { -string => $tex_variables, -charset => 'ISO-8859-1' } ) ;
#print $tex_variables ;
print $tex_variables_utf8 if $debug_invoice_utf8 ;
print $tex_variables if $debug_invoice ;
#print "$invoice ", invoice_sent( $dir_invoices, $invoice, $De_l_adresse_email ), "\n" ;
if ( $write_invoices and ! invoice_sent( $dir_invoices, $invoice, $De_l_adresse_email ) ) {
write_tex_variables_file( $dir_invoices, $invoice, $Date, $tex_variables ) ;
write_tex_variables_file( $dir_invoices, $invoice, $Date, $tex_variables_utf8 ) ;
}
}
@ -823,18 +841,19 @@ sub write_email_message {
}
sub write_tex_variables_file {
my ( $dir_invoices, $invoice, $date_jjSmmSaaaa, $tex_variables ) = @_ ;
sub write_tex_variables_file {
my ( $dir_invoices, $invoice, $date_jjSmmSaaaa, $tex_variables_utf8 ) = @_ ;
my $tex_variables_utf8 = to_utf8({ -string => $tex_variables, -charset => 'ISO-8859-1' });
mkdir( "$dir_invoices/$invoice" ) or die if ! -d "$dir_invoices/$invoice" ;
open( FILE, "> $dir_invoices/$invoice/imapsync_var.tex") or die ;
print FILE $tex_variables_utf8 ;
close( FILE ) ;
if ( ! -f "$dir_invoices/$invoice/imapsync_var_manual.tex" ) {
open( FILE, "> $dir_invoices/$invoice/imapsync_var_manual.tex") or die ;
print FILE "%% $0 created file
%% Can be used to override imapsync_var.tex definitions\n" ;
print FILE $tex_variables_utf8 ;
close( FILE ) ;
}
@ -1012,7 +1031,7 @@ sub client_type {
return( $clientTypeEN, $clientTypeFR ) ;
}
sub build_adress {
sub build_address {
my(
$Nom,
$Adresse_1,
@ -1036,7 +1055,9 @@ Pays $Pays
my @address ;
$Nom = '' if ( $Nom =~ m/^\s+$/ ) ;
push( @address, $Nom ) if $Nom ;
my( $Nom1, $Nom2 ) = cut( $Nom, 42 ) ;
push( @address, $Nom1 ) if $Nom1 ;
#push( @address, $Nom2 ) if $Nom2 ;
push( @address, $Adresse_1 ) if $Adresse_1 ;
push( @address, $Adresse_2_district_quartier ) if $Adresse_2_district_quartier ;
push( @address, "$Ville $Code_postal" ) if ( $Ville or $Code_postal );
@ -1070,3 +1091,33 @@ $addr = "
$clientAdrF,
) ;
}
sub half {
my $string = shift ;
my $half = int( lenght( $string ) / 2 ) ;
# TO BE DONE
}
sub tests_half {
my( $aa, $bb ) = half( 'aa bb' ) ;
ok( 'aa' eq $aa, 'half: aa' ) ;
ok( 'bb' eq $bb, 'half: bb' ) ;
}
sub cut {
my $string = shift ;
my $offset = shift ;
return( $string, '' ) if length( $string ) < $offset ;
my $first = substr( $string, 0, $offset ) ;
my $last = substr( $string, $offset ) ;
return( $first, $last ) ;
}
sub tests_cut {
my( $aa, $bb ) = cut("123456789", 4 ) ;
ok( '1234' eq $aa, 'cut 123456789 4 => first 1234' ) ;
ok( '56789' eq $bb, 'cut 123456789 4 => last 56789' ) ;
}

View File

@ -1,756 +0,0 @@
#!/usr/bin/perl
# $Id: paypal_bilan,v 1.22 2011/04/19 12:52:27 gilles Exp $
use strict;
use warnings;
use Getopt::Long;
use Text::CSV_XS ;
use IO::Handle ;
use Data::Dumper ;
use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset);
die unless (utf8_supported_charset('ISO-8859-1'));
my $total_usd_received = 0 ;
my $total_usd_invoice = 0 ;
my $total_eur_received = 0 ;
my $total_eur_invoice = 0 ;
my $nb_invoice = 0 ;
my $nb_invoice_refund = 0 ;
my $debug ;
my $debug_csv ;
my $debug_dev ;
my $first_invoice = 1 ;
my $print_details = '' ;
my $bnc = '';
my $usdeur = 1.2981 ;
my $invoices ;
my %invoice_refund ;
my $write_invoices = 0;
my $dir_invoices = '/g/var/paypal_invoices' ;
my $option_ret = GetOptions (
'debug' => \$debug,
'debug_csv' => \$debug_csv,
'debug_dev' => \$debug_dev,
'first_invoice=i' => \$first_invoice,
'print_details|details' => \$print_details,
'bnc' => \$bnc,
'usdeur=f' => \$usdeur,
'invoices=s' => \$invoices,
'write_invoices!' => \$write_invoices,
);
my @files = @ARGV ;
my %action_of_invoice ;
my @invoices = split( /\s+/, $invoices ) if $invoices ;
#print "@invoices\n" ;
foreach my $file ( @files ) {
my @actions = parse_file( $file ) ;
foreach my $action (@actions) {
my %action = %$action ;
#print $action->{ Nom }, "\n" ;
my( $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
$Devise, $Montant, $Numero_davis_de_reception, $Solde,
$Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe )
= @action{ ( 'Date', 'Heure', 'Fuseau horaire', 'Nom', 'Type', 'Etat',
'Devise', 'Montant', "Numéro d'avis de réception", 'Solde',
'Pays', 'Nom Option 1', 'Valeur Option 1', 'Hors taxe') } ;
#print "$Nom\n" ;
my $invoice = 'NONE' ;
$Montant = $action->{ Net } if not defined $Montant;
compute_line($action, $invoice, $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
$Devise, $Montant, $Numero_davis_de_reception, $Solde,
$Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe ) ;
# index by invoice number
$action_of_invoice{ $action->{ 'invoice' } } = $action ;
}
delete $action_of_invoice{ 'NONE' } ;
}
@invoices = ( $first_invoice .. $first_invoice + $nb_invoice -1 ) if ( ! @invoices ) ;
foreach my $invoice ( @invoices ) {
build_invoice( $invoice ) ;
}
print "USD banque $total_usd_received\n" ;
print "USD invoice $total_usd_invoice\n" ;
my $total_eur_from_usd ;
$total_eur_from_usd = int( ( $total_usd_invoice / $usdeur ) + 0.5 ) ; # au 30 nov 2010 http://fr.finance.yahoo.com/devises/convertisseur/#from=EUR;to=USD;amt=1
print "EUR from USD $total_eur_from_usd\n" ;
#$total_eur = int( ( $total_eur_invoice / 1.3 ) + 0.5 ) ;
#print "EUR $total_eur_from_usd\n" ;
print "EUR banque $total_eur_received\n" ;
print "EUR invoice $total_eur_invoice\n" ;
my $total_eur = $total_eur_from_usd + $total_eur_invoice ;
print "EUR total $total_eur\n" ;
print "Nb invoice $nb_invoice\n" ;
print "Nb invoice refund $nb_invoice_refund\n" ;
sub parse_one_line_io {
my $csv = shift ;
my $io = shift ;
my $line = $csv->getline($io) ;
return if ( $csv->eof( ) ) ;
if ( not defined( $line ) ) {
my($cde, $str, $pos) = $csv->error_diag () ;
print "[$cde] [$str] [$pos]\n" ;
}
return( $line ) ;
}
sub hash_and_count_dupplicate {
my @columns = @_ ;
my %columns ;
#@columns_def{ @columns_def } = ( ) ;
foreach my $col ( @columns ) {
$columns{ $col } += 1 ;
}
$debug_csv and print "Nb columns: ", scalar( keys %columns ), " ", scalar( @columns ), "\n" ;
# debug how many time a title is defined
foreach my $col (1 .. scalar( @columns )) {
$debug_csv and print "$col | ",
deci_to_AA( $col ) , " | ",
$columns{ $columns[ $col - 1 ] }, " | ",
$columns[ $col - 1 ], "\n" ;
}
# exit in case two columns have the same name
die "Erreur : doublons dans les titres\n" if ( scalar( keys %columns ) != scalar( @columns ) ) ;
return( %columns ) ;
}
sub deci_to_AA {
my $deci = shift ;
my $AA = '';
while ( $deci > 0 ) {
my $quot = int( ( $deci - 1 ) / 26 ) ;
my $rest = $deci - 1 - ( 26 * $quot ) ;
my $char = chr ( ord('A') + $rest ) ;
$AA = $char . $AA ;
$deci = $quot ;
}
#print "col=$AA\n" ;
return( $AA ) ;
}
sub remove_first_blank {
my $string = shift ;
$string =~ s/^ +// ;
return( $string ) ;
}
sub parse_file {
my $file = shift ;
open my $io, "<", $file or die "$file: $!" ;
my $csv = Text::CSV_XS->new( {
sep_char => ',',
binary => 1,
keep_meta_info => 1,
eol => $/,
} ) ;
my $line_1 = parse_one_line_io( $csv, $io ) ;
die if ( not defined $line_1 ) ; # first line must have no problem
my @columns_def_orig = @$line_1 ;
my @columns_def = map { remove_first_blank( $_ ) } @columns_def_orig ;
$debug_csv and print "columns_def = ", map( { "[$_]" } @columns_def ), "\n";
my %columns_def = hash_and_count_dupplicate( @columns_def ) ;
my $nb_columns_def = scalar @columns_def ;
my $line_counter = 2 ;
my @actions ;
while ( 1 ) {
$debug_csv and print "ligne $line_counter ", $csv->eof( ), "\n" ;
my $line = parse_one_line_io( $csv, $io ) ;
last if ( $csv->eof( ) ) ;
if ( not defined $line ) {
print "Erreur ligne $line_counter : ", $csv->error_diag, "\n\n";
++$line_counter ;
next ;
}
my @columns = @$line ;
if ( $nb_columns_def != scalar @columns ) {
print "Erreur ligne $line_counter : nombre de colonnes = ", scalar @columns, " != $nb_columns_def\n" ;
++$line_counter ;
next ;
}
my %columns ;
@columns{ @columns_def } = @columns ;
$columns{ 'file_csv' } = $file ;
$columns{ 'line_number' } = $line_counter ;
$csv->combine( @columns ) ;
my $line_csv = $csv->string();
$columns{ 'line_csv' } = $line_csv ;
$debug_csv and print map( { "[$_] = [" . $columns{$_} . "]\n" }
@columns_def, 'line_number', 'line_csv', 'file_csv' ),
"\n";
++$line_counter ;
push( @actions, \%columns ) ;
}
close( $io );
return( reverse @actions ) ;
}
sub compute_line {
my( $action, $invoice, $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
$Devise, $Montant, $Numero_davis_de_reception, $Solde,
$Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe_paypal ) = @_ ;
$debug and print( "[$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n",
"[$Pays] [$Nom_Option_1] [$Valeur_Option_1]\n" ) ;
#$debug_dev and print "$Hors_taxe_paypal\n" ;
$Montant =~ s/[^0-9-,.]//g ;
$Montant =~ s/,/./g ;
#$debug and print "MM[$Montant]\n" ;
$Hors_taxe_paypal =~ s/,/./g ;
my $MontantEUR;
if ( $bnc ) {
$MontantEUR = $Montant ;
$MontantEUR = sprintf( "%.4f", $Montant/$usdeur ) if ($Devise eq 'USD') ;
print( "\n", "=" x 60, "\n" ) ;
print( "[$Date] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [EUR $MontantEUR]\n",
"[$Pays] [$Nom_Option_1] [$Valeur_Option_1]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'USD' eq $Devise
and 'Terminé' eq $Etat
) {
$Montant =~tr/,/./;
#print "$Montant\n" ;
my $Montant2_usd;
$Montant2_usd = $Hors_taxe_paypal ;
$total_usd_received += $Montant ;
$total_usd_invoice += $Montant2_usd ;
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'USD' eq $Devise
and 'Compensé' eq $Etat
) {
$Montant =~tr/,/./;
#print "$Montant\n" ;
my $Montant2_usd;
$Montant2_usd = $Hors_taxe_paypal ;
$total_usd_received += $Montant ;
$total_usd_invoice += $Montant2_usd ;
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'EUR' eq $Devise
and 'Terminé' eq $Etat
) {
$Montant =~tr/,/./;
#print "$Montant\n" ;
my $Montant2_eur;
$Montant2_eur = $Hors_taxe_paypal ;
$total_eur_received += $Montant ;
$total_eur_invoice += $Montant2_eur ;
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'EUR' eq $Devise
and 'Remboursé' eq $Etat
) {
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$nb_invoice_refund++;
$invoice_refund{ $invoice }++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'EUR' eq $Devise
and 'Compensé' eq $Etat
) {
$Montant =~tr/,/./;
#print "$Montant\n" ;
my $Montant2_eur;
$Montant2_eur = 21.99 if ( 20.88 == $Montant or 20.99 == $Montant ) ;
$Montant2_eur = 30 if ( 28.58 == $Montant or 28.73 == $Montant ) ;
$Montant2_eur = 110 if ( 105.46 == $Montant ) ;
#print "$Montant $Montant2_eur\n" ;
$total_eur_received += $Montant ;
$total_eur_invoice += $Montant2_eur ;
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'EUR' eq $Devise
and 'Non compensé' eq $Etat
) {
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
$action->{ 'invoice' } = $invoice ;
if ( $bnc ) {
my $FR_flag = '' ;
$FR_flag = ' FR' if $Pays eq 'France' ;
my $IND_flag = '' ;
$IND_flag = ' IND' if ('imapsync usage' eq $Nom_Option_1 and 'individual' eq $Valeur_Option_1 ) ;
print "FE $invoice$FR_flag$IND_flag\n" ;
print "Facture $invoice imapsync$FR_flag $Nom\n" ;
printf( "%.2f [EUR %.2f]\n", $Montant, $MontantEUR ) ;
}
}
sub build_invoice {
my $invoice = shift ;
return if ! $invoice ;
my $action = $action_of_invoice{ $invoice } ;
my $refund = '' ;
$refund = 'REFUND ' if $invoice_refund{ $invoice } ;
my %action = %$action if $action ;
#print Data::Dumper->Dump( [$action] ) ;
my( $Date, $Heure, $Nom, $Type, $Etat, $Devise, $Hors_taxe, $Commission, $Net,
$De_l_adresse_email, $A_l_adresse_email, $N_de_transaction, $Titre_de_l_objet,
$TVA, $Nom_Option_1, $Valeur_Option_1, $N_de_transaction_de_reference,
$Adresse_1, $Adresse_2_district_quartier, $Ville,
$Etat_Province, $Code_postal, $Pays, $line_number, $line_csv, $file_csv )
= @action{ ( 'Date', 'Heure', 'Nom', 'Type', 'Etat', 'Devise', 'Hors taxe', 'Commission', 'Net',
"De l'adresse email", "A l'adresse email", 'N° de transaction', "Titre de l'objet",
'TVA', 'Nom Option 1', 'Valeur Option 1', 'Nº de transaction de référence',
'Adresse 1', 'Adresse 2/district/quartier', 'Ville',
'Etat/Province/Région/Comté/Territoire/Préfecture/République', 'Code postal', 'Pays', 'line_number', 'line_csv', 'file_csv' ) } ;
#print "$Hors_taxe $Devise\n" ;
my $Hors_taxe_num = $Hors_taxe ;
$Hors_taxe_num =~ s{,}{.} ;
if ($Hors_taxe_num > 100) {
print "invoice $invoice $Hors_taxe_num > 100\n" ;
#return() ;
}
my ( $email_message_header, $email_message_body )
= build_email_message( $Date, $Nom, $De_l_adresse_email, $invoice ) ;
if ( $write_invoices ) {
write_email_message( $dir_invoices, $invoice,
$email_message_header, $email_message_body,
$De_l_adresse_email) ;
write_csv_info( $dir_invoices, $invoice, $file_csv, $line_number, $line_csv ) ;
}
#print "==== $invoice $refund=================================================" ;
#print $email_message ;
my(
$clientAdrA,
$clientAdrB,
$clientAdrC,
$clientAdrD,
$clientAdrE,
$clientAdrF,
)
= build_adress(
$Nom,
$Adresse_1,
$Adresse_2_district_quartier,
$Ville,
$Code_postal,
$Etat_Province,
$Pays,
) ;
foreach my $str (
$De_l_adresse_email,
$Nom,
$clientAdrA,
$clientAdrB,
$clientAdrC,
$clientAdrD,
$clientAdrE,
$clientAdrF,
) {
$str =~ s{#}{\\#}g ;
$str =~ s{_}{\\_}g ;
$str =~ s{&}{\\&}g ;
}
my ( $clientTypeEN, $clientTypeFR ) = client_type( $Nom_Option_1, $Valeur_Option_1 ) ;
my (
$priceHT,
$tvaFR,
$tvaEN,
$priceTVA,
$priceTTC,
$messageTVAFR,
$messageTVAEN,
$priceTTCusd
)
= tva_stuff( $clientTypeEN, $Pays, $Hors_taxe, $Devise ) ;
my ( $urlSrc, $urlExe ) = download_urls( $Date ) ;
my $tex_variables = qq{
%% Begin input from $0
\\providecommand{\\invoiceNumber}{$invoice}
\\providecommand{\\clientName}{$Nom}
\\providecommand{\\clientEmail}{$De_l_adresse_email}
\\providecommand{\\clientTypeEN}{$clientTypeEN}
\\providecommand{\\clientTypeFR}{$clientTypeFR}
\\providecommand{\\clientAdrA}{$clientAdrA}
\\providecommand{\\clientAdrB}{$clientAdrB}
\\providecommand{\\clientAdrC}{$clientAdrC}
\\providecommand{\\clientAdrD}{$clientAdrD}
\\providecommand{\\clientAdrE}{$clientAdrE}
\\providecommand{\\clientAdrF}{$clientAdrF}
\\providecommand{\\invoiceDate}{$Date}
\\providecommand{\\invoiceHour}{$Heure}
\\providecommand{\\priceHT}{$priceHT}
\\providecommand{\\tvaFR}{$tvaFR}
\\providecommand{\\tvaEN}{$tvaEN}
\\providecommand{\\priceTVA}{$priceTVA}
\\providecommand{\\priceTTC}{$priceTTC}
\\providecommand{\\priceTTCusd}{$priceTTCusd}
\\providecommand{\\messageTVAFR}{$messageTVAFR}
\\providecommand{\\messageTVAEN}{$messageTVAEN}
\\providecommand{\\urlSrc}{\\url{$urlSrc}}
\\providecommand{\\urlExe}{\\url{$urlExe}}
%% End input from $0
} ;
#print $tex_variables ;
write_tex_variables_file( $dir_invoices,
$invoice, $Date, $tex_variables ) if $write_invoices ;
}
sub build_email_message {
my ( $date, $name, $email, $invoice ) = @_ ;
my $message_header = qq{X-imapsync: invoice $invoice
From: Gilles LAMIRAL <gilles.lamiral\@laposte.net>
Bcc: gilles\@lamiral.info
Subject: [imapsync invoice] $invoice ($date)
Disposition-Notification-To: Gilles LAMIRAL <gilles.lamiral\@laposte.net>
} ;
my $message_body = qq{
Hello $name,
First I'm sorry for the delay to prepare and send you this message.
Attached is the invoice of imapsync software you bought ($date).
The invoice file is named facture_imapsync-${invoice}.pdf
This invoice is in PDF format, ready to be print.
If you need this invoice on paper, just ask me then
I will send it to you by postal mail.
In order to respect the law, this numeric invoice PDF
file is signed with my private gpg key.
The resulting gpg signature is in the file named
facture_imapsync-${invoice}.pdf.asc
also attached in this email message.
You can verify I (Gilles LAMIRAL) really generated
this invoice with the following command line
gpg --verify facture_imapsync-${invoice}.pdf.asc facture_imapsync-${invoice}.pdf
or any other gpg graphical tool.
I thank you again for buying and using imapsync.
Any feedback is welcome.
--
Au revoir, 09 51 84 42 42
Gilles Lamiral. France, Baulon (35580) 06 20 79 76 06
} ;
my $message_body_blabla = qq{
Here is the fingerprint of my public key
pub 1024D/FDA2B3DC 2002-05-08
Key fingerprint = 7906 F53D 0D62 0C67 304A 4CF0 6928 869B FDA2 B3DC
uid Gilles LAMIRAL <gilles.lamiral\@laposte.net>
sub 1024g/A2C4CB42 2002-05-08
Of course the verification doesn't prove anything until
all the following conditions are met:
- you met me,
- I agree that the fingerprint above is really mine
- I prove I'm Gilles LAMIRAL with an official paper.
Normally we won't have to verify anything unless
I disagree with this invoice and the payment
you made for imapsync.
} ;
return( $message_header, $message_body ) ;
}
sub write_csv_info {
my( $dir_invoices, $invoice, $file_csv, $line_number, $line_csv ) = @_ ;
open( CSVINFO, "> $dir_invoices/$invoice/csv_info.txt") or die ;
print CSVINFO join( "\n", $file_csv, $line_number, $line_csv ) ;
close( CSVINFO ) ;
}
sub write_email_message {
my ( $dir_invoices, $invoice, $message_header, $message_body, $email_address ) = @_ ;
my $message_body_utf8 = to_utf8({ -string => $message_body, -charset => 'ISO-8859-1' });
mkdir( "$dir_invoices/$invoice" ) or die if ! -d "$dir_invoices/$invoice" ;
open( HEADER, "> $dir_invoices/$invoice/facture_message_header.txt") or die ;
print HEADER $message_header ;
close( HEADER ) ;
open( BODY, "> $dir_invoices/$invoice/facture_message_body.txt") or die ;
print BODY $message_body_utf8 ;
close( BODY ) ;
open( ADDRESS, "> $dir_invoices/$invoice/email_address.txt") or die ;
print ADDRESS "$email_address\n" ;
close( ADDRESS ) ;
}
sub write_tex_variables_file {
my ( $dir_invoices, $invoice, $date_jjSmmSaaaa, $tex_variables ) = @_ ;
my $tex_variables_utf8 = to_utf8({ -string => $tex_variables, -charset => 'ISO-8859-1' });
mkdir( "$dir_invoices/$invoice" ) or die if ! -d "$dir_invoices/$invoice" ;
open( FILE, "> $dir_invoices/$invoice/imapsync_var.tex") or die ;
print FILE $tex_variables_utf8 ;
close( FILE ) ;
}
sub download_urls {
my $date_jjSmmSaaaa = shift ;
my $date_aaaa_mm_jj = date_aaaa_mm_jj( $date_jjSmmSaaaa ) ;
# print "$date_aaaa_mm_jj $date_jjSmmSaaaa\n" ;
my ( $urlSrc, $urlExe ) ;
if ('2011_03_24' le $date_aaaa_mm_jj) {
$urlSrc = 'http://www.linux-france.org/prj/imapsync/paypal_return.shtml' ;
$urlExe = '' ;
return( $urlSrc, $urlExe ) ;
}
if ('2011_02_21' le $date_aaaa_mm_jj) {
$urlSrc = 'http://www.linux-france.org/depot/2011_02_21/OUMbo7/' ;
$urlExe = 'http://www.linux-france.org/depot/2011_02_21/rHSVNs/' ;
return( $urlSrc, $urlExe ) ;
}
if ('2011_01_18' le $date_aaaa_mm_jj) {
$urlSrc = 'http://www.linux-france.org/depot/2011_01_18/zPRRNt/' ;
$urlExe = 'http://www.linux-france.org/depot/2011_01_18/FO1QzG/' ;
return( $urlSrc, $urlExe ) ;
}
if ('2011_01_18' le $date_aaaa_mm_jj) {
$urlSrc = 'http://www.linux-france.org/depot/2010_11_28/SiNdlZ/' ;
$urlExe = 'http://www.linux-france.org/depot/2010_11_28/R3ZAyr/' ;
return( $urlSrc, $urlExe ) ;
}
$urlSrc = 'http://www.linux-france.org/depot/2010_11_08/X2PWMe/' ;
$urlExe = 'http://www.linux-france.org/depot/2010_11_08/ZZ7zSc/' ;
return( $urlSrc, $urlExe ) ;
}
sub date_aaaa_mm_jj {
my $date_jjSmmSaaaa = shift ;
if ( $date_jjSmmSaaaa =~ m{(\d\d)/(\d\d)/(\d\d\d\d)} ) {
my( $jj, $mm, $aaaa ) = ( $1, $2, $3 ) ;
return( join( '_', $aaaa, $mm, $jj ) ) ;
}else{
return( '9999_12_31' ) ;
}
}
sub tva_stuff {
my( $clientTypeEN, $Pays, $Hors_taxe, $Devise ) = @_ ;
my $priceTTCusd = '' ;
$Hors_taxe =~ s{,}{.} ;
if ( $Devise eq 'USD' ) {
$priceTTCusd = "(USD $Hors_taxe)" ;
$Hors_taxe = ( $Hors_taxe/$usdeur ) ;
}
my (
$priceHT,
$tvaFR,
$tvaEN,
$priceTVA,
$priceTTC,
$messageTVAFR,
$messageTVAEN,
) ;
if ( ( 'individual' eq $clientTypeEN)
or
( 'France' eq $Pays )
) {
$priceHT = sprintf('%2.2f', $Hors_taxe/1.196) ;
$tvaFR = '19,60\%';
$tvaEN = '';
$priceTVA = sprintf('%2.2f', $Hors_taxe/1.196*0.196) ;
$priceTTC = sprintf('%2.2f', $Hors_taxe) ;
$messageTVAFR = '';
$messageTVAEN = '';
}else{
$priceHT = sprintf('%2.2f', $Hors_taxe) ;
$tvaFR = 'néant';
$tvaEN = '(none)';
$priceTVA = 0 ;
$priceTTC = $priceHT;
$messageTVAFR = 'Exonération de TVA, article 259 B-1 du Code Général des Impôts';
$messageTVAEN = '(VAT tax-exempt, article 259 B-1 French General Tax Code)';
}
foreach my $price ( $priceHT, $priceTVA, $priceTTC, $priceTTCusd ) {
#print "[$price]\n" ;
$price =~ s{\.}{, } ;
}
return(
$priceHT,
$tvaFR,
$tvaEN,
$priceTVA,
$priceTTC,
$messageTVAFR,
$messageTVAEN,
$priceTTCusd
) ;
}
sub client_type {
my ( $Nom_Option_1, $Valeur_Option_1 ) = @_ ;
my ( $clientTypeEN, $clientTypeFR ) = ( 'professional', 'professionnel' ) ;
if ('imapsync usage' eq $Nom_Option_1 and 'individual' eq $Valeur_Option_1 ) {
$clientTypeEN = 'individual' ;
$clientTypeFR = 'individuel' ;
}elsif ('imapsync usage' eq $Nom_Option_1 and 'professional' eq $Valeur_Option_1 ) {
$clientTypeEN = 'professional' ;
$clientTypeFR = 'professionnel' ;
}
return( $clientTypeEN, $clientTypeFR ) ;
}
sub build_adress {
my(
$Nom,
$Adresse_1,
$Adresse_2_district_quartier,
$Ville,
$Code_postal,
$Etat_Province,
$Pays,
) = @_ ;
my $addr = "
===========================================================
Nom $Nom
Adresse_1 $Adresse_1
Adresse_2_district_quartier $Adresse_2_district_quartier
Ville Code_postal $Ville $Code_postal
Etat_Province $Etat_Province
Pays $Pays
" ;
#print $addr ;
my @address ;
$Nom = '' if ( $Nom =~ m/^\s+$/ ) ;
push( @address, $Nom ) if $Nom ;
push( @address, $Adresse_1 ) if $Adresse_1 ;
push( @address, $Adresse_2_district_quartier ) if $Adresse_2_district_quartier ;
push( @address, "$Ville $Code_postal" ) if ( $Ville or $Code_postal );
push( @address, $Etat_Province ) if $Etat_Province ;
push( @address, $Pays, ) if $Pays ;
my $clientAdrA = shift( @address ) || '' ;
my $clientAdrB = shift( @address ) || '' ;
my $clientAdrC = shift( @address ) || '' ;
my $clientAdrD = shift( @address ) || '' ;
my $clientAdrE = shift( @address ) || '' ;
my $clientAdrF = shift( @address ) || '' ;
$addr = "
[$clientAdrA]
[$clientAdrB]
[$clientAdrC]
[$clientAdrD]
[$clientAdrE]
[$clientAdrF]
";
#print $addr ;
return(
$clientAdrA,
$clientAdrB,
$clientAdrC,
$clientAdrD,
$clientAdrE,
$clientAdrF,
) ;
}

View File

@ -1,826 +0,0 @@
#!/usr/bin/perl
# $Id: paypal_bilan,v 1.27 2011/05/01 12:57:37 gilles Exp gilles $
use strict;
use warnings;
use Getopt::Long;
use Text::CSV_XS ;
use IO::Handle ;
use Data::Dumper ;
use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset);
die unless (utf8_supported_charset('ISO-8859-1'));
my $total_usd_received = 0 ;
my $total_usd_invoice = 0 ;
my $total_HT_EUR_exo = 0 ;
my $total_HT_EUR_ass = 0 ;
my $total_TVA_EUR = 0 ;
my $total_eur_received = 0 ;
my $total_eur_invoice = 0 ;
my $nb_invoice = 0 ;
my $nb_invoice_refund = 0 ;
my $nb_invoice_suspended = 0 ;
my $debug ;
my $debug_csv ;
my $debug_dev ;
my $first_invoice = 1 ;
my $print_details = '' ;
my $bnc = '';
my $usdeur = 1.2981 ;
my $invoices ;
my %invoice_refund ;
my %invoice_suspended ;
my $write_invoices = 0;
my $dir_invoices = '/g/var/paypal_invoices' ;
my $option_ret = GetOptions (
'debug' => \$debug,
'debug_csv' => \$debug_csv,
'debug_dev' => \$debug_dev,
'first_invoice=i' => \$first_invoice,
'print_details|details' => \$print_details,
'bnc' => \$bnc,
'usdeur=f' => \$usdeur,
'invoices=s' => \$invoices,
'write_invoices!' => \$write_invoices,
);
my @files = @ARGV ;
my %action_of_invoice ;
my @invoices = split( /\s+/, $invoices ) if $invoices ;
#print "@invoices\n" ;
foreach my $file ( @files ) {
my @actions = parse_file( $file ) ;
foreach my $action (@actions) {
my %action = %$action ;
#print $action->{ Nom }, "\n" ;
my( $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
$Devise, $Montant, $Numero_davis_de_reception, $Solde,
$Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe )
= @action{ ( 'Date', 'Heure', 'Fuseau horaire', 'Nom', 'Type', 'Etat',
'Devise', 'Montant', "Numéro d'avis de réception", 'Solde',
'Pays', 'Nom Option 1', 'Valeur Option 1', 'Hors taxe') } ;
#print "$Nom\n" ;
my $invoice = 'NONE' ;
$Montant = $action->{ Net } if not defined $Montant;
compute_line($action, $invoice, $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
$Devise, $Montant, $Numero_davis_de_reception, $Solde,
$Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe ) ;
# index by invoice number
$action_of_invoice{ $action->{ 'invoice' } } = $action ;
}
delete $action_of_invoice{ 'NONE' } ;
}
my $last_invoice = $first_invoice + $nb_invoice -1 ;
@invoices = ( $first_invoice .. $last_invoice ) if ( ! @invoices ) ;
my @invoice_sent ;
my %invoice_sent ;
my @invoice_not_sent ;
my %invoice_not_sent ;
foreach my $invoice ( @invoices ) {
my $action = $action_of_invoice{ $invoice } ;
my $email_address = $action->{ "De l'adresse email" } ;
my $invoice_sent = invoice_sent( $dir_invoices, $invoice, $email_address ) ;
#print "$invoice $invoice_sent\n" ;
if ( $invoice_sent ) {
$invoice_sent{ $invoice }++ ;
}else{
$invoice_not_sent{ $invoice }++ ;
build_invoice( $invoice ) ;
}
}
@invoice_sent = sort { $a <=> $b } keys( %invoice_sent ) ;
my $nb_invoice_sent = scalar( @invoice_sent ) ;
@invoice_not_sent = sort { $a <=> $b } keys( %invoice_not_sent ) ;
print "USD banque $total_usd_received\n" ;
print "USD invoice $total_usd_invoice\n" ;
my $total_eur_from_usd ;
$total_eur_from_usd = int( ( $total_usd_invoice / $usdeur ) + 0.5 ) ; # au 30 nov 2010 http://fr.finance.yahoo.com/devises/convertisseur/#from=EUR;to=USD;amt=1
print "EUR from USD $total_eur_from_usd\n" ;
#$total_eur = int( ( $total_eur_invoice / 1.3 ) + 0.5 ) ;
#print "EUR $total_eur_from_usd\n" ;
print "EUR banque $total_eur_received\n" ;
print "EUR invoice $total_eur_invoice\n" ;
my $total_eur = $total_eur_from_usd + $total_eur_invoice ;
$total_HT_EUR_exo = sprintf('%2.f', $total_HT_EUR_exo) ;
$total_HT_EUR_ass = sprintf('%2.f', $total_HT_EUR_ass) ;
$total_TVA_EUR = sprintf('%2.f', $total_TVA_EUR) ;
$total_eur = sprintf('%2.f', $total_eur) ;
print "EUR total $total_eur\n" ;
print "EUR total HT exo $total_HT_EUR_exo\n" ;
print "EUR total HT assuj $total_HT_EUR_ass\n" ;
print "EUR total TVA $total_TVA_EUR\n" ;
print "Nb invoice $nb_invoice ( from $first_invoice to $last_invoice )\n" ;
print "Nb invoice refund $nb_invoice_refund\n" ;
print "Nb invoice suspended $nb_invoice_suspended\n" ;
print "Nb invoice sent $nb_invoice_sent\n" ;
print "Have to send invoices @invoice_not_sent\n" if ( @invoice_not_sent ) ;
print "$total_eur != $total_HT_EUR_exo + $total_HT_EUR_ass + $total_TVA_EUR\n"
if ( $total_eur != $total_HT_EUR_exo + $total_HT_EUR_ass + $total_TVA_EUR ) ;
sub parse_one_line_io {
my $csv = shift ;
my $io = shift ;
my $line = $csv->getline($io) ;
return if ( $csv->eof( ) ) ;
if ( not defined( $line ) ) {
my($cde, $str, $pos) = $csv->error_diag () ;
print "[$cde] [$str] [$pos]\n" ;
}
return( $line ) ;
}
sub hash_and_count_dupplicate {
my @columns = @_ ;
my %columns ;
#@columns_def{ @columns_def } = ( ) ;
foreach my $col ( @columns ) {
$columns{ $col } += 1 ;
}
$debug_csv and print "Nb columns: ", scalar( keys %columns ), " ", scalar( @columns ), "\n" ;
# debug how many time a title is defined
foreach my $col (1 .. scalar( @columns )) {
$debug_csv and print "$col | ",
deci_to_AA( $col ) , " | ",
$columns{ $columns[ $col - 1 ] }, " | ",
$columns[ $col - 1 ], "\n" ;
}
# exit in case two columns have the same name
die "Erreur : doublons dans les titres\n" if ( scalar( keys %columns ) != scalar( @columns ) ) ;
return( %columns ) ;
}
sub deci_to_AA {
my $deci = shift ;
my $AA = '';
while ( $deci > 0 ) {
my $quot = int( ( $deci - 1 ) / 26 ) ;
my $rest = $deci - 1 - ( 26 * $quot ) ;
my $char = chr ( ord('A') + $rest ) ;
$AA = $char . $AA ;
$deci = $quot ;
}
#print "col=$AA\n" ;
return( $AA ) ;
}
sub remove_first_blank {
my $string = shift ;
$string =~ s/^ +// ;
return( $string ) ;
}
sub parse_file {
my $file = shift ;
open my $io, "<", $file or die "$file: $!" ;
my $csv = Text::CSV_XS->new( {
sep_char => ',',
binary => 1,
keep_meta_info => 1,
eol => $/,
} ) ;
my $line_1 = parse_one_line_io( $csv, $io ) ;
die if ( not defined $line_1 ) ; # first line must have no problem
my @columns_def_orig = @$line_1 ;
my @columns_def = map { remove_first_blank( $_ ) } @columns_def_orig ;
$debug_csv and print "columns_def = ", map( { "[$_]" } @columns_def ), "\n";
my %columns_def = hash_and_count_dupplicate( @columns_def ) ;
my $nb_columns_def = scalar @columns_def ;
my $line_counter = 2 ;
my @actions ;
while ( 1 ) {
$debug_csv and print "ligne $line_counter ", $csv->eof( ), "\n" ;
my $line = parse_one_line_io( $csv, $io ) ;
last if ( $csv->eof( ) ) ;
if ( not defined $line ) {
print "Erreur ligne $line_counter : ", $csv->error_diag, "\n\n";
++$line_counter ;
next ;
}
my @columns = @$line ;
if ( $nb_columns_def != scalar @columns ) {
print "Erreur ligne $line_counter : nombre de colonnes = ", scalar @columns, " != $nb_columns_def\n" ;
++$line_counter ;
next ;
}
my %columns ;
@columns{ @columns_def } = @columns ;
$columns{ 'file_csv' } = $file ;
$columns{ 'line_number' } = $line_counter ;
$csv->combine( @columns ) ;
my $line_csv = $csv->string();
$columns{ 'line_csv' } = $line_csv ;
$debug_csv and print map( { "[$_] = [" . $columns{$_} . "]\n" }
@columns_def, 'line_number', 'line_csv', 'file_csv' ),
"\n";
++$line_counter ;
push( @actions, \%columns ) ;
}
close( $io );
return( reverse @actions ) ;
}
sub compute_line {
my( $action, $invoice, $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
$Devise, $Montant, $Numero_davis_de_reception, $Solde,
$Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe_paypal ) = @_ ;
$debug and print( "[$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n",
"[$Pays] [$Nom_Option_1] [$Valeur_Option_1]\n" ) ;
#$debug_dev and print "$Hors_taxe_paypal\n" ;
$Montant =~ s/[^0-9-,.]//g ;
$Montant =~ s/,/./g ;
#$debug and print "MM[$Montant]\n" ;
$Hors_taxe_paypal =~ s/,/./g ;
my $MontantEUR;
my( $montant_HT_EUR_exo, $montant_HT_EUR_ass, $montant_TVA_EUR ) ;
if ( $bnc ) {
$MontantEUR = $Montant ;
$MontantEUR = sprintf( "%.4f", $Montant/$usdeur ) if ($Devise eq 'USD') ;
print( "\n", "=" x 60, "\n" ) ;
print( "[$Date] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [EUR $MontantEUR]\n",
"[$Pays] [$Nom_Option_1] [$Valeur_Option_1]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'USD' eq $Devise
and ( 'Terminé' eq $Etat or 'Compensé' eq $Etat )
) {
$Montant =~tr/,/./;
#print "$Montant\n" ;
my $Montant2_usd;
$Montant2_usd = $Hors_taxe_paypal ;
$total_usd_received += $Montant ;
$total_usd_invoice += $Montant2_usd ;
( $montant_HT_EUR_exo, $montant_HT_EUR_ass, $montant_TVA_EUR ) = tva_line( $Devise, $Montant2_usd, $Pays, $Nom_Option_1, $Valeur_Option_1 ) ;
$total_HT_EUR_exo += $montant_HT_EUR_exo ;
$total_HT_EUR_ass += $montant_HT_EUR_ass ;
$total_TVA_EUR += $montant_TVA_EUR ;
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'EUR' eq $Devise
and ( 'Terminé' eq $Etat or 'Compensé' eq $Etat )
) {
$Montant =~tr/,/./;
#print "$Montant\n" ;
my $Montant2_eur;
$Montant2_eur = $Hors_taxe_paypal ;
$total_eur_received += $Montant ;
$total_eur_invoice += $Montant2_eur ;
( $montant_HT_EUR_exo, $montant_HT_EUR_ass, $montant_TVA_EUR ) = tva_line( $Devise, $Montant2_eur, $Pays, $Nom_Option_1, $Valeur_Option_1 ) ;
$total_HT_EUR_exo += $montant_HT_EUR_exo ;
$total_HT_EUR_ass += $montant_HT_EUR_ass ;
$total_TVA_EUR += $montant_TVA_EUR ;
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'EUR' eq $Devise
and 'Remboursé' eq $Etat
) {
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$nb_invoice_refund++;
$invoice_refund{ $invoice }++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'EUR' eq $Devise
and 'Suspendu' eq $Etat
) {
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$nb_invoice_suspended++;
$invoice_suspended{ $invoice }++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
if (
'Paiement sur site marchand reçu' eq $Type
and 'EUR' eq $Devise
and 'Non compensé' eq $Etat
) {
$invoice = $first_invoice + $nb_invoice ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde]\n" ) ;
}
$action->{ 'invoice' } = $invoice ;
if ( $bnc ) {
my $FR_flag = '' ;
$FR_flag = ' FR' if $Pays eq 'France' ;
my $IND_flag = '' ;
$IND_flag = ' IND' if ('imapsync usage' eq $Nom_Option_1 and 'individual' eq $Valeur_Option_1 ) ;
print "FE $invoice$FR_flag$IND_flag\n" ;
print "Facture $invoice imapsync$FR_flag $Nom\n" ;
printf( "%.2f [EUR %.2f]\n", $Montant, $MontantEUR ) ;
}
}
sub build_invoice {
my $invoice = shift ;
return if ! $invoice ;
my $action = $action_of_invoice{ $invoice } ;
my $refund = '' ;
$refund = 'REFUND ' if $invoice_refund{ $invoice } ;
my %action = %$action if $action ;
#print Data::Dumper->Dump( [$action] ) ;
my( $Date, $Heure, $Nom, $Type, $Etat, $Devise, $Hors_taxe, $Commission, $Net,
$De_l_adresse_email, $A_l_adresse_email, $N_de_transaction, $Titre_de_l_objet,
$TVA, $Nom_Option_1, $Valeur_Option_1, $N_de_transaction_de_reference,
$Adresse_1, $Adresse_2_district_quartier, $Ville,
$Etat_Province, $Code_postal, $Pays, $line_number, $line_csv, $file_csv )
= @action{ ( 'Date', 'Heure', 'Nom', 'Type', 'Etat', 'Devise', 'Hors taxe', 'Commission', 'Net',
"De l'adresse email", "A l'adresse email", 'N° de transaction', "Titre de l'objet",
'TVA', 'Nom Option 1', 'Valeur Option 1', 'Nº de transaction de référence',
'Adresse 1', 'Adresse 2/district/quartier', 'Ville',
'Etat/Province/Région/Comté/Territoire/Préfecture/République', 'Code postal', 'Pays', 'line_number', 'line_csv', 'file_csv' ) } ;
#print "$Hors_taxe $Devise\n" ;
my $Hors_taxe_num = $Hors_taxe ;
$Hors_taxe_num =~ s{,}{.} ;
if ($Hors_taxe_num > 100) {
print "invoice $invoice $Hors_taxe_num > 100\n" ;
#return() ;
}
my ( $email_message_header, $email_message_body )
= build_email_message( $Date, $Nom, $De_l_adresse_email, $invoice ) ;
if ( $write_invoices and ! invoice_sent( $dir_invoices, $invoice, $De_l_adresse_email ) ) {
write_email_message( $dir_invoices, $invoice,
$email_message_header, $email_message_body,
$De_l_adresse_email) ;
write_csv_info( $dir_invoices, $invoice, $file_csv, $line_number, $line_csv ) ;
}
#print "==== $invoice $refund=================================================" ;
#print $email_message ;
my(
$clientAdrA,
$clientAdrB,
$clientAdrC,
$clientAdrD,
$clientAdrE,
$clientAdrF,
)
= build_adress(
$Nom,
$Adresse_1,
$Adresse_2_district_quartier,
$Ville,
$Code_postal,
$Etat_Province,
$Pays,
) ;
foreach my $str (
$De_l_adresse_email,
$Nom,
$clientAdrA,
$clientAdrB,
$clientAdrC,
$clientAdrD,
$clientAdrE,
$clientAdrF,
) {
$str =~ s{#}{\\#}g ;
$str =~ s{_}{\\_}g ;
$str =~ s{&}{\\&}g ;
}
my ( $clientTypeEN, $clientTypeFR ) = client_type( $Nom_Option_1, $Valeur_Option_1 ) ;
my (
$priceHT,
$tvaFR,
$tvaEN,
$priceTVA,
$priceTTC,
$messageTVAFR,
$messageTVAEN,
$priceTTCusd
)
= tva_stuff( $clientTypeEN, $Pays, $Hors_taxe, $Devise ) ;
my ( $urlSrc, $urlExe ) = download_urls( $Date ) ;
my $tex_variables = qq{
%% Begin input from $0
\\providecommand{\\invoiceNumber}{$invoice}
\\providecommand{\\clientName}{$Nom}
\\providecommand{\\clientEmail}{$De_l_adresse_email}
\\providecommand{\\clientTypeEN}{$clientTypeEN}
\\providecommand{\\clientTypeFR}{$clientTypeFR}
\\providecommand{\\clientAdrA}{$clientAdrA}
\\providecommand{\\clientAdrB}{$clientAdrB}
\\providecommand{\\clientAdrC}{$clientAdrC}
\\providecommand{\\clientAdrD}{$clientAdrD}
\\providecommand{\\clientAdrE}{$clientAdrE}
\\providecommand{\\clientAdrF}{$clientAdrF}
\\providecommand{\\invoiceDate}{$Date}
\\providecommand{\\invoiceHour}{$Heure}
\\providecommand{\\priceHT}{$priceHT}
\\providecommand{\\tvaFR}{$tvaFR}
\\providecommand{\\tvaEN}{$tvaEN}
\\providecommand{\\priceTVA}{$priceTVA}
\\providecommand{\\priceTTC}{$priceTTC}
\\providecommand{\\priceTTCusd}{$priceTTCusd}
\\providecommand{\\messageTVAFR}{$messageTVAFR}
\\providecommand{\\messageTVAEN}{$messageTVAEN}
\\providecommand{\\urlSrc}{\\url{$urlSrc}}
\\providecommand{\\urlExe}{\\url{$urlExe}}
%% End input from $0
} ;
#print $tex_variables ;
#print "$invoice ", invoice_sent( $dir_invoices, $invoice, $De_l_adresse_email ), "\n" ;
if ( $write_invoices and ! invoice_sent( $dir_invoices, $invoice, $De_l_adresse_email ) ) {
write_tex_variables_file( $dir_invoices, $invoice, $Date, $tex_variables ) ;
}
}
sub build_email_message {
my ( $date, $name, $email, $invoice ) = @_ ;
my $message_header = qq{X-imapsync: invoice $invoice
From: Gilles LAMIRAL <gilles.lamiral\@laposte.net>
Bcc: gilles\@lamiral.info
Subject: [imapsync invoice] $invoice ($date)
Disposition-Notification-To: Gilles LAMIRAL <gilles.lamiral\@laposte.net>
} ;
my $message_body = qq{
Hello $name,
First of all, I'm sorry for the delay in getting back to you.
You'll find in the attachment the invoice of imapsync software you bought ($date).
The invoice file is named facture_imapsync-${invoice}.pdf
This invoice is in PDF format, ready to be print.
Should you need a hardcopy of this invoice,
I'll send it to you upon request by regular mail.
As the law requires, this numeric invoice PDF file
is signed with my private gpg key.
The resulting gpg signature is in the file named
facture_imapsync-${invoice}.pdf.asc
you will also find in the attachment.
You can check I (Gilles LAMIRAL) really did generate
this invoice with the following command line:
gpg --verify facture_imapsync-${invoice}.pdf.asc facture_imapsync-${invoice}.pdf
or any other gpg graphical tool.
Once more, thank you for buying and using imapsync.
Any feedback is welcome.
--
Best Regards, 09 51 84 42 42
Gilles Lamiral. France, Baulon (35580) 06 20 79 76 06
} ;
my $message_body_blabla = qq{
Here is the fingerprint of my public key
pub 1024D/FDA2B3DC 2002-05-08
Key fingerprint = 7906 F53D 0D62 0C67 304A 4CF0 6928 869B FDA2 B3DC
uid Gilles LAMIRAL <gilles.lamiral\@laposte.net>
sub 1024g/A2C4CB42 2002-05-08
Of course the verification doesn't prove anything until
all the following conditions are met:
- you met me,
- I agree that the fingerprint above is really mine
- I prove I'm Gilles LAMIRAL with an official paper.
Normally we won't have to verify anything unless
I disagree with this invoice and the payment
you made for imapsync.
} ;
return( $message_header, $message_body ) ;
}
sub write_csv_info {
my( $dir_invoices, $invoice, $file_csv, $line_number, $line_csv ) = @_ ;
open( CSVINFO, "> $dir_invoices/$invoice/csv_info.txt") or die ;
print CSVINFO join( "\n", $file_csv, $line_number, $line_csv ) ;
close( CSVINFO ) ;
}
sub invoice_sent {
my ( $dir_invoices, $invoice, $email_address ) = @_ ;
return( 1 ) if ( -f "$dir_invoices/$invoice/SENT_TO_$email_address" ) ;
return( 0 ) ;
}
sub write_email_message {
my ( $dir_invoices, $invoice, $message_header, $message_body, $email_address ) = @_ ;
my $message_body_utf8 = to_utf8({ -string => $message_body, -charset => 'ISO-8859-1' });
mkdir( "$dir_invoices/$invoice" ) or die if ! -d "$dir_invoices/$invoice" ;
open( HEADER, "> $dir_invoices/$invoice/facture_message_header.txt") or die ;
print HEADER $message_header ;
close( HEADER ) ;
open( BODY, "> $dir_invoices/$invoice/facture_message_body.txt") or die ;
print BODY $message_body_utf8 ;
close( BODY ) ;
open( ADDRESS, "> $dir_invoices/$invoice/email_address.txt") or die ;
print ADDRESS "$email_address\n" ;
close( ADDRESS ) ;
}
sub write_tex_variables_file {
my ( $dir_invoices, $invoice, $date_jjSmmSaaaa, $tex_variables ) = @_ ;
my $tex_variables_utf8 = to_utf8({ -string => $tex_variables, -charset => 'ISO-8859-1' });
mkdir( "$dir_invoices/$invoice" ) or die if ! -d "$dir_invoices/$invoice" ;
open( FILE, "> $dir_invoices/$invoice/imapsync_var.tex") or die ;
print FILE $tex_variables_utf8 ;
close( FILE ) ;
}
sub download_urls {
my $date_jjSmmSaaaa = shift ;
my $date_aaaa_mm_jj = date_aaaa_mm_jj( $date_jjSmmSaaaa ) ;
# print "$date_aaaa_mm_jj $date_jjSmmSaaaa\n" ;
my ( $urlSrc, $urlExe ) ;
if ('2011_03_24' le $date_aaaa_mm_jj) {
$urlSrc = 'http://www.linux-france.org/prj/imapsync/paypal_return.shtml' ;
$urlExe = '' ;
return( $urlSrc, $urlExe ) ;
}
if ('2011_02_21' le $date_aaaa_mm_jj) {
$urlSrc = 'http://www.linux-france.org/depot/2011_02_21/OUMbo7/' ;
$urlExe = 'http://www.linux-france.org/depot/2011_02_21/rHSVNs/' ;
return( $urlSrc, $urlExe ) ;
}
if ('2011_01_18' le $date_aaaa_mm_jj) {
$urlSrc = 'http://www.linux-france.org/depot/2011_01_18/zPRRNt/' ;
$urlExe = 'http://www.linux-france.org/depot/2011_01_18/FO1QzG/' ;
return( $urlSrc, $urlExe ) ;
}
if ('2011_01_18' le $date_aaaa_mm_jj) {
$urlSrc = 'http://www.linux-france.org/depot/2010_11_28/SiNdlZ/' ;
$urlExe = 'http://www.linux-france.org/depot/2010_11_28/R3ZAyr/' ;
return( $urlSrc, $urlExe ) ;
}
$urlSrc = 'http://www.linux-france.org/depot/2010_11_08/X2PWMe/' ;
$urlExe = 'http://www.linux-france.org/depot/2010_11_08/ZZ7zSc/' ;
return( $urlSrc, $urlExe ) ;
}
sub date_aaaa_mm_jj {
my $date_jjSmmSaaaa = shift ;
if ( $date_jjSmmSaaaa =~ m{(\d\d)/(\d\d)/(\d\d\d\d)} ) {
my( $jj, $mm, $aaaa ) = ( $1, $2, $3 ) ;
return( join( '_', $aaaa, $mm, $jj ) ) ;
}else{
return( '9999_12_31' ) ;
}
}
sub tva_line {
my( $Devise, $Montant2, $Pays, $Nom_Option_1, $Valeur_Option_1 ) = @_ ;
my( $montant_HT_EUR_exo, $montant_HT_EUR_ass, $montant_TVA_EUR ) ;
$Montant2 = $Montant2/$usdeur if 'USD' eq $Devise ;
if (
( 'imapsync usage' eq $Nom_Option_1 and 'individual' eq $Valeur_Option_1 )
or
( 'France' eq $Pays )
) {
$montant_HT_EUR_exo = 0 ;
$montant_HT_EUR_ass = $Montant2 / 1.196 ;
$montant_TVA_EUR = $Montant2 / 1.196 * 0.196 ;
$debug_dev and print "$Montant2 $Pays $Valeur_Option_1\n" ;
}else{
$montant_HT_EUR_exo = $Montant2 ;
$montant_HT_EUR_ass = 0 ;
$montant_TVA_EUR = 0 ;
}
return( $montant_HT_EUR_exo, $montant_HT_EUR_ass, $montant_TVA_EUR ) ;
}
sub tva_stuff {
my( $clientTypeEN, $Pays, $Hors_taxe, $Devise ) = @_ ;
my $priceTTCusd = '' ;
$Hors_taxe =~ s{,}{.} ;
if ( $Devise eq 'USD' ) {
$priceTTCusd = "(usd $Hors_taxe)" ;
$Hors_taxe = ( $Hors_taxe/$usdeur ) ;
}
my (
$priceHT,
$tvaFR,
$tvaEN,
$priceTVA,
$priceTTC,
$messageTVAFR,
$messageTVAEN,
) ;
if ( ( 'individual' eq $clientTypeEN)
or
( 'France' eq $Pays )
) {
$priceHT = sprintf('%2.2f', $Hors_taxe/1.196) ;
$tvaFR = '19,60\%';
$tvaEN = '';
$priceTVA = sprintf('%2.2f', $Hors_taxe/1.196*0.196) ;
$priceTTC = sprintf('%2.2f', $Hors_taxe) ;
$messageTVAFR = '';
$messageTVAEN = '';
}else{
$priceHT = sprintf('%2.2f', $Hors_taxe) ;
$tvaFR = 'néant';
$tvaEN = '(none)';
$priceTVA = 0 ;
$priceTTC = $priceHT;
$messageTVAFR = 'Exonération de TVA, article 259 B-1 du Code Général des Impôts';
$messageTVAEN = '(VAT tax-exempt, article 259 B-1 French General Tax Code)';
}
foreach my $price ( $priceHT, $priceTVA, $priceTTC, $priceTTCusd ) {
#print "[$price]\n" ;
$price =~ s{\.}{, } ;
}
return(
$priceHT,
$tvaFR,
$tvaEN,
$priceTVA,
$priceTTC,
$messageTVAFR,
$messageTVAEN,
$priceTTCusd
) ;
}
sub client_type {
my ( $Nom_Option_1, $Valeur_Option_1 ) = @_ ;
my ( $clientTypeEN, $clientTypeFR ) = ( 'professional', 'professionnel' ) ;
if ('imapsync usage' eq $Nom_Option_1 and 'individual' eq $Valeur_Option_1 ) {
$clientTypeEN = 'individual' ;
$clientTypeFR = 'individuel' ;
}elsif ('imapsync usage' eq $Nom_Option_1 and 'professional' eq $Valeur_Option_1 ) {
$clientTypeEN = 'professional' ;
$clientTypeFR = 'professionnel' ;
}
return( $clientTypeEN, $clientTypeFR ) ;
}
sub build_adress {
my(
$Nom,
$Adresse_1,
$Adresse_2_district_quartier,
$Ville,
$Code_postal,
$Etat_Province,
$Pays,
) = @_ ;
my $addr = "
===========================================================
Nom $Nom
Adresse_1 $Adresse_1
Adresse_2_district_quartier $Adresse_2_district_quartier
Ville Code_postal $Ville $Code_postal
Etat_Province $Etat_Province
Pays $Pays
" ;
#print $addr ;
my @address ;
$Nom = '' if ( $Nom =~ m/^\s+$/ ) ;
push( @address, $Nom ) if $Nom ;
push( @address, $Adresse_1 ) if $Adresse_1 ;
push( @address, $Adresse_2_district_quartier ) if $Adresse_2_district_quartier ;
push( @address, "$Ville $Code_postal" ) if ( $Ville or $Code_postal );
push( @address, $Etat_Province ) if $Etat_Province ;
push( @address, $Pays, ) if $Pays ;
my $clientAdrA = shift( @address ) || '' ;
my $clientAdrB = shift( @address ) || '' ;
my $clientAdrC = shift( @address ) || '' ;
my $clientAdrD = shift( @address ) || '' ;
my $clientAdrE = shift( @address ) || '' ;
my $clientAdrF = shift( @address ) || '' ;
$addr = "
[$clientAdrA]
[$clientAdrB]
[$clientAdrC]
[$clientAdrD]
[$clientAdrE]
[$clientAdrF]
";
#print $addr ;
return(
$clientAdrA,
$clientAdrB,
$clientAdrC,
$clientAdrD,
$clientAdrE,
$clientAdrF,
) ;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
#!/bin/sh
# $Id: paypal_build_invoices,v 1.23 2012/01/08 00:33:04 gilles Exp gilles $
# $Id: paypal_build_invoices,v 1.24 2012/01/28 02:19:43 gilles Exp gilles $
# usage: sh paypal_build_invoices /g/var/paypal_invoices/????
@ -21,7 +21,8 @@ set -x
#/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 999 /g/paypal/paypal_2011_09_complet.csv
#/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 1094 /g/paypal/paypal_2011_10_complet.csv
#/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 1185 /g/paypal/paypal_2011_11_complet.csv
/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 1263 /g/paypal/paypal_2011_12_complet.csv
#/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 1263 /g/paypal/paypal_2011_12_complet.csv
/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 1335 /g/paypal/paypal_2012_01_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 147 /g/paypal/paypal_2010_11_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 214 /g/paypal/paypal_2010_12_complet.csv
@ -36,15 +37,17 @@ set -x
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 1094 /g/paypal/paypal_2011_10_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 1185 /g/paypal/paypal_2011_11_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 1263 /g/paypal/paypal_2011_12_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 1335 /g/paypal/paypal_2012_01_complet.csv
set +x
# La totale
: || /g/public_html/imapsync/W/paypal_reply/paypal_bilan --bnc --debug \
--first_in 147 --avoid_numbers '292 293 643 644 731 732 1093' \
--first_in 147 --avoid_numbers '292 293 643 644 731 732 1093 1330 1331 1332 1333 1334' \
/g/paypal/paypal_201?_??_complet.csv
: || /g/public_html/imapsync/W/paypal_reply/paypal_bilan \
--first_in 147 --avoid_numbers '292 293 643 644 731 732 1093' \
--first_in 147 --avoid_numbers '292 293 643 644 731 732 1093 1330 1331 1332 1333 1334' \
/g/paypal/paypal_201?_??_complet.csv
echo 'sh paypal_build_invoices /g/var/paypal_invoices/1???'

View File

@ -1,6 +1,6 @@
#!/usr/bin/perl -w
# $Id: paypal_imapget,v 1.7 2011/03/23 17:05:24 gilles Exp gilles $
# $Id: paypal_imapget,v 1.8 2012/01/25 18:25:50 gilles Exp gilles $
use Getopt::Long;
use Mail::IMAPClient;
@ -56,7 +56,7 @@ $imap->select($folder) or die "Error select folder [$folder] host [$host] user [
#my @uids = $imap->search('TEXT', 'PP341');
print "@search\n" ;
@search = ('TEXT', 'PP341') if not @search ;
my @uids = $imap->search('HEADER', 'Sender','sendmail@paypal.com', @search );
my @uids = $imap->search('HEADER', 'Return-Path','<payment@paypal.com>', @search );
print "Search: [@uids]\n";
foreach $msg (@uids) {

View File

@ -8,7 +8,7 @@ set -e
# Add path to commands at home
PATH=$PATH:/g/public_html/imapsync/W/paypal_reply
PERL5LIB=/g/public_html/imapsync/Mail-IMAPClient-3.28/lib
PERL5LIB=/g/public_html/imapsync/Mail-IMAPClient-3.30/lib
export PERL5LIB
test -f /g/public_html/imapsync/W/paypal_reply/paypal_functions \

View File

@ -20,7 +20,7 @@ Synchronise mailboxes between two imap servers.
Good at IMAP migration. More than 44 different IMAP server softwares
supported with success.
$Revision: 1.480 $
$Revision: 1.484 $
=head1 SYNOPSIS
@ -519,7 +519,7 @@ Entries for imapsync:
Feedback (good or bad) will often be welcome.
$Id: imapsync,v 1.480 2012/01/08 05:11:03 gilles Exp gilles $
$Id: imapsync,v 1.484 2012/02/07 00:19:33 gilles Exp gilles $
=cut
@ -580,7 +580,8 @@ my(
$usedatemanip,
$syncacls,
$fastio1, $fastio2,
$maxsize, $minsize, $maxage, $minage,
$maxsize, $minsize, $maxage, $minage,
$exitwhenover,
$search,
$skipheader, @useheader,
$skipsize, $allowsizemismatch, $foldersizes, $buffersize,
@ -635,7 +636,7 @@ my(
# global variables initialisation
$rcs = '$Id: imapsync,v 1.480 2012/01/08 05:11:03 gilles Exp gilles $ ';
$rcs = '$Id: imapsync,v 1.484 2012/02/07 00:19:33 gilles Exp gilles $ ';
$total_bytes_transferred = 0;
$total_bytes_skipped = 0;
@ -1083,8 +1084,9 @@ FOLDER: foreach my $h1_fold (@h1_folders_wanted) {
#relogin1( ) if ( $relogin1 ) ;
printf( "%-35s -> %-35s\n", "[$h1_fold]", "[$h2_fold]" ) ;
# host1 can be fetched read only, select is not needed.
examine_folder( $imap1, $h1_fold, 'Host1' ) or next FOLDER ;
# host1 can not be fetched read only, select is needed because of expunge.
select_folder( $imap1, $h1_fold, 'Host1' ) or next FOLDER ;
#examine_folder( $imap1, $h1_fold, 'Host1' ) or next FOLDER ;
if ( ! exists( $h2_folders_all{ $h2_fold } ) ) {
@ -1338,6 +1340,7 @@ FOLDER: foreach my $h1_fold (@h1_folders_wanted) {
unless (exists($h2_hash{$m_id})) {
# copy
copy_message( $h1_msg, $h1_fold, $h2_fold, $h1_fir_ref, $permanentflags2, $cache_dir ) ;
last FOLDER if total_bytes_max_reached( ) ;
next MESS;
}
else{
@ -1381,10 +1384,10 @@ FOLDER: foreach my $h1_fold (@h1_folders_wanted) {
#print "Messages by uid: ", map { "$_ " } keys %h1_msgs_copy_by_uid, "\n" ;
MESS_BY_UID: foreach my $h1_msg ( sort { $a <=> $b } keys %h1_msgs_copy_by_uid ) {
# copy_message
#
$debug and print "Copy by uid $h1_fold/$h1_msg\n" ;
copy_message( $h1_msg, $h1_fold, $h2_fold, $h1_fir_ref, $permanentflags2, $cache_dir ) ;
last FOLDER if total_bytes_max_reached( ) ;
}
if ($expunge or $expunge1){
@ -1399,6 +1402,16 @@ FOLDER: foreach my $h1_fold (@h1_folders_wanted) {
$debug and print "Time: ", timenext(), " s\n";
}
sub total_bytes_max_reached {
return( 0 ) if not $exitwhenover ;
if ( $total_bytes_transferred >= $exitwhenover ) {
print "Maximum bytes transfered reached, $total_bytes_transferred >= $exitwhenover, ending sync\n" ;
return( 1 ) ;
}
}
sub size_filtered_flag {
my $h1_size = shift ;
@ -1855,8 +1868,8 @@ sub banner_imapsync {
my @argv_copy = @_;
my $banner_imapsync = join("",
'$RCSfile: imapsync,v $ ',
'$Revision: 1.480 $ ',
'$Date: 2012/01/08 05:11:03 $ ',
'$Revision: 1.484 $ ',
'$Date: 2012/02/07 00:19:33 $ ',
"\n",localhost_info(), "\n",
"Command line used:\n",
"$0 ", command_line_nopassword(@argv_copy), "\n",
@ -2654,6 +2667,19 @@ sub size_filtered {
return( 0 ) ;
}
sub message_exists {
my( $imap, $msg ) = @_ ;
return( 1 ) if not $imap->Uid( ) ;
my $search ;
( $search ) = $imap->search( "UID $msg" ) ;
#print "$search ? $msg\n" ;
return( 1 ) if ( $search eq $msg ) ;
return( 0 ) ;
}
sub copy_message {
# copy
@ -2670,7 +2696,7 @@ sub copy_message {
do { print "SLEEP 5\n" and sleep 5 ; } if ( $debugsleep ) ;
print "- msg $h1_fold/$h1_msg S[$h1_size] F[$h1_flags] I[$h1_idate] has RFC822.SIZE null!\n" if ( ! $h1_size ) ;
return( ) if not message_exists( $imap1, $h1_msg ) ;
$string = $imap1->message_string($h1_msg);
@ -3454,6 +3480,7 @@ sub get_options {
"debugcache!" => \$debugcache,
"useuid!" => \$useuid,
"addheader!" => \$addheader,
"exitwhenover=i" => \$exitwhenover,
);
$debug and print "get options: [$opt_ret]\n";
@ -3643,7 +3670,7 @@ sub check_last_release {
}
sub imapsync_version {
my $rcs = '$Id: imapsync,v 1.480 2012/01/08 05:11:03 gilles Exp gilles $ ';
my $rcs = '$Id: imapsync,v 1.484 2012/02/07 00:19:33 gilles Exp gilles $ ';
$rcs =~ m/,v (\d+\.\d+)/;
my $VERSION = ($1) ? $1: "UNKNOWN";
return($VERSION);
@ -3864,7 +3891,9 @@ Several options are mandatory.
past|+++++++++++++++minage---->now
past|----maxage+++++minage---->now (intersection)
past|++++minage-----maxage++++>now (union)
--search <string> : Select messages returned by this IMAP SEARCH command
--search <string> : Select messages returned by this IMAP SEARCH command.
--exitwhenover <int> : Stop syncing when total bytes transferred reached.
Gmail per day allows 2500000000 down 500000000 upload.
--useheader <string> : Use this header to compare messages on both sides.
Ex: Message-ID or Subject or Date.
--useheader <string> and this one, etc.
@ -3880,9 +3909,11 @@ Several options are mandatory.
--syncacls : synchronises acls (Access Control Lists).
--nosyncacls : does not synchronise acls. This is the default.
--usecache : Use cache to speedup.
--nousecache : Do not use cache.
--nousecache : Do not use cache. Caveat: --useuid --nousecache creates
duplicates on multiple runs.
--useuid : Use uid instead of header as a criterium to sync.
--usecache is then implied unless --nousecache
--usecache is then implied unless --nousecache is
used.
--debug : debug mode.
--debugcontent : debug content of the messages transfered.
--debugflags : debug flags.

8
imapsync_example.bat.txt Executable file
View File

@ -0,0 +1,8 @@
REM imapsync example batch for Windows users
REM lines beginning with REM are just comments
REM Replace imap.foo.org toto secretoto 192.168.42.4 titi secretiti with your own values
.\imapsync.exe --host1 imap.foo.org --user1 toto --password1 "secretoto" --host2 192.168.42.4 --user2 titi --password2 "secretiti"

View File

@ -5,7 +5,7 @@
<title>Imapsync: an IMAP migration tool ( release <!--#exec cmd="cat VERSION"--> )</title>
<meta name="generator" content="Bluefish 1.0.7"/>
<meta name="author" content="Gilles LAMIRAL"/>
<meta name="date" content="2012-01-08T02:59:44+0100"/>
<meta name="date" content="2012-02-07T11:52:59+0100"/>
<meta name="copyright" content="None"/>
<meta name="keywords" content="imap, transfert, migration"/>
<meta name="description" content="imap migration tool"/>
@ -63,11 +63,11 @@ for <b>2 ways synchronizations</b>.
<p>Alternatives to imapsync are listed in the <a href="#similar"><b>Similar softwares</b></a> section.
</p>
<h2><a id="NUMBERS"></a>Some numbers for 2011</h2>
<h2><a id="NUMBERS"></a>Some numbers for past year 2011</h2>
<ul>
<li>Number of <b>imapsync users</b> per month: between <b>2 and 3 thousands </b>users</li>
<li>Number of <b>imapsync transfers</b> per month: between <b>3 and 25 millions mailboxes </b>transfers </li>
<li>Number of <b>imapsync transfers</b> between <b>3 and 25 millions mailboxes </b>transfers per month, 93 millions in 2011</li>
<li>Pourcentage between <b>operating systems</b> users running imapsync:
<ul>
<li><b>Linux: 65 %</b></li>
@ -93,6 +93,25 @@ for <b>2 ways synchronizations</b>.
<p>New features or bugfixes since previous releases:</p>
<ul>
<li><b>1.484</b></li>
<li><b>Bug fix</b>: Back to select() (read-write mode) instead of examine() (read-only mode in 1.468) on host1. <b>Needed with --delete</b></li>
<li><b>Enhancement</b>: Added option --exitwhenover option <b>to avoid locking</b> when transfers exceed maximum limit.
See for example <a href="http://support.google.com/a/bin/answer.py?hl=en&amp;answer=1071518">this Gmail constraint</a>
<ul>
<li>imapsync ... --exitwhenover 2500000000 # 2.5GB if <b>host1 is Gmail</b></li>
<li>imapsync ... --exitwhenover 500000000 # 500MB if <b>host2 is Gmail</b></li>
</ul></li>
<li><b>Better behavior</b>: Check if a message exists before fetching it (could have been deleted recently)</li>
<li><b>Usability</b>: Unified outout in --debug mode. Lines start with Host1 or Host2.</li>
<li><b>Usability</b>: Changed output about messages ignored to better reflect what is going on.</li>
<li><b>Better behavior</b>: --split down to 100 by defaultto follow the recommendation of RFC2683 section 3.2.1.5
Thanks to Phil Pearl for this advice.</li>
</ul>
<ul>
<li><b>1.476</b></li>
@ -106,40 +125,7 @@ for <b>2 ways synchronizations</b>.
<li><b>Experimental</b>: Added --nofilterflags to check any STORE flags by ignoring PERMANENTFLAGS (Exchange tests)</li>
</ul>
<ul>
<li><b>1.468</b></li>
<li><b>Usability</b>: Subscribe to host2 folders only for folders not already subscribed.</li>
<li><b>Safer behavior</b>: Use examine() (read-only mode) on host1 instead of select().</li>
<li><b>Gmail fix</b>: Fix select behavior on host2 to allow (silly) Gmail folders that don't exist but that are listed.</li>
<li><b>Cosmetic</b>: Changed imapsync homepage from http://www.linux-france.org/prj/imapsync/ to http://imapsync.lamiral.info/</li>
<li><b>Bugfix</b>: stay compatible with perl 5.8 (no use of // operator)</li>
</ul>
<ul>
<li><b>1.463</b></li>
<li><b>Update</b>: include and use of <b>Mail-IMAPClient-3.30</b> (imapsync.exe). Thanks to <b>Phil Pearl</b> (Mail-IMAPClient maintainer)
</li>
<li><b>Usability</b>: --subscribe option is on by default. --nosubscribe option can avoid this behavior.</li>
<li><b>BugFix</b>: Added --nocacheaftercopy to avoid bad uids in cache with --useuid or --usecache and strange uid generator like dbmail 2.2.17</li>
<li><b>BugFix</b>: Avoid Perl warning 'Use of uninitialized value $uid1 in exists'. Thanks to Klaus Franken</li>
</ul>
<ul>
<li><b>1.456</b></li>
<li>Added a <b><a href="./file.txt">file.txt</a></b> example to <b>batch massive migration</b> (many mailboxes) on Windows or Unix</li>
<li>Added support to <b>Yahoo</b> as host1 (just add <kbd>--sep1 "/"</kbd> option. Add <kbd>--ssl1</kbd> for encryption)</li>
<li>Empty default value for $h1_flags $h2_flags to avoid useless Perl warnings.</li>
<li><b>MDaemon 12.0.3 failure as host2</b> (successive APPEND are buggy on MDaemon)</li>
</ul>
<ul>
<li><b>1.452</b></li>
<li><b>New feature</b>: Added <b>--search</b> option allowing to <b>select messages</b> with the <b>powerful IMAP SEARCH</b> command.</li>
<li><b>Bugfix</b>: Date reference to select messages with --maxdate --mindate is the beginning of imapsync run now.</li>
<li>Bugfix: Fixed ps call to work with Solaris 10. Thanks to Daniel Rohde.</li>
<li>Success: <b>Kerio 7.2.0P1</b> success story.</li>
<li>Success: <b>MDaemon 12.0.3 success story as host1</b>.</li>
</ul>
<!--
@ -149,6 +135,22 @@ for <b>2 ways synchronizations</b>.
</ul>
-->
<h2><a id="DOC_BASIC"></a>Basic usage</h2>
<p>
See <b><a href="./imapsync_example.bat.txt">imapsync_example.bat.txt</a></b> batch file example
that you can easily adapt with your parameters (remove .txt extension in order to run it).
</p>
<h2><a id="DOC_MASS"></a>Huge usage</h2>
<p>
See <b><a href="./file.txt">file.txt</a></b> example for <b>batch massive migration</b>
(many mailboxes) on Windows or Unix.
</p>
<h2><a id="AUTHOR"></a>Who is the author?</h2>
<p>Gilles LAMIRAL<br/>
@ -176,7 +178,7 @@ for <b>2 ways synchronizations</b>.
</p>
<p>
30 EUR is equal to around <b>45 USD</b>, no problem to pay in USD (or any currency) with paypal:
30 EUR is equal to around <b>40 USD</b>, no problem to pay in USD (or any currency) with paypal:
</p>
<p>
@ -209,7 +211,7 @@ name="submit" alt="PayPal - The safer, easier way to pay online!"/>
<p>For <b>180 EUR</b> buy imapsync <b>support</b> by the developper who wrote and maintains imapsync.
</p>
<p>
180 EUR is equal to around <b>260 USD</b>, no problem to pay in USD (or any currency) with paypal:
180 EUR is equal to around <b>230 USD</b>, no problem to pay in USD (or any currency) with paypal:
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
@ -242,7 +244,7 @@ buying the latest win32 <b>standalone imapsync.exe</b> for <b>30 EUR</b>
<p>
30 EUR is equal to around <b>45 USD</b>, no problem to pay in USD (or any currency) with paypal:
30 EUR is equal to around <b>40 USD</b>, no problem to pay in USD (or any currency) with paypal:
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
@ -506,7 +508,7 @@ alt="Viewable With Any Browser" />
<!--#config timefmt="%D" -->
<!--#config timefmt="%A %B %d, %Y" -->
<b>This document last modified on <!--#echo var="LAST_MODIFIED" --></b>
($Id: index.shtml,v 1.106 2012/01/08 02:00:53 gilles Exp gilles $)
($Id: index.shtml,v 1.109 2012/02/07 10:54:11 gilles Exp gilles $)
</p>
</body>

6
memo
View File

@ -1,6 +1,6 @@
#!/bin/sh
# $Id: memo,v 1.40 2012/01/08 05:12:55 gilles Exp gilles $
# $Id: memo,v 1.41 2012/02/04 23:55:37 gilles Exp gilles $
software_version() {
@ -42,7 +42,7 @@ echo -n "lfo count ip: "
ssh glamiral@linux-france.org "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n|wc -l" # count ip
echo -n "lfo imapsync runs: "
ssh glamiral@linux-france.org "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|wc -l" # imapsync runs
date
}
@ -75,7 +75,7 @@ echo -n "ks count ip: "
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n|wc -l" # count ip
echo -n "ks imapsync runs: "
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|wc -l" # imapsync runs
date
}

View File

@ -5,7 +5,7 @@
<title>imapsync donation</title>
<meta name="generator" content="Bluefish 1.0.7"/>
<meta name="author" content="Gilles LAMIRAL"/>
<meta name="date" content="2011-01-18T03:51:50+0100"/>
<meta name="date" content="2012-02-05T02:07:59+0100"/>
<meta name="copyright" content=""/>
<meta name="keywords" content=""/>
<meta name="description" content=""/>
@ -36,7 +36,7 @@ border:0px;
<h1>imapsync donation</h1>
<p>Help the author to maintain imapsync:<br/>
(<b>1 EUR ~ 1.5 USD</b> on 05/2011)
(<b>1 EUR ~ 1.3 USD</b> on 02/2012)
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<p>
@ -65,7 +65,7 @@ border:0px;
<!--#config timefmt="%D" -->
<!--#config timefmt="%A %B %d, %Y" -->
<b>This document last modified on <!--#echo var="LAST_MODIFIED" --></b>
($Id: paypal.shtml,v 1.5 2011/05/07 02:23:32 gilles Exp gilles $)
($Id: paypal.shtml,v 1.6 2012/02/05 01:08:05 gilles Exp gilles $)
</p>
</body>

139
tests.sh
View File

@ -1,6 +1,6 @@
#!/bin/sh
# $Id: tests.sh,v 1.188 2012/01/08 06:38:29 gilles Exp gilles $
# $Id: tests.sh,v 1.191 2012/02/07 09:27:17 gilles Exp gilles $
# Example 1:
# CMD_PERL='perl -I./Mail-IMAPClient-3.25/lib' sh -x tests.sh
@ -94,8 +94,8 @@ no_args() {
# mailbox tata titi on most ll_*() tests
# mailbox tete@est.belle used on big size tests:
# big_transfert()
# big_transfert_sizes_only()
# big_folder()
# big_folder_sizes_only()
# dprof()
# mailbox big1 big2 used on bigmail tests
@ -881,10 +881,26 @@ ll_newmessage()
--passfile1 ../../var/pass/secret.tata \
--host2 $HOST2 --user2 titi \
--passfile2 ../../var/pass/secret.titi \
--maxage 1 --folder INBOX --nofoldersizes --noreleasecheck \
--maxage 1 --folder INBOX --nofoldersizes \
--debugLIST
}
ll_exitwhenover()
{
can_send && sendtestmessage
can_send && sendtestmessage
$CMD_PERL ./imapsync \
--host1 $HOST1 --user1 tata \
--passfile1 ../../var/pass/secret.tata \
--host2 $HOST2 --user2 titi \
--passfile2 ../../var/pass/secret.titi \
--maxage 1 --folder INBOX --nofoldersizes \
--exitwhenover 300
}
ll_folder_INBOX()
{
$CMD_PERL ./imapsync \
@ -1552,20 +1568,42 @@ ll_delete2_dev() {
}
ll_delete() {
if can_send; then
sendtestmessage titi
fi
ll_delete() {
$CMD_PERL ./imapsync \
--host1 $HOST1 --user1 tata \
--passfile1 ../../var/pass/secret.tata \
--host2 $HOST2 --user2 titi \
--passfile2 ../../var/pass/secret.titi \
--folder INBOX.oneemail3
#find /home/vmail/titi/.oneemail3/ || :
echo After first sync
test -f /home/vmail/titi/.oneemail3/cur/* || return 1
$CMD_PERL ./imapsync \
--host1 $HOST1 --user1 titi \
--passfile1 ../../var/pass/secret.titi \
--host2 $HOST2 --user2 tata \
--passfile2 ../../var/pass/secret.tata \
--folder INBOX \
--folder INBOX.oneemail3 \
--delete
$CMD_PERL ./imapsync \
--host1 $HOST1 --user1 titi \
--passfile1 ../../var/pass/secret.titi \
--host2 $HOST2 --user2 tata \
--passfile2 ../../var/pass/secret.tata \
--folder INBOX.oneemail3 \
--justfoldersizes
#find /home/vmail/titi/.oneemail3/ || :
echo After delete
! test -f /home/vmail/titi/.oneemail3/cur/* || return 1
}
ll_delete_delete2() {
! $CMD_PERL ./imapsync \
--host1 $HOST1 --user1 titi \
@ -1637,7 +1675,6 @@ msw2() {
ssh Admin@c 'C:/msys/1.0/home/Admin/imapsync/test_exe.bat'
}
xxxxx_gmail() {
! ping -c1 imap.gmail.com || $CMD_PERL ./imapsync \
@ -1649,13 +1686,10 @@ xxxxx_gmail() {
--user1 tata \
--passfile1 ../../var/pass/secret.tata \
--nofoldersizes \
--justfolders \
--regextrans2 "s, +$,,g" --regextrans2 "s, +/,/,g" \
--exclude INBOX.yop.YAP
#--dry --prefix2 '[Gmail]/'
--justfolders --regextrans2 's/ //g' --exclude 'INBOX.yop.YAP' --exclude Gmail
}
xxxxx_gmail_2() {
! ping -c1 imap.gmail.com || $CMD_PERL ./imapsync \
@ -1681,11 +1715,11 @@ xxxxx_gmail_3() {
--user2 gilles.lamiral@gmail.com \
--passfile2 ../../var/pass/secret.gilles_gmail \
--nofoldersizes \
--folder INBOX.few_emails --justfolders --debug \
--folder INBOX.few_emails --debug \
--regextrans2 's,few_emails,Gmail/Messages envoyes,'
}
xxxxx_gmail_4() {
xxxxx_gmail_4_Sent() {
! ping -c1 imap.gmail.com || $CMD_PERL ./imapsync \
--host1 $HOST2 \
@ -1695,11 +1729,24 @@ xxxxx_gmail_4() {
--ssl2 \
--user2 gilles.lamiral@gmail.com \
--passfile2 ../../var/pass/secret.gilles_gmail \
--nofoldersizes \
--folder INBOX.Sent \
--regextrans2 's{Sent}{Gmail/Messages envoyes}'
--regextrans2 's{Sent}{[Gmail]/Messages envoy&AOk-s}'
}
xxxxx_gmail_5_justfolders() {
! ping -c1 imap.gmail.com || $CMD_PERL ./imapsync \
--host1 $HOST2 \
--user1 tata \
--passfile1 ../../var/pass/secret.tata \
--host2 imap.gmail.com \
--ssl2 \
--user2 gilles.lamiral@gmail.com \
--passfile2 ../../var/pass/secret.gilles_gmail \
--justfolders
}
xxxxx_gmail_5_justlogin() {
! ping -c1 imap.gmail.com || $CMD_PERL ./imapsync \
@ -1713,6 +1760,24 @@ xxxxx_gmail_5_justlogin() {
--justlogin
}
xxxxx_gmail_6() {
! ping -c1 imap.gmail.com || $CMD_PERL ./imapsync \
--host2 imap.gmail.com \
--ssl2 \
--user2 gilles.lamiral@gmail.com \
--passfile2 ../../var/pass/secret.gilles_gmail \
--host1 $HOST2 \
--user1 tata \
--passfile1 ../../var/pass/secret.tata \
--nofoldersizes \
--justfolders \
--regextrans2 "s, +$,,g" --regextrans2 "s, +/,/,g" \
--exclude INBOX.yop.YAP
#--dry --prefix2 '[Gmail]/'
}
gmail_xxxxx() {
@ -1725,7 +1790,7 @@ gmail_xxxxx() {
--user2 tata \
--passfile2 ../../var/pass/secret.tata \
--nofoldersizes \
--dry --justfolders
--dry --justfolders --exclude Gmail
}
@ -1738,7 +1803,8 @@ gmail() {
--passfile1 ../../var/pass/secret.gilles_gmail \
--host2 $HOST2 \
--user2 tata \
--passfile2 ../../var/pass/secret.tata
--passfile2 ../../var/pass/secret.tata \
--exclude Gmail
}
gmail_justfolders() {
@ -1751,7 +1817,7 @@ gmail_justfolders() {
--host2 $HOST2 \
--user2 tata \
--passfile2 ../../var/pass/secret.tata \
--justfolders
--justfolders --exclude Gmail
}
@ -1781,7 +1847,7 @@ gmail_gmail() {
--ssl2 \
--user2 imapsync.gl@gmail.com \
--passfile2 ../../var/pass/secret.imapsync.gl_gmail \
--justfolders
--justfolders --exclude Gmail
}
@ -2433,7 +2499,7 @@ sunone_gmail_2()
echo3 "[$date1] [$date2]"
}
big_transfert()
big_folder()
{
date1=`date`
{ $CMD_PERL ./imapsync \
@ -2449,7 +2515,26 @@ big_transfert()
echo3 "[$date1] [$date2]"
}
big_transfert_sizes_only()
big_folder_useuid()
{
date1=`date`
{ $CMD_PERL ./imapsync \
--host1 $HOST1 --user1 gilles@est.belle \
--passfile1 ../../var/pass/secret.gilles_mbox \
--host2 $HOST2 --user2 tete@est.belle \
--passfile2 ../../var/pass/secret.tete \
--folder INBOX.Junk.2011 --nofoldersizes \
--useuid --tmpdir /var/tmp || \
true
}
date2=`date`
echo3 "[$date1] [$date2]"
}
big_folder_sizes_only()
{
date1=`date`
{ $CMD_PERL ./imapsync \
@ -2464,7 +2549,7 @@ big_transfert_sizes_only()
echo3 "[$date1] [$date2]"
}
big_transfert_fast()
big_folder_fast()
{
date1=`date`
{ $CMD_PERL ./imapsync \
@ -2480,7 +2565,7 @@ big_transfert_fast()
echo3 "[$date1] [$date2]"
}
big_transfert_fast2()
big_folder_fast2()
{
date1=`date`
{ $CMD_PERL ./imapsync \