$result = true;
foreach($exts as $i => $ext) {
- if ($ext['package'] && ($ext['active'] ^ check_value('Active'.$i))) {
- if (check_value('Active'.$i) && !check_src_ext_version($ext['version']))
- {
- display_warning(sprintf(_("Package '%s' is incompatible with current application version and cannot be activated.\n")
- . _("Check Install/Activate page for newer package version."), $ext['name']));
- continue;
- }
- if (!$ext['active'])
- $activated = activate_hooks($ext['package'], $comp);
- else
- $activated = hook_invoke($ext['package'], check_value('Active'.$i) ?
- 'activate_extension':'deactivate_extension', $comp, false);
+ if ($ext['package'] && ($ext['active'] ^ check_value('Active'.$i)))
+ {
+ $activated = activate_hooks($ext['package'], $comp, !$ext['active']); // change active state
+
if ($activated !== null)
$result &= $activated;
if ($activated || ($activated === null))
else
$memo_ = $_SESSION["wa_current_user"]->username . " - " . $memo_;
}
- if (!is_subledger_account($account) || $account==get_company_pref('grn_clearing_act'))
+ if ($type != ST_WORKORDER && (!is_subledger_account($account) || $account==get_company_pref('grn_clearing_act')))
$person_id = $person_type_id = null;
-
+
$sql = "INSERT INTO ".TB_PREF."gl_trans ( type, type_no, tran_date,
account, dimension_id, dimension2_id, memo_, amount";
function get_gl_wo_cost_trans($trans_id, $cost_type=-1)
{
- $sql = "SELECT costing.*, gl.*, chart.account_name, com.memo_ FROM "
- .TB_PREF."wo_costing costing, "
- .TB_PREF."gl_trans gl LEFT JOIN ".TB_PREF."comments com ON gl.type=com.type AND gl.type_no=com.id,"
- .TB_PREF."chart_master chart
- WHERE
- costing.workorder_id=".db_escape($trans_id)
- ." AND chart.account_code=gl.account
- AND gl.type=costing.trans_type
- AND gl.type_no=costing.trans_no";
- if ($cost_type != -1)
- $sql .= " AND costing.cost_type=".db_escape($cost_type);
+ $sql = "SELECT gl.*, chart.account_name FROM ".TB_PREF."gl_trans gl, ".TB_PREF."chart_master chart
+ WHERE chart.account_code=gl.account AND gl.type=".ST_WORKORDER." AND gl.type_no=".db_escape($trans_id)."
+ AND gl.person_type_id=".PT_WORKORDER;
+ if ($cost_type!= -1)
+ $sql .= " AND gl.person_id=".db_escape($cost_type);
$sql .= " AND amount < 0";
return db_query($sql, "The gl transactions could not be retrieved");
display_error( _("The account name cannot be empty."));
set_focus('account_name');
}
- elseif (!$SysPrefs->accounts_alpha() && !is_numeric($_POST['account_code']))
+ elseif (!$SysPrefs->accounts_alpha() && !preg_match("/^[0-9.]+$/",$_POST['account_code'])) // we only allow 0-9 and a dot
{
$input_error = 1;
display_error( _("The account code must be numeric."));
Non active hooks are not included in $Hooks array, so we can use special function to
activate.
*/
-function activate_hooks($ext, $comp)
+function activate_hooks($ext, $comp, $on=true)
{
global $Hooks;
}
if (!$hooks)
return false;
- else
+ elseif ($on)
return $hooks->activate_extension($comp, false);
+ else
+ return $hooks->deactivate_extension($comp, false);
}
/*
Calls hook $method defined in extension $ext (if any)
msgstr "Sprog"
#: /install/index.php:124
-msgid "Cannot connect to database. User or password is invalid or you have no permittions to create database."
-msgstr "Kan ikke skabe forbindelse til databasen. Enten er brugernavnet eller adgangskoden forkert eller også har du ikke adgang til at skabe databasen"
+msgid ""
+"Cannot connect to database. User or password is invalid or you have no "
+"permittions to create database."
+msgstr ""
+"Kan ikke skabe forbindelse til databasen. Enten er brugernavnet eller "
+"adgangskoden forkert eller også har du ikke adgang til at skabe databasen"
#: /install/index.php:164
msgid "Cannot save system configuration file 'config.php'."
msgstr "Kan ikke skrive til 'config_db.php' konfigurationsfilen."
#: /install/index.php:177
-msgid "Configuration file 'config_db.php' is not writable. Change its permissions so it is, then re-run installation step."
-msgstr "Konfigurationsfilen 'config_db.php' er ikke skrivbar. Ändre tilladelsen til det og kör installationenstrinet igen."
+msgid ""
+"Configuration file 'config_db.php' is not writable. Change its permissions "
+"so it is, then re-run installation step."
+msgstr ""
+"Konfigurationsfilen 'config_db.php' er ikke skrivbar. Ändre tilladelsen til "
+"det og kör installationenstrinet igen."
#: /install/index.php:216
msgid "Host name cannot be empty."
msgstr "Vælg installationswizard sprog:"
#: /install/index.php:328
-msgid "All application preliminary requirements seems to be correct. Please press Continue button below."
-msgstr "Alle programmets behov ser ud til at være dækket. Venligst tryk 'Fortsæt' forneden."
+msgid ""
+"All application preliminary requirements seems to be correct. Please press "
+"Continue button below."
+msgstr ""
+"Alle programmets behov ser ud til at være dækket. Venligst tryk 'Fortsæt' "
+"forneden."
#: /install/index.php:329 /install/index.php:357 /install/index.php:364
#: /install/index.php:371
msgstr "Fortsæt >>"
#: /install/index.php:331
-msgid "Application cannot be installed. Please fix problems listed below in red, and press Refresh button."
-msgstr "Programmet kan ikke installeres. Venligst ordne problemerne beskrivet forneden i rødt, og tryk 'Genlæs' knappen."
+msgid ""
+"Application cannot be installed. Please fix problems listed below in red, "
+"and press Refresh button."
+msgstr ""
+"Programmet kan ikke installeres. Venligst ordne problemerne beskrivet "
+"forneden i rødt, og tryk 'Genlæs' knappen."
#: /install/index.php:332
msgid "Refresh"
#: /install/index.php:348
msgid "Database Collation:"
-msgstr ""
+msgstr "Database sortering:"
#: /install/index.php:349
msgid "Use '0_' Table Prefix:"
msgstr "Installer yderligere kontoplaner fra FA's lager (Repository):"
#: /install/index.php:353
-msgid "Select collation you want to use. If you are unsure or you will use various languages, select unicode collation."
+msgid ""
+"Select collation you want to use. If you are unsure or you will use various "
+"languages, select unicode collation."
msgstr ""
+"Vælg database sortering du wil bruge. Om du er usikker eller du vil bruge "
+"forskellige sprog, vælg da unicode sortering."
#: /install/index.php:354
-msgid "Use table prefix if you share selected database for more than one FA company using the same collation."
+msgid ""
+"Use table prefix if you share selected database for more than one FA company "
+"using the same collation."
msgstr ""
+"Brug tabel prefix of du deler valgt database med mere end et firma som "
+"bruger samme sortering."
#: /install/index.php:355
-msgid "Do not select additional langs nor COAs if you have no working internet connection right now. You can install them later."
-msgstr "Vælg ikke yderligere sprog eller kontoplaner hvis du ikke har en fungerende internet forbindelse lige nu. Du kan installere dem senere."
+msgid ""
+"Do not select additional langs nor COAs if you have no working internet "
+"connection right now. You can install them later."
+msgstr ""
+"Vælg ikke yderligere sprog eller kontoplaner hvis du ikke har en fungerende "
+"internet forbindelse lige nu. Du kan installere dem senere."
#: /install/index.php:356 /install/index.php:363 /install/index.php:370
#: /install/index.php:394
#: /install/index.php:395
msgid "Start installation process"
-msgstr ""
+msgstr "Påbegynd installationen"
#: /install/index.php:399
msgid "FrontAccounting ERP has been installed successsfully."
#: /includes/system_tests.inc:50
msgid "Upgrade PHP to version at least 5.0.0"
-msgstr ""
+msgstr "Opgrader PHP til mindst version 5.0.0 "
#: /includes/system_tests.inc:57
msgid "Server system"
#: /includes/system_tests.inc:323
#, php-format
-msgid "'%s' file should be read-only if you do not plan to add or change companies"
-msgstr "'%s' filen må være 'read-only' hvis du ikke har planer om at lægge till eller ændre firmaer."
+msgid ""
+"'%s' file should be read-only if you do not plan to add or change companies"
+msgstr ""
+"'%s' filen må være 'read-only' hvis du ikke har planer om at lægge till "
+"eller ændre firmaer."
#: /includes/system_tests.inc:334
msgid "Extensions system"
msgstr "Ikke standard theme mappe '%s' er ikk skrivbar"
#: /includes/system_tests.inc:395
-msgid "OpenSSL PHP extension have to be enabled to use extension repository system."
-msgstr "OpenSSL PHP tillæg må være aktiv for at bruge tillægslagersystemet (FA Repository)"
+msgid ""
+"OpenSSL PHP extension have to be enabled to use extension repository system."
+msgstr ""
+"OpenSSL PHP tillæg må være aktiv for at bruge tillægslagersystemet (FA "
+"Repository)"
#: /includes/system_tests.inc:398
-msgid "OpenSSL have to be available on your server to use extension repository system."
-msgstr "OpenSSL må findes på din server for at bruge tillægslagersystem (FA Repository)"
+msgid ""
+"OpenSSL have to be available on your server to use extension repository "
+"system."
+msgstr ""
+"OpenSSL må findes på din server for at bruge tillægslagersystem (FA "
+"Repository)"
#: /includes/system_tests.inc:421
msgid "Test"
#: /includes/packages.inc:294
msgid "Cannot download repo index file."
-msgstr ""
+msgstr "Kan ikke downloade repo indeks fil."
#: /includes/packages.inc:306 /includes/packages.inc:343
#, php-format
msgid "Cannot delete outdated '%s' file."
-msgstr ""
+msgstr "Kan ikke slette gammel '%s' fil."
#: /includes/packages.inc:310
msgid "Release file in repository is invalid, or public key is outdated."
-msgstr "Release felt i repository er ugyldig, eller også er public key for gammel."
+msgstr ""
+"Release felt i repository er ugyldig, eller også er public key for gammel."
#: /includes/packages.inc:327
msgid "Repository version does not match application version."
#: /includes/packages.inc:335 /includes/packages.inc:377
#, php-format
msgid "Cannot download '%s' file."
-msgstr ""
+msgstr "Kan ikke downloade '%s' fil."
#: /includes/packages.inc:347
#, php-format
-msgid "Security alert: broken index file in repository '%s'. Please inform repository administrator about this issue."
-msgstr "Sikkerhedsadvarsel: Indeks feltet i repository '%s' er brudt. Informer venligst repository administratoren om dette."
+msgid ""
+"Security alert: broken index file in repository '%s'. Please inform "
+"repository administrator about this issue."
+msgstr ""
+"Sikkerhedsadvarsel: Indeks feltet i repository '%s' er brudt. Informer "
+"venligst repository administratoren om dette."
#: /includes/packages.inc:383
#, php-format
-msgid "Security alert: broken package '%s' in repository. Please inform repository administrator about this issue."
-msgstr "Sikkerhedsadvarsel: Brudt pakke '%s' i repository. Venligst informer repository administratoren om dette."
+msgid ""
+"Security alert: broken package '%s' in repository. Please inform repository "
+"administrator about this issue."
+msgstr ""
+"Sikkerhedsadvarsel: Brudt pakke '%s' i repository. Venligst informer "
+"repository administratoren om dette."
#: /includes/packages.inc:641 /includes/packages.inc:696
#, php-format
msgid "Package '%s' not found."
msgstr "Pakke '%s' findes ikke."
-#~ msgid "Use table prefix if you share selected database for more than one FA company."
+#~ msgid ""
+#~ "Use table prefix if you share selected database for more than one FA "
+#~ "company."
#~ msgstr "Brug tabel prefix hvis du deler databasen med flere FA firmaer."
#~ msgid "Upgrade PHP to version at least 4.3.3"
"Project-Id-Version: PACKAGE Version\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-11 13:17+0100\n"
-"PO-Revision-Date: 2015-05-07 15:03+0100\n"
+"PO-Revision-Date: 2015-12-11 23:12+0100\n"
"Last-Translator: Joe Hunt <joe.hunt.consulting@gmail.com>\n"
"Language-Team: Language <LL@li.org>\n"
"Language: sv_SE\n"
msgstr "Språk"
#: /install/index.php:124
-msgid "Cannot connect to database. User or password is invalid or you have no permittions to create database."
-msgstr "Kan inte ansluta till databasen. Anvøndarnamnet eller lösenordet är ogiltig eller hu har inte tillgång att skapa databasen."
+msgid ""
+"Cannot connect to database. User or password is invalid or you have no "
+"permittions to create database."
+msgstr ""
+"Kan inte ansluta till databasen. Anvøndarnamnet eller lösenordet är ogiltig "
+"eller hu har inte tillgång att skapa databasen."
#: /install/index.php:164
msgid "Cannot save system configuration file 'config.php'."
msgstr "Kan inte skriva till 'config_db.php konfigutionsfilen."
#: /install/index.php:177
-msgid "Configuration file 'config_db.php' is not writable. Change its permissions so it is, then re-run installation step."
-msgstr "Konfigurationsfilen 'config_db.php' är inte skrivbar. Ändra så att den ör skrivbar, och kör installationssteget igen."
+msgid ""
+"Configuration file 'config_db.php' is not writable. Change its permissions "
+"so it is, then re-run installation step."
+msgstr ""
+"Konfigurationsfilen 'config_db.php' är inte skrivbar. Ändra så att den ör "
+"skrivbar, och kör installationssteget igen."
#: /install/index.php:216
msgid "Host name cannot be empty."
msgstr "Välj installationswizardens språk:"
#: /install/index.php:328
-msgid "All application preliminary requirements seems to be correct. Please press Continue button below."
-msgstr "Alla programmets behov ser ut att vara korrekta. Vänligen tryck Fortsätt knappen nedan."
+msgid ""
+"All application preliminary requirements seems to be correct. Please press "
+"Continue button below."
+msgstr ""
+"Alla programmets behov ser ut att vara korrekta. Vänligen tryck Fortsätt "
+"knappen nedan."
#: /install/index.php:329 /install/index.php:357 /install/index.php:364
#: /install/index.php:371
msgstr "Fortsätt >>"
#: /install/index.php:331
-msgid "Application cannot be installed. Please fix problems listed below in red, and press Refresh button."
-msgstr "Programmet kan inte installeras. Vänligen fixa problemen som är beskrivna nedan och tryk Upprepa knappen."
+msgid ""
+"Application cannot be installed. Please fix problems listed below in red, "
+"and press Refresh button."
+msgstr ""
+"Programmet kan inte installeras. Vänligen fixa problemen som är beskrivna "
+"nedan och tryk Upprepa knappen."
#: /install/index.php:332
msgid "Refresh"
#: /install/index.php:348
msgid "Database Collation:"
-msgstr ""
+msgstr "Databas sortering."
#: /install/index.php:349
msgid "Use '0_' Table Prefix:"
msgstr "Installera ytterligare kontoplaner från FA lagret:"
#: /install/index.php:353
-msgid "Select collation you want to use. If you are unsure or you will use various languages, select unicode collation."
+msgid ""
+"Select collation you want to use. If you are unsure or you will use various "
+"languages, select unicode collation."
msgstr ""
+"Välj sortering som du önskar att använda. Om du är osäker eller will använda "
+"olika språk, välj då unicode sortering."
#: /install/index.php:354
-msgid "Use table prefix if you share selected database for more than one FA company using the same collation."
+msgid ""
+"Use table prefix if you share selected database for more than one FA company "
+"using the same collation."
msgstr ""
+"Använd tabell prefix om du delar vald daabas med flera än ett FA bolag som "
+"använder samma sortering. "
#: /install/index.php:355
-msgid "Do not select additional langs nor COAs if you have no working internet connection right now. You can install them later."
-msgstr "Välj inte ytterligare språk eller kontoplaner om du inte har någon fungerande internet förbindelse nu. Du kan installere dem senare."
+msgid ""
+"Do not select additional langs nor COAs if you have no working internet "
+"connection right now. You can install them later."
+msgstr ""
+"Välj inte ytterligare språk eller kontoplaner om du inte har någon "
+"fungerande internet förbindelse nu. Du kan installere dem senare."
#: /install/index.php:356 /install/index.php:363 /install/index.php:370
#: /install/index.php:394
#: /install/index.php:395
msgid "Start installation process"
-msgstr ""
+msgstr "Påbörja installationen"
#: /install/index.php:399
msgid "FrontAccounting ERP has been installed successsfully."
#: /install/index.php:400
msgid "Please do not forget to remove install wizard folder."
-msgstr "Vänligen glöm inte att omdöpa eller ta bort installationswizrdens mapp."
+msgstr ""
+"Vänligen glöm inte att omdöpa eller ta bort installationswizrdens mapp."
#: /install/index.php:403
msgid "Click here to start."
#: /includes/system_tests.inc:50
msgid "Upgrade PHP to version at least 5.0.0"
-msgstr ""
+msgstr "Uppgrader PHP till åtminstone"
#: /includes/system_tests.inc:57
msgid "Server system"
#: /includes/system_tests.inc:83
msgid "Remove or rename install wizard folder for security reasons."
-msgstr "Ta bort eller omdöp installationswizardens mapp av säkerhetsmässiga orsaker."
+msgstr ""
+"Ta bort eller omdöp installationswizardens mapp av säkerhetsmässiga orsaker."
#: /includes/system_tests.inc:90
msgid "Browser type"
#: /includes/system_tests.inc:166
msgid "Database structure seems to be not upgraded to current version"
-msgstr "Databasstruktur tycks inte ha blivit uppgraderat till nuvarande version"
+msgstr ""
+"Databasstruktur tycks inte ha blivit uppgraderat till nuvarande version"
#: /includes/system_tests.inc:181
msgid "Company subdirectories consistency"
#: /includes/system_tests.inc:323
#, php-format
-msgid "'%s' file should be read-only if you do not plan to add or change companies"
-msgstr "'%s' filen måste vara read-only om du inte planerar att lägga till eller ändra företag."
+msgid ""
+"'%s' file should be read-only if you do not plan to add or change companies"
+msgstr ""
+"'%s' filen måste vara read-only om du inte planerar att lägga till eller "
+"ändra företag."
#: /includes/system_tests.inc:334
msgid "Extensions system"
msgstr "Icke standard theme mapp '%s' är inte skrivbar"
#: /includes/system_tests.inc:395
-msgid "OpenSSL PHP extension have to be enabled to use extension repository system."
+msgid ""
+"OpenSSL PHP extension have to be enabled to use extension repository system."
msgstr "OpenSSL PHP tillägget måste vara aktivt för att använda tillägslagret"
#: /includes/system_tests.inc:398
-msgid "OpenSSL have to be available on your server to use extension repository system."
+msgid ""
+"OpenSSL have to be available on your server to use extension repository "
+"system."
msgstr "OpenSSL måste finnas på din server för att använda tillägslagret."
#: /includes/system_tests.inc:421
#: /includes/packages.inc:294
msgid "Cannot download repo index file."
-msgstr ""
+msgstr "Kan inte ladda ner repo index filen."
#: /includes/packages.inc:306 /includes/packages.inc:343
#, php-format
msgid "Cannot delete outdated '%s' file."
-msgstr ""
+msgstr "Kan inte radera gammal '%s' fil."
#: /includes/packages.inc:310
msgid "Release file in repository is invalid, or public key is outdated."
-msgstr "Release filen i repository är ogiltig, eller också är publika nyckeln ogiltig."
+msgstr ""
+"Release filen i repository är ogiltig, eller också är publika nyckeln "
+"ogiltig."
#: /includes/packages.inc:327
msgid "Repository version does not match application version."
#: /includes/packages.inc:335 /includes/packages.inc:377
#, php-format
msgid "Cannot download '%s' file."
-msgstr ""
+msgstr "Kan inte ladda ner '%s' filen."
#: /includes/packages.inc:347
#, php-format
-msgid "Security alert: broken index file in repository '%s'. Please inform repository administrator about this issue."
-msgstr "Säkerhetsvarning: Bruten indes fil i repository '%s'. Vänligen informera repository administratorn om detta."
+msgid ""
+"Security alert: broken index file in repository '%s'. Please inform "
+"repository administrator about this issue."
+msgstr ""
+"Säkerhetsvarning: Bruten indes fil i repository '%s'. Vänligen informera "
+"repository administratorn om detta."
#: /includes/packages.inc:383
#, php-format
-msgid "Security alert: broken package '%s' in repository. Please inform repository administrator about this issue."
-msgstr "Säkerhetsvarning: Brutet paket '%s' i repository. Vänligen informera repository administratorn om detta."
+msgid ""
+"Security alert: broken package '%s' in repository. Please inform repository "
+"administrator about this issue."
+msgstr ""
+"Säkerhetsvarning: Brutet paket '%s' i repository. Vänligen informera "
+"repository administratorn om detta."
#: /includes/packages.inc:641 /includes/packages.inc:696
#, php-format
msgid "Package '%s' not found."
msgstr "Paket '%s' finns ej."
-#~ msgid "Use table prefix if you share selected database for more than one FA company."
-#~ msgstr "Använd tabell prefix om du delar databasen med flera än ett företag."
+#~ msgid ""
+#~ "Use table prefix if you share selected database for more than one FA "
+#~ "company."
+#~ msgstr ""
+#~ "Använd tabell prefix om du delar databasen med flera än ett företag."
#~ msgid "Upgrade PHP to version at least 4.3.3"
#~ msgstr "Uppgradera PHP till minst 4.3.3"
if (!is_service($issue["mb_flag"]))
$ivaccount = $issue["inventory_account"];
else
- $ivaccount = $issue["cogs_account"];
+ $ivaccount = $issue["assembly_account"];
$total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $ivaccount, 0, 0,
$date_.": "._("Issue of")." ".$stockitem["description"], -$issue_cost);
if (!is_service($issue["mb_flag"]))
$ivaccount = $issue["inventory_account"];
else
- $ivaccount = $issue["cogs_account"];
+ $ivaccount = $issue["assembly_account"];
if ($issue_cost != 0)
{
$standard_cost = get_standard_cost($bom_item['component']);
$m_cost += ($bom_item['quantity'] * $standard_cost);
}
+ // new 2015.10.15
+ // additilnal costs.
+ if (work_order_has_issues($woid))
+ {
+ $res = get_additional_issues($woid);
+ while ($issue = db_fetch($res))
+ {
+ $standard_cost = get_standard_cost($issue['stock_id']);
+ $m_cost += ($issue['qty_issued'] * $standard_cost) / $quantity;
+ }
+ }
+ $m_cost += (get_gl_wo_cost($woid, WO_LABOUR) / $quantity);
+ $m_cost += (get_gl_wo_cost($woid, WO_OVERHEAD) / $quantity);
// insert a +ve stock move for the item being manufactured
// negative means "unproduce" or unassemble
if (!is_service($issue["mb_flag"]))
$ivaccount = $issue["inventory_account"];
else
- $ivaccount = $issue["cogs_account"];
+ $ivaccount = $issue["assembly_account"];
if ($issue_cost != 0)
{
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
+//--------------------------------------------------------------------------------------
+
+function add_material_cost($stock_id, $qty, $date_, $advanced=false, $woid=0)
+{
+ $m_cost = 0;
+ $result = get_bom($stock_id);
+ while ($bom_item = db_fetch($result))
+ {
+ $standard_cost = get_standard_cost($bom_item['component']);
+ $m_cost += ($bom_item['quantity'] * $standard_cost);
+ }
+ $bom_cost = $m_cost;
+ // new 2015.10.15
+ // additilnal costs.
+ $i_cost = 0;
+ if ($woid != 0 && work_order_has_issues($woid))
+ {
+ $res = get_additional_issues($woid);
+ while ($issue = db_fetch($res))
+ {
+ $standard_cost = get_standard_cost($issue['stock_id']);
+ $i_cost += ($issue['qty_issued'] * $standard_cost) / $qty;
+ }
+ }
+ $sql = "SELECT material_cost, labour_cost, overhead_cost FROM ".TB_PREF."stock_master WHERE stock_id = "
+ .db_escape($stock_id);
+ $result = db_query($sql);
+ $myrow = db_fetch($result);
+ $material_cost = $myrow['material_cost'] - $i_cost; // $i_cost was already added to material cost
+ $m_cost += $i_cost;
+ /* no, why will we do that?? Joe Hunt 2015.10.17
+ if ($advanced)
+ {
+ //reduce overhead_cost and labour_cost from price as those will remain as is
+ $m_cost = $m_cost - $myrow['labour_cost'] - $myrow['overhead_cost'];
+ }
+ */
+ $qoh = get_qoh_on_date($stock_id);
+ $cost_adjust = false;
+ if ($qoh < 0)
+ {
+ if ($qoh + $qty >= 0)
+ $cost_adjust = true;
+ $qoh = 0;
+ }
+ if ($qoh + $qty != 0)
+ {
+ if ($qoh == 0) // 27.10.2014 apmuthu and dz.
+ $material_cost = $m_cost;
+ else
+ $material_cost = ($qoh * $material_cost + $qty * $m_cost) / ($qoh + $qty);
+ }
+ if ($advanced && $cost_adjust) // new 2010-02-10
+ adjust_deliveries($stock_id, $bom_cost, $date_);
+
+ $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=".db_escape($material_cost)."
+ WHERE stock_id=".db_escape($stock_id);
+ db_query($sql,"The cost details for the inventory item could not be updated");
+}
+
+function add_overhead_cost($stock_id, $qty, $date_, $costs, $adj_only=false)
+{
+ if ($qty != 0)
+ $costs /= $qty;
+ $sql = "SELECT overhead_cost FROM ".TB_PREF."stock_master WHERE stock_id = "
+ .db_escape($stock_id);
+ $result = db_query($sql);
+ $myrow = db_fetch($result);
+ $overhead_cost = $myrow['overhead_cost'];
+ $qoh = get_qoh_on_date($stock_id);
+ if ($qoh < 0)
+ $qoh = 0;
+ if ($adj_only)
+ {
+ if ($qoh>0)
+ {
+ if ($qoh + $qty != 0)
+ $overhead_cost = ($qoh * $overhead_cost + $qty * $costs) / ($qoh + $qty);
+ elseif ($qty == 0)
+ $overhead_cost = ($qoh * $overhead_cost + $costs) / $qoh;
+ }
+ else // Journal Entry if QOH is 0/negative
+ {
+ global $Refs;
+
+ $id = get_next_trans_no(ST_JOURNAL);
+ $ref = $Refs->get_next(ST_JOURNAL);
+
+ $stock_gl_code = get_stock_gl_code($stock_id);
+ $memo = "WO Overhead cost settlement JV for zero/negative respository of ".$stock_id;
+ //Reverse the inventory effect if $qoh <=0
+ add_gl_trans_std_cost(ST_JOURNAL, $id, $date_,
+ $stock_gl_code["inventory_account"],
+ $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $memo,
+ -$costs);
+ //GL Posting to inventory adjustment account
+ add_gl_trans_std_cost(ST_JOURNAL, $id, $date_,
+ $stock_gl_code["assembly_account"], // changed 2015.10.14 from adjustment to assembly account. Petros.
+ $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $memo,
+ $costs);
+
+ add_audit_trail(ST_JOURNAL, $id, $date_);
+ add_comments(ST_JOURNAL, $id, $date_, $memo);
+ $Refs->save(ST_JOURNAL, $id, $ref);
+ if ($qty != 0) // 27.10.2014 dz
+ $overhead_cost = ($qoh * $overhead_cost + $costs) / $qty;
+ }
+ }
+ else
+ {
+ if ($qoh + $qty != 0)
+ $overhead_cost = ($qoh * $overhead_cost + $qty * $costs) / ($qoh + $qty);
+ }
+ $sql = "UPDATE ".TB_PREF."stock_master SET overhead_cost=".db_escape($overhead_cost)."
+ WHERE stock_id=".db_escape($stock_id);
+ db_query($sql,"The cost details for the inventory item could not be updated");
+}
+
+function add_labour_cost($stock_id, $qty, $date_, $costs, $adj_only=false)
+{
+ if ($qty != 0)
+ $costs /= $qty;
+ $sql = "SELECT labour_cost FROM ".TB_PREF."stock_master WHERE stock_id = "
+ .db_escape($stock_id);
+ $result = db_query($sql);
+ $myrow = db_fetch($result);
+ $labour_cost = $myrow['labour_cost'];
+ $qoh = get_qoh_on_date($stock_id);
+ if ($qoh < 0)
+ $qoh = 0;
+ if ($adj_only)
+ {
+ if ($qoh>0)
+ {
+ if ($qoh + $qty != 0)
+ $labour_cost = ($qoh * $labour_cost + $qty * $costs) / ($qoh + $qty);
+ elseif ($qty == 0)
+ $labour_cost = ($qoh * $labour_cost + $costs) / $qoh;
+ }
+ else // Journal Entry if QOH is 0/negative
+ {
+ global $Refs;
+
+ $id = get_next_trans_no(ST_JOURNAL);
+ $ref = $Refs->get_next(ST_JOURNAL);
+
+ $stock_gl_code = get_stock_gl_code($stock_id);
+ $memo = "WO labour cost settlement JV for zero/negative respository of ".$stock_id;
+ //Reverse the inventory effect if $qoh <=0
+ add_gl_trans_std_cost(ST_JOURNAL, $id, $date_,
+ $stock_gl_code["inventory_account"],
+ $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $memo,
+ -$costs);
+ //GL Posting to inventory adjustment account
+ add_gl_trans_std_cost(ST_JOURNAL, $id, $date_,
+ $stock_gl_code["assembly_account"], // changed 2015.10.14 from adjustment to assembly account. Petros.
+ $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $memo,
+ $costs);
+
+ add_audit_trail(ST_JOURNAL, $id, $date_);
+ add_comments(ST_JOURNAL, $id, $date_, $memo);
+ $Refs->save(ST_JOURNAL, $id, $ref);
+ if ($qty != 0) // 27.10.2014 dz
+ $labour_cost = ($qoh * $labour_cost + $costs) / $qty;
+ }
+ }
+ else
+ {
+ if ($qoh + $qty != 0)
+ $labour_cost = ($qoh * $labour_cost + $qty * $costs) / ($qoh + $qty);
+ }
+ $sql = "UPDATE ".TB_PREF."stock_master SET labour_cost=labour_cost+".db_escape($labour_cost)."
+ WHERE stock_id=".db_escape($stock_id);
+ db_query($sql,"The cost details for the inventory item could not be updated");
+}
+
+function add_issue_cost($stock_id, $qty, $date_, $costs, $adj_only=false)
+{
+ if ($qty != 0)
+ $costs /= $qty;
+ $sql = "SELECT material_cost FROM ".TB_PREF."stock_master WHERE stock_id = "
+ .db_escape($stock_id);
+ $result = db_query($sql);
+ $myrow = db_fetch($result);
+ $material_cost = $myrow['material_cost'];
+ $qoh = get_qoh_on_date($stock_id);
+ if ($qoh < 0)
+ $qoh = 0;
+ if ($adj_only)
+ {
+ if ($qoh>0)
+ $material_cost = ($qoh * $material_cost + $costs) / $qoh;
+ else // Journal Entry if QOH is 0/negative
+ {
+ global $Refs;
+
+ $id = get_next_trans_no(ST_JOURNAL);
+ $ref = $Refs->get_next(ST_JOURNAL);
+
+ $stock_gl_code = get_stock_gl_code($stock_id);
+ $memo = "WO Issue settlement JV for zero/negative respository of ".$stock_id;
+ //Reverse the inventory effect if $qoh <=0
+ add_gl_trans_std_cost(ST_JOURNAL, $id, $date_,
+ $stock_gl_code["inventory_account"],
+ $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $memo,
+ -$costs);
+ //GL Posting to inventory adjustment account
+ add_gl_trans_std_cost(ST_JOURNAL, $id, $date_,
+ $stock_gl_code["assembly_account"], // changed 2015.10.14 from adjustment to assembly account. Petros.
+ $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $memo,
+ $costs);
+
+ add_audit_trail(ST_JOURNAL, $id, $date_);
+ add_comments(ST_JOURNAL, $id, $date_, $memo);
+ $Refs->save(ST_JOURNAL, $id, $ref);
+ if ($qty != 0) // 27.10.2014 dz
+ $material_cost = $costs / $qty;
+ }
+ }
+ else
+ {
+ if ($qoh + $qty != 0)
+ $material_cost = ($qoh * $material_cost + $qty * $costs) / ($qoh + $qty);
+ }
+ $sql = "UPDATE ".TB_PREF."stock_master SET material_cost="
+ .db_escape($material_cost)
+ ." WHERE stock_id=".db_escape($stock_id);
+ db_query($sql,"The cost details for the inventory item could not be updated");
+}
+
function add_work_order($wo_ref, $loc_code, $units_reqd, $stock_id,
$type, $date_, $required_by, $memo_, $costs, $cr_acc, $labour, $cr_lab_acc)
{
$work_order = get_work_order($woid);
if (!($work_order["type"] == WO_ADVANCED))
{
- $date = sql2date($work_order['date_']);
- $qty = $work_order['units_reqd'];
- add_material_cost($work_order['stock_id'], -$qty, $date); // remove avg. cost for qty
- $cost = get_gl_wo_cost($woid, WO_LABOUR); // get the labour cost and reduce avg cost
- if ($cost != 0)
- add_labour_cost($work_order['stock_id'], -$qty, $date, $cost);
- $cost = get_gl_wo_cost($woid, WO_OVERHEAD); // get the overhead cost and reduce avg cost
- if ($cost != 0)
- add_overhead_cost($work_order['stock_id'], -$qty, $date, $cost);
-
$sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_reqd=0,units_issued=0 WHERE id = "
.db_escape($woid);
db_query($sql, "The work order couldn't be voided");
// void all related stock moves
void_stock_move(ST_WORKORDER, $woid);
- void_wo_costing($woid);
+ // void any related bank/gl trans
+ void_bank_trans(ST_WORKORDER, $woid, true);
// clear the requirements units received
void_wo_requirements($woid);
{
// void everything inside the work order : issues, productions, payments
$date = sql2date($work_order['date_']);
- add_material_cost($work_order['stock_id'], -$work_order['units_reqd'], $date); // remove avg. cost for qty
+
$result = get_work_order_productions($woid); // check the produced quantity
- $qty = 0;
while ($row = db_fetch($result))
{
- $qty += $row['quantity'];
- // clear the production record
- $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".$$row['id'];
- db_query($sql, "Cannot void a wo production");
-
- void_stock_move(ST_MANURECEIVE, $row['id']); // and void the stock moves;
+ void_work_order_produce($row['id']);
+
+ //Post voided entry if not prevoided explicitly
+ $void_entry = get_voided_entry(ST_MANURECEIVE, $row['id']);
+ if ($void_entry)
+ continue;
+ $memo_ = _("Voiding Work Order Trans # ").$woid;
+ add_audit_trail(ST_MANURECEIVE, $row['id'], today(), _("Voided.")."\n".$memo_);
+ add_voided_entry(ST_MANURECEIVE, $row['id'], today(), $memo_);
}
- $result = get_additional_issues($woid); // check the issued quantities
+
+ $result = get_work_order_issues($woid);
$cost = 0;
- $issue_no = 0;
while ($row = db_fetch($result))
{
- $std_cost = get_standard_cost($row['stock_id']);
- $icost = $std_cost * $row['qty_issued'];
- $cost += $icost;
- if ($issue_no == 0)
- $issue_no = $row['issue_no'];
- // void the actual issue items and their quantities
- $sql = "UPDATE ".TB_PREF."wo_issue_items SET qty_issued = 0 WHERE issue_id="
- .db_escape($row['id']);
- db_query($sql,"A work order issue item could not be voided");
- }
- if ($issue_no != 0)
- void_stock_move(ST_MANUISSUE, $issue_no); // and void the stock moves
- if ($cost != 0)
- add_issue_cost($work_order['stock_id'], -$qty, $date, $cost);
+ void_work_order_issue($row['issue_no']);
+
+ //Post voided entry if not prevoided explicitly
+ $void_entry = get_voided_entry(ST_MANUISSUE, $row['issue_no']);
+ if ($void_entry)
+ continue;
+ $memo_ = _("Voiding Work Order Trans # ").$woid;
+ add_audit_trail(ST_MANUISSUE, $row['issue_no'], today(), _("Voided.")."\n".$memo_);
+ add_voided_entry(ST_MANUISSUE, $row['issue_no'], today(), $memo_);
+ }
- $cost = get_gl_wo_cost($woid, WO_LABOUR); // get the labour cost and reduce avg cost
+ //Adust avg labour cost
+ $cost = get_gl_wo_cost($woid, WO_LABOUR);
if ($cost != 0)
- add_labour_cost($work_order['stock_id'], -$qty, $date, $cost);
- $cost = get_gl_wo_cost($woid, WO_OVERHEAD); // get the overhead cost and reduce avg cost
+ add_labour_cost($work_order['stock_id'], 1, $date, -$cost, true);
+
+ //Adust avg overhead cost
+ $cost = get_gl_wo_cost($woid, WO_OVERHEAD);
if ($cost != 0)
- add_overhead_cost($work_order['stock_id'], -$qty, $date, $cost);
+ add_overhead_cost($work_order['stock_id'], 1, $date, -$cost, true);
$sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_reqd=0,units_issued=0 WHERE id = "
.db_escape($woid);
// void all related stock moves
void_stock_move(ST_WORKORDER, $woid);
- void_wo_costing($wo);
+ // void any related bank/gl trans
+ void_bank_trans(ST_WORKORDER, $woid, true);
// clear the requirements units received
void_wo_requirements($woid);
// insert a -ve stock move for each item
$UnitCost = get_standard_cost($bom_item["component"]);
add_stock_move(ST_WORKORDER, $bom_item["component"], $woid,
- $bom_item["loc_code"], $date_, $wo_ref, -$item_quantity, $UnitCost, $UnitCost);
+ $bom_item["loc_code"], $date_, $wo_ref, -$item_quantity, $UnitCost, 0, 1, $UnitCost);
}
// -------------------------------------------------------------------------
$cost_adjust = true;
}
-
//Negative Stock Handling First; Prior to add_stock_move
if ($cost_adjust)
adjust_deliveries($stock_id, get_standard_cost($stock_id), $date_);
function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced=0, $costs=0, $cr_acc="", $labour=0, $cr_lab_acc="")
{
+ global $wo_cost_types;
$result = get_bom($stock_id);
// credit all the components
$total_cost = 0;
+ $total_material_cost = 0;
while ($bom_item = db_fetch($result))
{
$memo = $date_.": ".$memo;
update_wo_requirement_issued($woid, $bom_item['component'], $bom_item["quantity"] * $units_reqd);
// insert a -ve stock move for each item
+ $UnitCost = get_standard_cost($bom_item["component"]);
add_stock_move(ST_MANURECEIVE, $bom_item["component"], $advanced,
- $bom_item["loc_code"], $date_, "", -$bom_item["quantity"] * $units_reqd, 0);
+ $bom_item["loc_code"], $date_, "", -$bom_item["quantity"] * $units_reqd, $UnitCost, 0, 1, $UnitCost);
}
- $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $bom_accounts["inventory_account"], 0, 0,
+ //Compatibility for Service Items
+ if (!is_service($bom_accounts["mb_flag"]))
+ $ivaccount = $bom_accounts["inventory_account"];
+ else
+ $ivaccount = $bom_accounts["assembly_account"]; // changed 2015.10.14 by Petros .
+ $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $ivaccount, 0, 0,
$memo, -$bom_cost);
-
+ $total_material_cost += $bom_cost;
}
- $item_accounts = get_stock_gl_code($stock_id);
if ($advanced)
{
- $wo = get_work_order($woid);
- $lcost = get_gl_wo_cost($woid, WO_LABOUR);
- add_labour_cost($stock_id, $units_reqd, $date_, $lcost * $units_reqd / $wo['units_reqd']);
- $ocost = get_gl_wo_cost($woid, WO_OVERHEAD);
- add_overhead_cost($stock_id, $units_reqd, $date_, $ocost * $units_reqd / $wo['units_reqd']);
-
- } else { // only for quick
- // credit additional costs
-
- if ($costs != 0.0)
- {
- add_wo_costs_journal($woid, $costs, WO_OVERHEAD, $cr_acc, $item_accounts["assembly_account"],
- $date_, $item_accounts["dimension_id"], $item_accounts["dimension2_id"]);
- }
- if ($labour != 0.0) // only for quick
- {
- add_wo_costs_journal($woid, $labour, WO_LABOUR, $cr_lab_acc, $item_accounts["assembly_account"],
- $date_, $item_accounts["dimension_id"], $item_accounts["dimension2_id"]);
- }
+ //Material cost added at time of production as per BOM at the time and in adjustment mode.
+ add_material_cost($stock_id, $units_reqd, $date_, true, $woid);
+ // $wo = get_work_order($woid);
+ // also take the additional issues
+ // moved to work_order_issues_db.inc
+ } // credit additional costs
+ $item_accounts = get_stock_gl_code($stock_id);
+ if ($costs != 0.0)
+ {
+ add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $cr_acc,
+ 0, 0, $wo_cost_types[WO_OVERHEAD], -$costs, PT_WORKORDER, WO_OVERHEAD);
+ $is_bank_to = is_bank_account($cr_acc);
+ if ($is_bank_to)
+ {
+ add_bank_trans(ST_WORKORDER, $woid, $is_bank_to, "",
+ $date_, -$costs, PT_WORKORDER, WO_OVERHEAD, get_company_currency(),
+ "Cannot insert a destination bank transaction");
+ }
+
+ add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["assembly_account"],
+ $item_accounts["dimension_id"], $item_accounts["dimension2_id"], $wo_cost_types[WO_OVERHEAD], $costs,
+ PT_WORKORDER, WO_OVERHEAD);
+ }
+ if ($labour != 0.0) // only for quick
+ {
+ add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $cr_lab_acc,
+ 0, 0, $wo_cost_types[WO_LABOUR], -$labour, PT_WORKORDER, WO_LABOUR);
+ $is_bank_to = is_bank_account($cr_lab_acc);
+ if ($is_bank_to)
+ {
+ add_bank_trans(ST_WORKORDER, $woid, $is_bank_to, "",
+ $date_, -$labour, PT_WORKORDER, WO_LABOUR, get_company_currency(),
+ "Cannot insert a destination bank transaction");
+ }
+
+ add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["assembly_account"],
+ $item_accounts["dimension_id"], $item_accounts["dimension2_id"], $wo_cost_types[WO_LABOUR], $labour,
+ PT_WORKORDER, WO_LABOUR);
}
// debit total components $total_cost
$stockitem = get_item($stock_id);
$memo = $date_.": ".$memo;
add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["inventory_account"],
0, 0, $memo, -$total_cost);
+ if (!$advanced)
+ {
+ $UnitWOCost = ($total_material_cost + $costs + $labour)/$units_reqd;
+ update_stock_move(ST_WORKORDER, $woid, $stock_id, $UnitWOCost);
+ }
}
include_once($path_to_root . "/includes/db/manufacturing_db.inc");
include_once($path_to_root . "/manufacturing/includes/db/work_centres_db.inc");
include_once($path_to_root . "/manufacturing/includes/db/work_orders_db.inc");
-include_once($path_to_root . "/manufacturing/includes/db/work_order_costing_db.inc");
include_once($path_to_root . "/manufacturing/includes/db/work_orders_quick_db.inc");
include_once($path_to_root . "/manufacturing/includes/db/work_order_issues_db.inc");
include_once($path_to_root . "/manufacturing/includes/db/work_order_produce_items_db.inc");
alt_table_row_color($k);
label_cell(get_gl_view_str( $myrow["type"], $myrow["type_no"], $myrow["type_no"]));
- label_cell($wo_cost_types[$myrow['cost_type']]);
+ label_cell($wo_cost_types[$myrow['person_id']]);
$date = sql2date($myrow["tran_date"]);
label_cell($date);
amount_cell(-($myrow['amount']));
display_note(get_trans_view_str($stype, $id, _("View this Work Order")));
+ display_note(get_gl_view_str($stype, $id, _("View the GL Journal Entries for this Work Order")), 1);
+
hyperlink_params("work_order_costs.php", _("Enter another additional cost."), "trans_no=$id");
hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process"));
//--------------------------------------------------------------------------------------------------
-function can_process($wo_details)
+function can_process()
{
-
+ global $wo_details;
+
if (!check_num('costs', 0))
{
display_error(_("The amount entered is not a valid number or less then zero."));
//--------------------------------------------------------------------------------------------------
-if (isset($_POST['process']) && can_process($wo_details) == true)
+if (isset($_POST['process']) && can_process() == true)
{
$date = $_POST['date_'];
- $memo = $_POST['memo'];
- $ref = $_POST['ref'];
-
- add_wo_costs_journal($_POST['selected_id'], input_num('costs'), $_POST['PaymentType'],
- $_POST['cr_acc'], $_POST['db_acc'], $date, $_POST['dim1'], $_POST['dim2'], $memo, $ref);
+ begin_transaction();
+ add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['cr_acc'],
+ 0, 0, $date.": ".$wo_cost_types[$_POST['PaymentType']], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType']);
+ $is_bank_to = is_bank_account($_POST['cr_acc']);
+ if ($is_bank_to)
+ {
+ add_bank_trans(ST_WORKORDER, $_POST['selected_id'], $is_bank_to, "",
+ $_POST['date_'], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType'], get_company_currency(),
+ "Cannot insert a destination bank transaction");
+ }
+ add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['db_acc'],
+ $_POST['dim1'], $_POST['dim2'], $date.": ".$wo_cost_types[$_POST['PaymentType']], input_num('costs'), PT_WORKORDER,
+ $_POST['PaymentType']);
+
+ //Apply the costs to manfuctured stock item as adjustement
+ $wo = get_work_order($_POST['selected_id']);
+ if ($_POST['PaymentType'] == 0)
+ add_labour_cost($wo['stock_id'], $wo['units_reqd'], $_POST['date_'], input_num('costs'), true);
+ else
+ add_overhead_cost($wo['stock_id'], $wo['units_reqd'], $_POST['date_'], input_num('costs'), true);
+
+ commit_transaction();
meta_forward($_SERVER['PHP_SELF'], "AddedID=".$_POST['selected_id']);
}
if ($clearing_act)
$total += add_gl_trans_supplier(ST_SUPPRECEIVE, $grn, $date_, $stock_gl_code["inventory_account"],
$stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
- $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id, '', 0,
- $order_line->stock_id);
- update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price,
+ $order_line->taxfree_charge_value($po), $po->supplier_id, '', 0, $order_line->stock_id);
+ update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price,
$order_line->receive_qty, $date_);
}
//------------------------------------------------------------------------------------------------------
$po->line_items[$line_no]->grn_item_id = $grn_item;
/* Update location stock records - NB a po cannot be entered for a service/kit parts done automatically */
add_stock_move(ST_SUPPRECEIVE, $order_line->stock_id, $grn, $po->Location, $date_, "",
- $order_line->receive_qty, $order_line->standard_cost, $order_line->taxfree_charge_price($po));
+ $order_line->receive_qty, $order_line->standard_cost,
+ $po->supplier_id, 1, $order_line->taxfree_charge_value($po)/$order_line->receive_qty);
} /*quantity received is != 0 */
} /*end of order_line loop */
$this->grn_item_id = $grn_item_id;
}
- function taxfree_charge_price($po)
+ // Deprecated, use with care. If you need line value as it is calculated in invoice, use taxfree_charge_value below.
+ function taxfree_charge_price($po)
{
return get_tax_free_price_for_item($this->stock_id, $this->price,
$po->tax_group_id, $po->tax_included, $po->tax_group_array);
}
+
+ //
+ // GRN line tax free value.
+ //
+ function taxfree_charge_value($po)
+ {
+ return get_tax_free_price_for_item($this->stock_id, $this->receive_qty*$this->price,
+ $po->tax_group_id, $po->tax_included, $po->tax_group_array);
+ }
}
);
$return_text = strtr($text_to_convert, $htmlentities_table);
- if (version_compare(PHP_VERSION, '5.3.0') >= 0) // 07.11.2014, from php 5.3.0 fixed deprecated preg_replace with the /e flag. Joe.
- {
+ // 07.11.2014, from php 5.3.0 fixed deprecated preg_replace with the /e flag. Joe
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0 && function_exists("preg_replace_callback"))
+ {
$return_text = preg_replace_callback('~&#x([0-9a-f]+);~i', function ($m){ return chr(hexdec($m[1]));}, $return_text);
$return_text = preg_replace_callback('~&#([0-9]+);~', function ($m){ return chr($m[1]);}, $return_text);
}
}
$DisplaySubTot = number_format2($SubTotal,$dec);
- $DisplayFreight = number_format2($sign*$myrow["ov_freight"],$dec);
// set to start of summary line:
$rep->row = $summary_start_row;
$rep->TextCol(3, 6, _("Sub-total"), -2);
$rep->TextCol(6, 7, $DisplaySubTot, -2);
$rep->NewLine();
- $rep->TextCol(3, 6, _("Shipping"), -2);
- $rep->TextCol(6, 7, $DisplayFreight, -2);
- $rep->NewLine();
+ if ($myrow['ov_freight'] != 0.0)
+ {
+ $DisplayFreight = number_format2($sign*$myrow["ov_freight"],$dec);
+ $rep->TextCol(3, 6, _("Shipping"), -2);
+ $rep->TextCol(6, 7, $DisplayFreight, -2);
+ $rep->NewLine();
+ }
$tax_items = get_trans_tax_details(ST_SALESINVOICE, $row['trans_no']);
$first = true;
while ($tax_item = db_fetch($tax_items))
$rep->TextColLines(1, 5, $myrow['comments'], -2);
}
$DisplaySubTot = number_format2($SubTotal,$dec);
- $DisplayFreight = number_format2($myrow["freight_cost"],$dec);
$rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
$doctype = ST_SALESORDER;
$rep->TextCol(3, 6, _("Sub-total"), -2);
$rep->TextCol(6, 7, $DisplaySubTot, -2);
$rep->NewLine();
- $rep->TextCol(3, 6, _("Shipping"), -2);
- $rep->TextCol(6, 7, $DisplayFreight, -2);
- $rep->NewLine();
-
+ if ($myrow['ov_freight'] != 0.0)
+ {
+ $DisplayFreight = number_format2($myrow["freight_cost"],$dec);
+ $rep->TextCol(3, 6, _("Shipping"), -2);
+ $rep->TextCol(6, 7, $DisplayFreight, -2);
+ $rep->NewLine();
+ }
$DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec);
if ($myrow['tax_included'] == 0) {
$rep->TextCol(3, 6, _("TOTAL ORDER EX VAT"), - 2);
}
$DisplaySubTot = number_format2($SubTotal,$dec);
- $DisplayFreight = number_format2($myrow["ov_freight"],$dec);
$rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
$doctype=ST_CUSTDELIVERY;
$rep->TextCol(3, 6, _("Sub-total"), -2);
$rep->TextCol(6, 7, $DisplaySubTot, -2);
$rep->NewLine();
- $rep->TextCol(3, 6, _("Shipping"), -2);
- $rep->TextCol(6, 7, $DisplayFreight, -2);
- $rep->NewLine();
+ if ($myrow['ov_freight'] != 0.0)
+ {
+ $DisplayFreight = number_format2($sign*$myrow["ov_freight"],$dec);
+ $rep->TextCol(3, 6, _("Shipping"), -2);
+ $rep->TextCol(6, 7, $DisplayFreight, -2);
+ $rep->NewLine();
+ }
$tax_items = get_trans_tax_details(ST_CUSTDELIVERY, $i);
$first = true;
while ($tax_item = db_fetch($tax_items))
$rep->TextColLines(1, 5, $myrow['comments'], -2);
}
$DisplaySubTot = number_format2($SubTotal,$dec);
- $DisplayFreight = number_format2($myrow["freight_cost"],$dec);
$rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
$doctype = ST_SALESQUOTE;
$rep->TextCol(3, 6, _("Sub-total"), -2);
$rep->TextCol(6, 7, $DisplaySubTot, -2);
$rep->NewLine();
- $rep->TextCol(3, 6, _("Shipping"), -2);
- $rep->TextCol(6, 7, $DisplayFreight, -2);
- $rep->NewLine();
-
+ if ($myrow['ov_freight'] != 0.0)
+ {
+ $DisplayFreight = number_format2($myrow["freight_cost"],$dec);
+ $rep->TextCol(3, 6, _("Shipping"), -2);
+ $rep->TextCol(6, 7, $DisplayFreight, -2);
+ $rep->NewLine();
+ }
$DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec);
if ($myrow['tax_included'] == 0) {
$rep->TextCol(3, 6, _("TOTAL ORDER EX VAT"), - 2);
}
$DisplaySubTot = number_format2($SubTotal,$dec);
- $DisplayFreight = number_format2($sign*$myrow["ov_freight"],$dec);
$rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
$doctype = ST_CUSTCREDIT;
$rep->TextCol(3, 6, _("Sub-total"), -2);
$rep->TextCol(6, 7, $DisplaySubTot, -2);
$rep->NewLine();
- $rep->TextCol(3, 6, _("Shipping"), -2);
+ if ($myrow['ov_freight'] != 0.0)
+ {
+ $DisplayFreight = number_format2($sign*$myrow["ov_freight"],$dec);
+ $rep->TextCol(3, 6, _("Shipping"), -2);
+ $rep->TextCol(6, 7, $DisplayFreight, -2);
+ $rep->NewLine();
+ }
+ $rep->TextCol(3, 6, _("Shipping"), -2);
$rep->TextCol(6, 7, $DisplayFreight, -2);
$rep->NewLine();
$tax_items = get_trans_tax_details(ST_CUSTCREDIT, $i);
LEFT JOIN ".TB_PREF."tax_types tt
ON taxrec.tax_type_id=tt.id
LEFT JOIN ".TB_PREF."gl_trans gl
- ON taxrec.trans_type=gl.type AND taxrec.trans_no=gl.type_no AND
+ ON taxrec.trans_type=gl.type AND taxrec.trans_no=gl.type_no AND gl.amount<>0 AND
(tt.purchasing_gl_code=gl.account OR tt.sales_gl_code=gl.account)
LEFT JOIN ".TB_PREF."supp_trans strans
ON taxrec.trans_no=strans.trans_no AND taxrec.trans_type=strans.type
AND taxrec.tran_date >= '$fromdate'
AND taxrec.tran_date <= '$todate'
ORDER BY taxrec.trans_type, taxrec.tran_date, taxrec.trans_no, taxrec.ex_rate";
+
return db_query($sql,"No transactions were returned");
}
display_note(_("There are no line items on this credit note."), 1, 2);
$display_sub_tot = price_format($sub_total);
-$display_freight = price_format($myrow["ov_freight"]);
$credit_total = $myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"];
$display_total = price_format($credit_total);
if ($sub_total != 0)
label_row(_("Sub Total"), $display_sub_tot, "colspan=6 align=right",
"nowrap align=right width='15%'");
-label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
+if ($myrow["ov_freight"] != 0.0)
+{
+ $display_freight = price_format($myrow["ov_freight"]);
+ label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
+}
$tax_items = get_trans_tax_details(ST_CUSTCREDIT, $trans_id);
display_customer_trans_tax_details($tax_items, 6);
}
else
display_note(_("There are no line items on this dispatch."), 1, 2);
-
-$display_freight = price_format($myrow["ov_freight"]);
-
-label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
+if ($myrow['ov_freight'] != 0.0)
+{
+ $display_freight = price_format($myrow["ov_freight"]);
+ label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
+}
$tax_items = get_trans_tax_details(ST_CUSTDELIVERY, $trans_id);
display_customer_trans_tax_details($tax_items, 6);
else
display_note(_("There are no line items on this invoice."), 1, 2);
-$display_freight = price_format($myrow["ov_freight"]);
-
/*Print out the invoice text entered */
-label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
+if ($myrow['ov_freight'] != 0.0)
+{
+ $display_freight = price_format($myrow["ov_freight"]);
+ label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
+}
$tax_items = get_trans_tax_details(ST_SALESINVOICE, $trans_id);
display_customer_trans_tax_details($tax_items, 6);
end_row();
}
-label_row(_("Shipping"), price_format($_SESSION['View']->freight_cost),
- "align=right colspan=6", "nowrap align=right", 1);
+if ($_SESSION['View']->freight_cost != 0.0)
+ label_row(_("Shipping"), price_format($_SESSION['View']->freight_cost),
+ "align=right colspan=6", "nowrap align=right", 1);
$sub_tot = $_SESSION['View']->get_items_total() + $_SESSION['View']->freight_cost;