Created
March 9, 2015 10:40
-
-
Save johanlunds/74bef4c4eaa2685845ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/suitescripts/models/customer.js.coffee b/suitescripts/models/customer.js.coffee | |
index d361731..e736bcd 100644 | |
--- a/suitescripts/models/customer.js.coffee | |
+++ b/suitescripts/models/customer.js.coffee | |
@@ -18,8 +18,8 @@ Hook.get('lead').validate('phone', Validator.phone) | |
Hook.get('prospect').rewrite('custentity_ssn', Validator.rewrite_org_ssn) | |
Hook.get('prospect').validate('custentity_ssn', Validator.org_ssn) | |
-Hook.get('prospect').validate(Validator.at_least_one_address) | |
-Hook.get('prospect').validate(Validator.address) | |
+Hook.get('prospect').validate(Validator.at_least_one_address) # TODO: error blir här? | |
+Hook.get('prospect').validate(Validator.address) # TODO: error blir här? | |
Hook.get('prospect').validate('phone', Validator.phone) | |
@@ -40,7 +40,7 @@ set_default_price_level = (department) -> | |
F().set('pricelevel', S.pricelevel.wholesale) | |
else if F().val('customform') == S.customform.dialysis_customer | |
# Not that his runs in the UI when changing the form in the UI | |
- # The default is SLL and an department must be explicitly selected to | |
+ # The default is SLL and an department must be explicitly selected to | |
# get anything else than SLL | |
F().set('pricelevel', S.pricelevel.sll) | |
F().set('pricelevel', S.pricelevel.base) if department? and department != S.department.sll | |
@@ -48,6 +48,7 @@ set_default_price_level = (department) -> | |
F().set('pricelevel', S.pricelevel.special) | |
Hook.get('customer').add 'before_load', 'Set default values', ['create'], -> | |
+ G.debug("H3: BEFORE LOAD DEFAULT VS") | |
F().default('terms', 1) | |
set_default_price_level(F().val('custentity_department')) | |
@@ -67,6 +68,7 @@ Hook.get('prospect') | |
G.merge_attach_send F(), S.email.customer.new, F().val('custentity_not_signed_agreement') | |
Hook.get('customer').add 'before_load', 'Set default values for dialysis customers', ['create'], -> | |
+ G.debug("H4: DEF VALUES DIALYS CUST") | |
if F().val('customform') == S.customform.dialysis_customer | |
# Random 8 character password | |
@@ -85,4 +87,3 @@ Hook.get('customer').add 'before_submit', 'set SLL item pricing for dialysis cus | |
F().sublists 'itempricing', ['level'], (line,i) -> | |
if F().val('custentity_department') == S.department.sll | |
{level: S.pricelevel.sll} | |
- | |
diff --git a/suitescripts/models/sales_order.js.coffee b/suitescripts/models/sales_order.js.coffee | |
index e6f7b13..2d65b0e 100644 | |
--- a/suitescripts/models/sales_order.js.coffee | |
+++ b/suitescripts/models/sales_order.js.coffee | |
@@ -32,8 +32,10 @@ Hook.get('salesorder').add 'before_submit', 'Set location to Apotek for PH order | |
# This is also set when auto approvning orders since that is run as a | |
# before_submit hook making this check useless for such orders | |
Hook.get('salesorder').add 'after_submit', 'Set closed Won (from potentially lost)', ['approve'], -> | |
+ G.debug("TEST JOHAN TEST") | |
customer = G.load_record('customer', F().val('entity')) | |
if F(customer).val('entitystatus') == S.entitystatus.potentially_lost | |
+ G.debug("H1: SETTING TO CLOSED WON") | |
F(customer).update(entitystatus: S.entitystatus.closed_won) | |
@@ -98,6 +100,7 @@ Hook.get('salesorder').add 'before_submit', 'Automatically approve order', ['cre | |
# Potentially Lost management for auto approved orders | |
customer = G.load_record('customer', F().val('entity')) | |
if F(customer).val('entitystatus') == S.entitystatus.potentially_lost | |
+ G.debug("H2: SETTING TO CLOSED WON") | |
F(customer).update(entitystatus: S.entitystatus.closed_won) | |
unless F().val('department') == S.department.sll | |
@@ -179,4 +182,3 @@ Hook.get('salesorder').add 'before_submit', 'Set GLN for dialysis orders', ['cre | |
parse_gln(a.label) if parse_gln(a.label) | |
glns = glns.filter (gln) -> gln | |
F().default('custbody_consignee_gln', glns[0]) if glns.length > 0 | |
- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment