package FS::cust_main::Billing; use strict; use feature 'state'; use vars qw( $conf $DEBUG $me ); use Carp; use Data::Dumper; use List::Util qw( min ); use FS::UID qw( dbh ); use FS::Record qw( qsearch qsearchs dbdef ); use FS::Misc::DateTime qw( day_end ); use Tie::RefHash; use FS::cust_bill; use FS::cust_bill_pkg; use FS::cust_bill_pkg_display; use FS::cust_bill_pay; use FS::cust_credit_bill; use FS::cust_tax_adjustment; use FS::tax_rate; use FS::tax_rate_location; use FS::cust_bill_pkg_tax_location; use FS::cust_bill_pkg_tax_rate_location; use FS::part_event; use FS::part_event_condition; use FS::pkg_category; use FS::FeeOrigin_Mixin; use FS::Log; use FS::TaxEngine; use FS::Misc::Savepoint; # 1 is mostly method/subroutine entry and options # 2 traces progress of some operations # 3 is even more information including possibly sensitive data $DEBUG = 0; $me = '[FS::cust_main::Billing]'; install_callback FS::UID sub { $conf = new FS::Conf; #yes, need it for stuff below (prolly should be cached) }; =head1 NAME FS::cust_main::Billing - Billing mixin for cust_main =head1 SYNOPSIS =head1 DESCRIPTION These methods are available on FS::cust_main objects. =head1 METHODS =over 4 =item bill_and_collect Cancels and suspends any packages due, generates bills, applies payments and credits, and applies collection events to run cards, send bills and notices, etc. Any errors prevent subsequent operations from continuing and die (but see the "fatal" flag below). Options are passed as name-value pairs. Currently available options are: =over 4 =item time Bills the customer as if it were that time. Specified as a UNIX timestamp; see L). Also see L and L for conversion functions. For example: use Date::Parse; ... $cust_main->bill( 'time' => str2time('April 20th, 2001') ); =item invoice_time Used in conjunction with the I