summaryrefslogtreecommitdiff
path: root/bin/fs-migrate-payref
blob: f1513112ba1444aee2b86f11b491ee5455916e08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl

use strict;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch);
use FS::cust_pay;
use FS::cust_refund;

my $user = shift or die &usage;
my $dbh = adminsuidsetup $user;

#local $FS::UID::AutoCommit = 0; #quelle hack, in this case
# $FS::UID::AutoCommit = 0; #quelle hack, in this case

# apply payments to invoices

foreach my $cust_pay ( qsearch('cust_pay', {} ) ) {
  my $error = $cust_pay->upgrade_replace;
  warn $error if $error;
}

# apply refunds to credits

foreach my $cust_refund ( qsearch('cust_refund') ) {
  my $error = $cust_refund->upgrade_replace;
  warn $error if $error;
}

# ? apply credits to invoices