/doc/examples/softwaresite/bugs/

rc='/cgit-css/cgit.png' alt='cgit logo'/> index : ledger-smb
Unnamed repository; edit this file to name it for gitweb.Jonas Smedegaard
summaryrefslogtreecommitdiff
path: root/bin/cp.pl
blob: 2caf4e7aed555e9d2d2a405dd060265b651436c0 (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # http://www.ledgersmb.org/
  4. #
  5. # Copyright (C) 2006
  6. # This work contains copyrighted information from a number of sources all used
  7. # with permission.
  8. #
  9. # This file contains source code included with or based on SQL-Ledger which
  10. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  11. # under the GNU General Public License version 2 or, at your option, any later
  12. # version. For a full list including contact information of contributors,
  13. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  14. #
  15. # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  16. # Copyright (c) 2002
  17. #
  18. # Author: DWS Systems Inc.
  19. # Web: http://www.sql-ledger.org
  20. #
  21. # Contributors:
  22. #
  23. #
  24. # Author: DWS Systems Inc.
  25. # Web: http://www.ledgersmb.org/
  26. #
  27. # Contributors:
  28. #
  29. # This program is free software; you can redistribute it and/or modify
  30. # it under the terms of the GNU General Public License as published by
  31. # the Free Software Foundation; either version 2 of the License, or
  32. # (at your option) any later version.
  33. #
  34. # This program is distributed in the hope that it will be useful,
  35. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  36. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  37. # GNU General Public License for more details.
  38. # You should have received a copy of the GNU General Public License
  39. # along with this program; if not, write to the Free Software
  40. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  41. #======================================================================
  42. #
  43. # Payment module
  44. #
  45. #======================================================================
  46. use LedgerSMB::CP;
  47. use LedgerSMB::OP;
  48. use LedgerSMB::IS;
  49. use LedgerSMB::IR;
  50. require "bin/arap.pl";
  51. 1;
  52. # end of main
  53. sub payment {
  54. if ($form->{type} eq 'receipt') {
  55. $form->{ARAP} = "AR";
  56. $form->{arap} = "ar";
  57. $form->{vc} = "customer";
  58. $form->{formname} = "receipt";
  59. }
  60. if ($form->{type} eq 'check') {
  61. $form->{ARAP} = "AP";
  62. $form->{arap} = "ap";
  63. $form->{vc} = "vendor";
  64. $form->{formname} = "check";
  65. }
  66. $form->{payment} = "payment";
  67. $form->{callback} = "$form->{script}?action=payment&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&all_vc=$form->{all_vc}&type=$form->{type}";
  68. # setup customer/vendor selection for open invoices
  69. if ($form->{all_vc}) {
  70. $form->all_vc(\%myconfig, $form->{vc}, $form->{ARAP}, undef, $form->{datepaid});
  71. } else {
  72. CP->get_openvc(\%myconfig, \%$form);
  73. if ($myconfig{vclimit} > 0) {
  74. $form->{"all_$form->{vc}"} = $form->{name_list};
  75. }
  76. }
  77. $form->{"select$form->{vc}"} = "";
  78. if (@{ $form->{"all_$form->{vc}"} }) {
  79. $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
  80. for (@{ $form->{"all_$form->{vc}"} }) { $form->{"select$form->{vc}"} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  81. }
  82. # departments
  83. if (@{ $form->{all_department} }) {
  84. $form->{selectdepartment} = "<option>\n";
  85. $form->{department} = "$form->{department}--$form->{department_id}" if $form->{department};
  86. for (@{ $form->{all_department} }) { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  87. }
  88. if (@{ $form->{all_language} }) {
  89. $form->{selectlanguage} = "<option>\n";
  90. for (@{ $form->{all_language} }) { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| }
  91. }
  92. CP->paymentaccounts(\%myconfig, \%$form);
  93. $form->{selectaccount} = "";
  94. $form->{"select$form->{ARAP}"} = "";
  95. for (@{ $form->{PR}{"$form->{ARAP}_paid"} }) { $form->{selectaccount} .= "<option>$_->{accno}--$_->{description}\n" }
  96. for (@{ $form->{PR}{$form->{ARAP}} }) { $form->{"select$form->{ARAP}"} .= "<option>$_->{accno}--$_->{description}\n" }
  97. # currencies
  98. @curr = split /:/, $form->{currencies};
  99. $form->{defaultcurrency} = $curr[0];
  100. chomp $form->{defaultcurrency};
  101. $form->{selectcurrency} = "";
  102. for (@curr) { $form->{selectcurrency} .= "<option>$_\n" }
  103. $form->{currency} = $form->{defaultcurrency};
  104. $form->{oldcurrency} = $form->{currency};
  105. if ($form->{currency} ne $form->{defaultcurrency}) {
  106. $form->{forex} = $form->{exchangerate} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{datepaid}, ($form->{vc} eq 'customer') ? "buy" : "sell");
  107. }
  108. $form->{olddatepaid} = $form->{datepaid};
  109. $form->{media} = $myconfig{printer};
  110. $form->{format} = "pdf" unless $myconfig{printer};
  111. &payment_header;
  112. &payment_footer;
  113. }
  114. sub payments {
  115. if ($form->{type} eq 'receipt') {
  116. $form->{ARAP} = "AR";
  117. $form->{arap} = "ar";
  118. $form->{vc} = "customer";
  119. $form->{formname} = "receipt";
  120. }
  121. if ($form->{type} eq 'check') {
  122. $form->{ARAP} = "AP";
  123. $form->{arap} = "ap";
  124. $form->{vc} = "vendor";
  125. $form->{formname} = "check";
  126. }
  127. $form->{payment} = "payments";
  128. $form->{callback} = "$form->{script}?action=$form->{action}";
  129. for (qw(path login sessionid type)) { $form->{callback} .= "&$_=$form->{$_}" }
  130. CP->paymentaccounts(\%myconfig, \%$form);
  131. if (@{ $form->{all_language} }) {
  132. $form->{selectlanguage} = "<option>\n";
  133. for (@{ $form->{all_language} }) { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| }
  134. }
  135. # departments
  136. if (@{ $form->{all_department} }) {
  137. $form->{selectdepartment} = "<option>\n";
  138. $form->{department} = "$form->{department}--$form->{department_id}" if $form->{department};
  139. for (@{ $form->{all_department} }) { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  140. }
  141. $form->{selectaccount} = "";
  142. $form->{"select$form->{ARAP}"} = "";
  143. for (@{ $form->{PR}{"$form->{ARAP}_paid"} }) { $form->{selectaccount} .= "<option>$_->{accno}--$_->{description}\n" }
  144. for (@{ $form->{PR}{$form->{ARAP}} }) { $form->{"select$form->{ARAP}"} .= "<option>$_->{accno}--$_->{description}\n" }
  145. # currencies
  146. @curr = split /:/, $form->{currencies};
  147. $form->{defaultcurrency} = $curr[0];
  148. chomp $form->{defaultcurrency};
  149. $form->{selectcurrency} = "";
  150. for (@curr) { $form->{selectcurrency} .= "<option>$_\n" }
  151. $form->{oldcurrency} = $form->{currency} = $form->{defaultcurrency};
  152. $form->{oldduedateto} = $form->{datepaid};
  153. $form->{media} = $myconfig{printer};
  154. $form->{format} = "pdf" unless $myconfig{printer};
  155. &payments_header;
  156. &invoices_due;
  157. &payments_footer;
  158. }
  159. sub payments_header {