4 use base qw( FS::Record );
5 use FS::Record qw( dbh ); #qsearch qsearchs );
10 FS::vend_pay - Object methods for vend_pay records
16 $record = new FS::vend_pay \%hash;
17 $record = new FS::vend_pay { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::vend_pay object represents a vendor payment. FS::vend_pay inherits from
30 FS::Record. The following fields are currently supported:
59 Creates a new payment. To add the payment to the database, see L<"insert">.
61 Note that this stores the hash reference, not a distinct copy of the hash it
62 points to. You can ask the object for a copy with the I<hash> method.
66 # the new method can be inherited from FS::Record, if a table method is defined
68 sub table { 'vend_pay'; }
72 Adds this record to the database. If there is an error, returns the error,
73 otherwise returns false.
79 my $oldAutoCommit = $FS::UID::AutoCommit;
80 local $FS::UID::AutoCommit = 0;
83 my $error = $self->SUPER::insert;
85 $dbh->rollback if $oldAutoCommit;
86 return "inserting vend_pay: $error";
89 if ( $self->get('vendbillnum') ) {
91 my $vend_bill_pay = new FS::vend_bill_pay {
92 'vendpaynum' => $self->vendpaynum,
93 'vendbillnum' => $self->get('vendbillnum'),
94 'amount' => $self->paid,
97 $error = $vend_bill_pay->insert;
99 $dbh->rollback if $oldAutoCommit;
100 return "auto-inserting vend_bill_pay: $error";
105 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
112 Delete this record from the database.
114 =item replace OLD_RECORD
116 Replaces the OLD_RECORD with this one in the database. If there is an error,
117 returns the error, otherwise returns false.
121 Checks all fields to make sure this is a valid payment. If there is
122 an error, returns the error, otherwise returns false. Called by the insert
131 $self->ut_numbern('vendpaynum')
132 || $self->ut_foreign_key('vendnum', 'vend_main', 'vendnum')
133 || $self->ut_numbern('_date')
134 || $self->ut_money('paid')
136 return $error if $error;
147 L<FS::Record>, schema.html from the base documentation.