#!/usr/local/bin/perl package ActinicOrder; use strict; $::STARTSEQUENCE = -1; $::BILLCONTACTPHASE = 0; $::SHIPCONTACTPHASE = 1; $::SHIPCHARGEPHASE = 2; $::TAXCHARGEPHASE = 3; $::GENERALPHASE = 4; $::PAYMENTPHASE = 5; $::COMPLETEPHASE = 6; $::RECEIPTPHASE = 7; $::PRELIMINARYINFOPHASE = 8; $::PAYMENT_ON_ACCOUNT_LOWER = 964; $::PAYMENT_ON_ACCOUNT_UPPER = 965; $::eTaxAlways = 0; $::eTaxByInvoice = 1; $::eTaxByDelivery = 2; $ActinicOrder::ZERO = 0; $ActinicOrder::EXEMPT = 1; $ActinicOrder::TAX1 = 2; $ActinicOrder::TAX2 = 3; $ActinicOrder::BOTH = 4; $ActinicOrder::BOTH = $ActinicOrder::BOTH; $ActinicOrder::PRORATA = 5; $ActinicOrder::CUSTOM = 6; $ActinicOrder::PERCENTOFFSET = 10000; $ActinicOrder::TRUNCATION = 0; $ActinicOrder::SCIENTIFIC_DOWN = 1; $ActinicOrder::SCIENTIFIC_NORMAL = 2; $ActinicOrder::CEILING = 3; $ActinicOrder::ROUNDPERLINE = 0; $ActinicOrder::ROUNDPERITEM = 1; $ActinicOrder::ROUNDPERORDER = 2; $ActinicOrder::bTaxDataParsed = $::FALSE; $ActinicOrder::prog_name = 'ActinicOrder.pm'; $ActinicOrder::prog_name = $ActinicOrder::prog_name; $ActinicOrder::prog_ver = '$Revision: 429 $ '; $ActinicOrder::prog_ver = substr($ActinicOrder::prog_ver, 11); $ActinicOrder::prog_ver =~ s/ \$//; $ActinicOrder::UNDEFINED_REGION = "UndefinedRegion"; $ActinicOrder::REGION_NOT_SUPPLIED = '---'; $ActinicOrder::sPriceTemplate = ''; $ActinicOrder::PRICING_MODEL_STANDARD = 0; $ActinicOrder::PRICING_MODEL_COMP = 1; $ActinicOrder::PRICING_MODEL_PROD_COMP = 2; $ActinicOrder::VDSIMILARLINES = 1; $ActinicOrder::RETAILID = 1; $ActinicOrder::FROM_UNKNOWN = 0; $ActinicOrder::FROM_CART = 1; $ActinicOrder::FROM_CHECKOUT = 2; $ActinicOrder::s_nContext = $ActinicOrder::FROM_UNKNOWN; sub CallShippingPlugIn { no strict 'refs'; if ($::s_Ship_bRun) { return ( $::SUCCESS, '', \%::s_Ship_nShippingStatus, \%::s_Ship_sShippingError, $::s_Ship_bShipPhaseIsHidden, $::s_Ship_sShippingDescription, $::s_Ship_nShipCharges, \%::s_Ship_ShippingVariables, $::s_Ship_nHandlingCharges, $::s_Ship_sHandlingDescription, $::s_Ship_nShipOptions ); } my ($pCartList); if (defined $_[0]) { $pCartList = $_[0]; } if (defined $_[1]) { $::s_Ship_nSubTotal = $_[1]; } $::s_Ship_bDisplayPrices = $$::g_pSetupBlob{PRICES_DISPLAYED}; %::s_Ship_PriceFormatBlob = (); %::s_Ship_OpaqueDataTables = (); @::s_Ship_sShipProducts = (); @::s_Ship_nShipQuantities = (); @::s_Ship_nShipPrices = (); @::s_Ship_nShipSeparately = (); @::s_Ship_sShipCategories = (); @::s_Ship_nShipShipQuantities = (); @::s_Ship_nExcludeFromShipping = (); @::s_Ship_dShipSupplements = (); @::s_Ship_dShipSupplementOnce = (); @::s_Ship_dHandSupplements = (); @::s_Ship_dHandSupplementOnce = (); @::s_Ship_dShipAltWeights = (); @::s_Ship_bProduct = (); @::s_Ship_bSeparateLine = (); @::s_Ship_bParentExcluded = (); @::s_Ship_bUseAssociatedShip = (); my (@Response) = GetAdvancedShippingScript(ACTINIC::GetPath()); if ($Response[0] != $::SUCCESS) { return ( $Response[0], $Response[1], undef, undef, undef, undef, undef, undef, undef, undef, undef ); } my ($sScript) = $Response[2]; my ($Status, $Message); if (!defined $pCartList) { @Response = $::Session->GetCartObject(); if ($Response[0] != $::SUCCESS) { return (@Response); } my $pCartObject = $Response[2]; $pCartList = $pCartObject->GetCartList(); } @Response = ACTINIC::GetDigitalContent($pCartList, $::TRUE); if ($Response[0] == $::FAILURE) { return (@Response); } my %hDDLinks = %{$Response[2]}; my ($pOrderDetail, $pProduct, $nComponentCount); $::s_Ship_nTotalQuantity = 0; $nComponentCount = 0; foreach $pOrderDetail (@$pCartList) { my ($sSectionBlobName); ($Status, $Message, $sSectionBlobName) = ACTINIC::GetSectionBlobName($$pOrderDetail{SID}); if ($Status == $::FAILURE) { return ($Status, $Message); } @Response = ACTINIC::GetProduct($$pOrderDetail{"PRODUCT_REFERENCE"}, $sSectionBlobName, ACTINIC::GetPath()); ($Status, $Message, $pProduct) = @Response; if ($Status == $::NOTFOUND) { next; } if ($Status != $::SUCCESS) { return ( $Status, $Message, undef, undef, undef, undef, undef, undef, undef, undef, undef ); } $::s_Ship_nTotalQuantity += $$pOrderDetail{"QUANTITY"}; my $nEffectiveQuantity = EffectiveCartQuantity($pOrderDetail,$pCartList,\&IdenticalCartLines,undef); my $nPricingModel = $pProduct->{PRICING_MODEL}; my $sPrice; if ($nPricingModel == $ActinicOrder::PRICING_MODEL_COMP) { $sPrice = 0; } else { $sPrice = ActinicOrder::CalculateSchPrice($pProduct,$nEffectiveQuantity,$ACTINIC::B2B->Get('UserDigest')); } push (@::s_Ship_sShipProducts, $$pOrderDetail{"PRODUCT_REFERENCE"}); push (@::s_Ship_nShipQuantities, $$pOrderDetail{"QUANTITY"}); push (@::s_Ship_nShipPrices, $sPrice); push (@::s_Ship_nShipSeparately, $$pProduct{"SHIP_SEPARATELY"}); push (@::s_Ship_sShipCategories, $$pProduct{"SHIP_CATEGORY"}); push (@::s_Ship_nShipShipQuantities, $$pProduct{"SHIP_QUANTITY"}); push (@::s_Ship_nExcludeFromShipping, $$pProduct{"EXCLUDE_FROM_SHIP"}); push (@::s_Ship_dShipSupplements, $$pProduct{"SHIP_SUPPLEMENT"}); push (@::s_Ship_dShipSupplementOnce, $$pProduct{"SHIP_SUPPLEMENT_ONCE"}); push (@::s_Ship_dHandSupplements, $$pProduct{"HAND_SUPPLEMENT"}); push (@::s_Ship_dHandSupplementOnce, $$pProduct{"HAND_SUPPLEMENT_ONCE"}); push (@::s_Ship_dShipAltWeights, $$pProduct{"ALT_WEIGHT"}); push (@::s_Ship_bProduct, $::TRUE); push (@::s_Ship_bSeparateLine, $::TRUE); push (@::s_Ship_bParentExcluded, $::FALSE); push (@::s_Ship_bUseAssociatedShip, $::TRUE); $::s_Ship_OpaqueDataTables{$$pProduct{REFERENCE}} = $$pProduct{OPAQUE_SHIPPING_DATA}; if( $pProduct->{COMPONENTS} ) { my %CurrentItem = %$pOrderDetail; my $VariantList = GetCartVariantList(\%CurrentItem); my (%Component, $pComp); my $nIndex = 1; foreach $pComp (@{$pProduct->{COMPONENTS}}) { @Response = FindComponent($pComp,$VariantList); ($Status, %Component) = @Response; if ($Status != $::SUCCESS) { return ($Status,$Component{text}); } if( $Component{quantity} > 0 ) { my $sRef= $Component{code} && $pComp->[4] == 1 ? $Component{code} : $CurrentItem{"PRODUCT_REFERENCE"} . "_" . $nIndex; @Response = GetComponentPrice($Component{price},$nEffectiveQuantity,$Component{quantity}, undef, $sRef); if ($Response[0] != $::SUCCESS) { return (@Response); } if ($nPricingModel == $ActinicOrder::PRICING_MODEL_STANDARD) { $sPrice = 0; } else { $sPrice = $Response[2]; } $sRef= $Component{code} ? $Component{code} : $CurrentItem{"PRODUCT_REFERENCE"} . "_" . $nIndex; push (@::s_Ship_sShipProducts, $sRef); push (@::s_Ship_nShipQuantities, $$pOrderDetail{"QUANTITY"} * $Component{quantity}); push (@::s_Ship_nShipPrices, $sPrice); push (@::s_Ship_nShipSeparately, $Component{"SHIP_SEPARATELY"}); push (@::s_Ship_sShipCategories, $Component{"SHIP_CATEGORY"}); push (@::s_Ship_nShipShipQuantities, $Component{"SHIP_QUANTITY"}); push (@::s_Ship_nExcludeFromShipping, $Component{"EXCLUDE_FROM_SHIP"}); push (@::s_Ship_dShipSupplements, $Component{"SHIP_SUPPLEMENT"}); push (@::s_Ship_dShipSupplementOnce, $Component{"SHIP_SUPPLEMENT_ONCE"}); push (@::s_Ship_dHandSupplements, $Component{"HAND_SUPPLEMENT"}); push (@::s_Ship_dHandSupplementOnce, $Component{"HAND_SUPPLEMENT_ONCE"}); push (@::s_Ship_dShipAltWeights, $Component{"ALT_WEIGHT"}); push (@::s_Ship_bProduct, $::FALSE); push (@::s_Ship_bSeparateLine, $Component{'SeparateLine'}); push (@::s_Ship_bParentExcluded, $$pProduct{"EXCLUDE_FROM_SHIP"}); push (@::s_Ship_bUseAssociatedShip, $Component{'UseAssociatedShip'}); $::s_Ship_OpaqueDataTables{$sRef} = $Component{OPAQUE_SHIPPING_DATA}; $nComponentCount++; } $nIndex++; } } } if(defined $::g_InputHash{DELIVERPOSTALCODE}) { $::g_ShipContact{'POSTALCODE'} = $::g_InputHash{DELIVERPOSTALCODE}; } if(defined $::g_InputHash{DELIVERRESIDENTIAL}) { $::g_LocationInfo{'DELIVERRESIDENTIAL'} = $::g_InputHash{DELIVERRESIDENTIAL}; } $::s_Ship_sSSPOpaqueShipData = $::g_ShipInfo{'SSP'}; $::s_Ship_sOpaqueShipData = $::g_ShipInfo{'ADVANCED'}; $::s_Ship_sOpaqueHandleData = $::g_ShipInfo{HANDLING}; $::s_sDeliveryCountryCode = $::g_LocationInfo{DELIVERY_COUNTRY_CODE}; $::s_sDeliveryRegionCode = $::g_LocationInfo{DELIVERY_REGION_CODE}; %::s_Ship_PriceFormatBlob = %{$::g_pCatalogBlob}; if (eval($sScript) != $::SUCCESS) { return ( $::FAILURE, ACTINIC::GetPhrase(-1, 160, $@), undef, undef, undef, undef, undef, undef, undef, undef, undef ); } if ($@) { return($::FAILURE, ACTINIC::GetPhrase(-1, 160, $@)); } $::g_ShipInfo{'ADVANCED'} = $::s_Ship_sOpaqueShipData; $::g_ShipInfo{HANDLING} = $::s_Ship_sOpaqueHandleData; $::g_LocationInfo{DELIVERY_COUNTRY_CODE} = $::s_sDeliveryCountryCode; $::g_LocationInfo{DELIVERY_REGION_CODE} = $::s_sDeliveryRegionCode; $::g_ShipInfo{'SSP'} = $::s_Ship_sSSPOpaqueShipData; $::s_Ship_bRun = $::TRUE; return ( $::SUCCESS, '', \%::s_Ship_nShippingStatus, \%::s_Ship_sShippingError, $::s_Ship_bShipPhaseIsHidden, $::s_Ship_sShippingDescription, $::s_Ship_nShipCharges, \%::s_Ship_ShippingVariables, $::s_Ship_nHandlingCharges, $::s_Ship_sHandlingDescription, $::s_Ship_nShipOptions ); } sub GetAdvancedShippingScript { if (defined $ActinicOrder::s_sShippingScript)# if it is already in memory, { return ($::SUCCESS, "", $ActinicOrder::s_sShippingScript); } if ($#_ < 0) { return ($::FAILURE, ACTINIC::GetPhrase(-1, 12, 'GetAdvancedShippingScript'), 0, 0); } my ($sPath) = $_[0]; my ($sFilename) = $sPath . "ActinicShipping.fil"; my @Response = ACTINIC::ReadAndVerifyFile($sFilename); if ($Response[0] == $::SUCCESS) { $ActinicOrder::s_sShippingScript = $Response[2]; } return (@Response); } sub GenerateValidPayments { my ($parrMethods, $bValidateDelivery) = @_; if (!defined $bValidateDelivery) { $bValidateDelivery = $::FALSE; } my @arrFullList = @{$$::g_pPaymentList{'ORDER'}}; my %Lookup = GetPaymentsForLocation($bValidateDelivery); my $nMethodID; foreach $nMethodID (@arrFullList) { if ($$::g_pPaymentList{$nMethodID}{ENABLED}) { if ( $::g_pLocationList->{EXPECT_PAYMENT} && !$Lookup{$nMethodID}) { next; } push (@$parrMethods, $nMethodID); } } my $sDigest = $ACTINIC::B2B->Get('UserDigest'); if ( $sDigest ) { my @Response = ActinicOrder::GetAccountDefaultPaymentMethod($sDigest); if ($Response[0] != $::SUCCESS) { return(@Response); } if (!$Lookup{$Response[2]}) { push (@$parrMethods, $Response[2]); } } } sub GetPaymentsForLocation { my $bValidateDelivery = shift @_; if (!defined $bValidateDelivery) { $bValidateDelivery = $::TRUE; } my $nMethodID; my (%Invoice, %Intersection) = (); if (!$::g_pLocationList->{EXPECT_PAYMENT} ) { foreach $nMethodID (@{$$::g_pPaymentList{'ORDER'}}) { if ($$::g_pPaymentList{$nMethodID}{ENABLED}) { $Intersection{$nMethodID} = 1 } } return(%Intersection); } my @arrInvoiceList = @{$::g_pLocationList->{$::g_LocationInfo{INVOICE_COUNTRY_CODE}}->{ALLOWED_PAYMENT}}; foreach $nMethodID (@arrInvoiceList) { if ($$::g_pPaymentList{$nMethodID}{ENABLED}) { $Invoice{$nMethodID} = 1; } } if ($::g_BillContact{'SEPARATE'} && $bValidateDelivery && $::g_LocationInfo{DELIVERY_COUNTRY_CODE} && $::g_LocationInfo{DELIVERY_COUNTRY_CODE} ne '') { my @arrDeliveryList = @{$::g_pLocationList->{$::g_LocationInfo{DELIVERY_COUNTRY_CODE}}->{ALLOWED_PAYMENT}}; foreach $nMethodID (@arrDeliveryList) { if ( $Invoice{$nMethodID} && $$::g_pPaymentList{$nMethodID}{ENABLED}) { $Intersection{$nMethodID} = 1; } } return(%Intersection); } return(%Invoice); } sub GetDefaultPayment { my ($bUseRestored) = shift @_; if (!defined $bUseRestored) { $bUseRestored = $::TRUE; } if (0 < length $::g_PaymentInfo{METHOD} && $bUseRestored) { return($::g_PaymentInfo{METHOD}); } my $sDigest = $ACTINIC::B2B->Get('UserDigest'); if ( $sDigest ) { my @Response = ActinicOrder::GetAccountDefaultPaymentMethod($sDigest); if ($Response[0] == $::SUCCESS) { return($Response[2]); } } my $nMethodID; foreach $nMethodID (@{$$::g_pPaymentList{'ORDER'}}) { if ($$::g_pPaymentList{$nMethodID}{DEFAULT}) { return($nMethodID); } } return($::PAYMENT_UNDEFINED); } sub GeneratePaymentSelection { my $sHTML = ACTINIC::GetPhrase(-1, 1951); my @arrMethods; GenerateValidPayments(\@arrMethods, $::FALSE); my $nPaymentCount = @arrMethods; if (0 == $nPaymentCount) { my $nDefault = GetDefaultPayment($::FALSE); if ($nDefault == $::PAYMENT_UNDEFINED) { return($::FAILURE, ACTINIC::GetPhrase(-1, 1955)); } else { push (@arrMethods, $nDefault); $nPaymentCount++; } } if (1 == $nPaymentCount) { $sHTML = sprintf("%s", $arrMethods[0], $$::g_pPaymentList{$arrMethods[0]}{'PROMPT'}); } else { my $nDefault = GetDefaultPayment(@arrMethods); my $sSelectLine = ACTINIC::GetPhrase(-1, 1952); my $nMethodID; foreach $nMethodID (@arrMethods) { if ($nMethodID == $::PAYMENT_PAYPAL_PRO) { next; } if ($nMethodID == $nDefault) { $sHTML .= sprintf(ACTINIC::GetPhrase(-1, 1954), $nMethodID, $$::g_pPaymentList{$nMethodID}{'PROMPT'}); } else { $sHTML .= sprintf($sSelectLine, $nMethodID, $$::g_pPaymentList{$nMethodID}{'PROMPT'}); } } $sHTML .= ACTINIC::GetPhrase(-1, 1953); } return ($::SUCCESS, $sHTML); } sub PaymentStringToEnum { my ($sPayment) = @_; return($sPayment); } sub EnumToPaymentString { my ($ePayment) = @_; return($$::g_pPaymentList{$ePayment}{'PROMPT'}); } sub IsAccountSpecificPaymentMethod { my ($ePayment) = @_; return($$::g_pPaymentList{$ePayment}{'CUSTOMER_USE_ONLY'}); } sub IsCreditCardAvailable { if (GetDefaultPayment($::FALSE) == $::PAYMENT_CREDIT_CARD) { return($::TRUE); } my (@arrMethods, $nMethodID); GenerateValidPayments(\@arrMethods); foreach $nMethodID (@arrMethods) { if ($nMethodID == $::PAYMENT_CREDIT_CARD) { return($::TRUE); } } return($::FALSE); } sub CountUnregisteredCustomerPaymentOptions { my $nPaymentOptions = 0; my $nMethodID; foreach $nMethodID (@{$$::g_pPaymentList{'ORDER'}}) { if ($$::g_pPaymentList{$nMethodID}{ENABLED}) { $nPaymentOptions++; } } return ($nPaymentOptions); } sub GetAccountDefaultPaymentMethod { my ($sDigest) = @_; my ($Status, $Message, $pBuyer) = ACTINIC::GetBuyer($sDigest, ACTINIC::GetPath()); if ($Status != $::SUCCESS) { return ($Status, $Message); } my $pAccount; ($Status, $Message, $pAccount) = ACTINIC::GetCustomerAccount($$pBuyer{AccountID}, ACTINIC::GetPath()); if ($Status != $::SUCCESS) { return ($Status, $Message); } return($::SUCCESS, '', $pAccount->{DefaultPaymentMethod}); } sub ParseDelimiterStatus { if ($#_ != 0) { ACTINIC::ReportError(ACTINIC::GetPhrase(-1, 12, 'ParseDelimiterStatus'), ACTINIC::GetPath()); } my ($nPhase) = @_; undef @ACTINIC::s_DeleteRegions; undef @ACTINIC::s_KeepRegions; my ($sPrefix); if ($nPhase == $::BILLCONTACTPHASE) { $sPrefix = 'INVOICE'; } elsif ($nPhase == $::SHIPCONTACTPHASE) { $sPrefix = 'DELIVER'; } elsif ($nPhase == $::SHIPCHARGEPHASE) { $sPrefix = 'SHIP'; } elsif ($nPhase == $::TAXCHARGEPHASE) { $sPrefix = 'TAX'; } elsif ($nPhase == $::GENERALPHASE) { $sPrefix = 'GENERAL'; } elsif ($nPhase == $::PAYMENTPHASE) { $sPrefix = 'PAYMENT'; } elsif ($nPhase == $::COMPLETEPHASE) { $sPrefix = ''; } elsif ($nPhase == $::RECEIPTPHASE) { $sPrefix = ''; } elsif ($nPhase == $::PRELIMINARYINFOPHASE) { $sPrefix = ''; } my ($pPromptList) = $::g_PhraseIndex{$nPhase}; my $nPhraseID; my ($sDelimiter); foreach $nPhraseID (@$pPromptList) { my ($pBlob) = $$::g_pPromptList{"$nPhase,$nPhraseID"}; if (!defined $pBlob) { next; } $sDelimiter = sprintf('%sPROMPT%3.3d', $sPrefix, $nPhraseID); if ($nPhase == $::TAXCHARGEPHASE) { if ($nPhraseID == 0) { if(!defined $$::g_pTaxSetupBlob{TAX_1} || !$$::g_pTaxSetupBlob{TAX_1}{ALLOW_EXEMPT}) { $$pBlob{STATUS} = $::HIDDEN; } else { $$pBlob{STATUS} = $::OPTIONAL; } } elsif ($nPhraseID == 1) { if(!defined $$::g_pTaxSetupBlob{TAX_2} || !$$::g_pTaxSetupBlob{TAX_2}{ALLOW_EXEMPT}) { $$pBlob{STATUS} = $::HIDDEN; } else { $$pBlob{STATUS} = $::OPTIONAL; } } } elsif ($nPhase == $::SHIPCHARGEPHASE) { if ($nPhraseID == 0 && ( !$$::g_pSetupBlob{MAKE_SHIPPING_CHARGE} || !$$::g_pSetupBlob{PRICES_DISPLAYED})) { $$pBlob{STATUS} = $::HIDDEN; } } elsif ($nPhase == $::PAYMENTPHASE) { if (!IsCreditCardAvailable() || $$::g_pSetupBlob{USE_SHARED_SSL} || $$::g_pSetupBlob{USE_DH} ) { if ($nPhraseID > 0 && $nPhraseID < 6 || $nPhraseID == 8) { $$pBlob{STATUS} = $::HIDDEN; } } if ($nPhraseID == 0) { my $nPaymentOptions = CountUnregisteredCustomerPaymentOptions(); my $sDigest = $ACTINIC::B2B->Get('UserDigest'); if($sDigest ne '') { my ($nStatus, $sMessage, $nCustomerPaymentOption) = GetAccountDefaultPaymentMethod($sDigest); if($nStatus == $::SUCCESS && ActinicOrder::IsAccountSpecificPaymentMethod($nCustomerPaymentOption)) { $nPaymentOptions++; } } if ($nPaymentOptions < 1) { $$pBlob{STATUS} = $::HIDDEN; } } } if ($$pBlob{STATUS} == $::HIDDEN) { push (@ACTINIC::s_DeleteRegions, $sDelimiter); } else { push (@ACTINIC::s_KeepRegions, $sDelimiter); } } return (\@ACTINIC::s_DeleteRegions, \@ACTINIC::s_KeepRegions); } sub IsPhaseHidden { if ($#_ != 0) { ACTINIC::ReportError(ACTINIC::GetPhrase(-1, 12, 'ParseDelimiterStatus'), ACTINIC::GetPath()); } my ($nPhase) = @_; my ($bPlugInHidden); if ($nPhase == $::SHIPCHARGEPHASE) { my @Response = CallShippingPlugIn(); if ($Response[0] == $::SUCCESS && ${$Response[2]}{IsFinalPhaseHidden} == $::SUCCESS) { if ($Response[10] == 0) { return($::TRUE); } if (($Response[10] == 1) && ACTINIC::IsPromptHidden(2,1)) { return($::TRUE); } return($::FALSE); } } elsif ($nPhase == $::PRELIMINARYINFOPHASE) { return (!$$::g_pLocationList{EXPECT_DELIVERY} && !$$::g_pLocationList{EXPECT_INVOICE}) } elsif ($nPhase == $::TAXCHARGEPHASE) { my $bTax1Hidden = !defined $$::g_pTaxSetupBlob{TAX_1} || !$$::g_pTaxSetupBlob{'TAX_1'}{'ALLOW_EXEMPT'}; my $bTax2Hidden = !defined $$::g_pTaxSetupBlob{TAX_2} || !$$::g_pTaxSetupBlob{'TAX_2'}{'ALLOW_EXEMPT'}; return($bTax1Hidden && $bTax2Hidden); } my ($pPromptList) = $::g_PhraseIndex{$nPhase}; my $nPhraseID; foreach $nPhraseID (@$pPromptList) { my ($pBlob) = $$::g_pPromptList{"$nPhase,$nPhraseID"}; if (!defined $pBlob) { next; } if ($nPhase == $::PAYMENTPHASE) { if (!IsCreditCardAvailable() || $$::g_pSetupBlob{USE_SHARED_SSL} || $$::g_pSetupBlob{USE_DH} ) { if ($nPhraseID > 0 && $nPhraseID < 6 || $nPhraseID == 8) { $$pBlob{STATUS} = $::HIDDEN; } } if ($nPhraseID == 0) { my $nPaymentOptions = CountUnregisteredCustomerPaymentOptions(); my $sDigest = $ACTINIC::B2B->Get('UserDigest'); if($sDigest ne '') { my ($nStatus, $sMessage, $nCustomerPaymentOption) = GetAccountDefaultPaymentMethod($sDigest); if($nStatus == $::SUCCESS && ActinicOrder::IsAccountSpecificPaymentMethod($nCustomerPaymentOption)) { $nPaymentOptions++; } } if ($nPaymentOptions < 1) { $$pBlob{STATUS} = $::HIDDEN; } } } if ($$pBlob{'STATUS'} != $::HIDDEN) { return ($::FALSE); } } return ($::TRUE); } sub ValidateStart { if ($#_ != 0) { return ($::FAILURE, ACTINIC::GetPhrase(-1, 12, 'ValidateStart'), 0, 0); } my ($bActuallyValidate) = @_; if (!$bActuallyValidate) { return ($::SUCCESS, "", 0, 0); } my ($nLineCount, @Response, $Status, $Message); my $pCartObject; @Response = $::Session->GetCartObject(); if ($Response[0] != $::SUCCESS) { $nLineCount = 0; } else { $pCartObject = $Response[2]; $nLineCount = $pCartObject->CountItems(); } my ($sLocalPage, $sBaseUrl, $sHTML); if ($nLineCount <= 0) { $sLocalPage = $::Session->GetLastShopPage(); if (ACTINIC::IsCatalogFramed() || ($$::g_pSetupBlob{CLEAR_ALL_FRAMES} && $$::g_pSetupBlob{UNFRAMED_CHECKOUT})) { $sLocalPage = ACTINIC::RestoreFrameURL($sLocalPage); } @Response = ACTINIC::BounceToPageEnhanced(5, ACTINIC::GetPhrase(-1, 1962) . ACTINIC::GetPhrase(-1, 44, $::g_sCart, $::g_sCart) . ACTINIC::GetPhrase(-1, 1970) . ACTINIC::GetPhrase(-1, 2049), $$::g_pSetupBlob{CHECKOUT_DESCRIPTION}, $::g_sWebSiteUrl, $::g_sContentUrl, $::g_pSetupBlob, $sLocalPage, \%::g_InputHash, $::FALSE); ($Status, $Message, $sHTML) = @Response; if ($Status != $::SUCCESS) { return (@Response); } return ($::BADDATA, $sHTML, 0, 0); } my $pCartList = $pCartObject->GetCartList(); my $nIndex; foreach ($nIndex = $#$pCartList; $nIndex >= 0; $nIndex--) { my $pFailure; ($Status, $Message, $pFailure) = ActinicOrder::ValidateOrderDetails($pCartList->[$nIndex], $nIndex); if ($Status != $::SUCCESS) { my $sURL = $::g_sCartScript . "?ACTION=SHOWCART"; $sURL .= $::g_InputHash{SHOP} ? '&SHOP=' . ACTINIC::EncodeText2($::g_InputHash{SHOP}, $::FALSE) : ''; @Response = ACTINIC::BounceToPageEnhanced(5, ACTINIC::GetPhrase(-1, 1962) . ACTINIC::GetPhrase(-1, 2167) . ACTINIC::GetPhrase(-1, 1970) . ACTINIC::GetPhrase(-1, 2049), $$::g_pSetupBlob{CHECKOUT_DESCRIPTION}, $::g_sWebSiteUrl, $::g_sContentUrl, $::g_pSetupBlob, $sURL , \%::g_InputHash, $::FALSE); ($Status, $Message, $sHTML) = @Response; if ($Status != $::SUCCESS) { return (@Response); } return ($::BADDATA, $sHTML, 0, 0); } } ($Status, $sHTML) = ActinicOrder::CheckBuyerLimit($::g_sCartId,'',$::TRUE); if ($Status != $::SUCCESS) { return ($::BADDATA,$sHTML); } return ($::SUCCESS, "", 0, 0); } sub ValidatePreliminaryInfo { if ($#_ != 0) { return(ACTINIC::GetPhrase(-1, 12, 'ValidatePreliminaryInfo')); } if($$::g_pLocationList{EXPECT_NONE}) { return(''); } my ($bActuallyValidate) = @_; if(defined $::g_InputHash{'LocationInvoiceCountry'} || defined $::g_InputHash{'LocationDeliveryCountry'}) { $::g_LocationInfo{SEPARATESHIP} = $::g_InputHash{'SEPARATESHIP'}; } my $bSeparateShip = $::g_LocationInfo{SEPARATESHIP} ne ''; $::g_BillContact{'SEPARATE'} = $bSeparateShip; my $sOldInvoiceCountry = $::g_LocationInfo{INVOICE_COUNTRY_CODE}; my $sOldDeliveryCountry = $::g_LocationInfo{DELIVERY_COUNTRY_CODE}; if(defined $::g_InputHash{'LocationInvoiceCountry'}) { $::g_LocationInfo{INVOICE_COUNTRY_CODE} = $::g_InputHash{'LocationInvoiceCountry'}; $::g_LocationInfo{INVOICE_REGION_CODE} = $::g_InputHash{'LocationInvoiceRegion'}; } if(defined $::g_InputHash{'LocationDeliveryCountry'}) { $::g_LocationInfo{DELIVERY_COUNTRY_CODE} = $::g_InputHash{'LocationDeliveryCountry'}; $::g_LocationInfo{DELIVERY_REGION_CODE} = $::g_InputHash{'LocationDeliveryRegion'}; } if(defined $::g_InputHash{'LocationInvoiceCountry'} || defined $::g_InputHash{'LocationDeliveryCountry'}) { $::g_LocationInfo{DELIVERRESIDENTIAL} = $::g_InputHash{'DELIVERRESIDENTIAL'}; } if(defined $::g_InputHash{'DELIVERPOSTALCODE'}) { $::g_LocationInfo{DELIVERPOSTALCODE} = $::g_InputHash{'DELIVERPOSTALCODE'}; } if(defined $::g_InputHash{'INVOICERESIDENTIAL'}) { $::g_LocationInfo{INVOICERESIDENTIAL} = $::g_InputHash{'INVOICERESIDENTIAL'}; } if(defined $::g_InputHash{'INVOICEPOSTALCODE'}) { $::g_LocationInfo{INVOICEPOSTALCODE} = $::g_InputHash{'INVOICEPOSTALCODE'}; } if ($$::g_pLocationList{EXPECT_BOTH}) { if ($::g_LocationInfo{INVOICE_COUNTRY_CODE} && $::g_LocationInfo{DELIVERY_COUNTRY_CODE} eq '') { $::g_LocationInfo{DELIVERY_COUNTRY_CODE} = $::g_LocationInfo{INVOICE_COUNTRY_CODE}; } if ($::g_LocationInfo{INVOICE_COUNTRY_CODE} eq $::g_LocationInfo{DELIVERY_COUNTRY_CODE} && $::g_LocationInfo{INVOICE_REGION_CODE} ne $ActinicOrder::UNDEFINED_REGION && $::g_LocationInfo{DELIVERY_REGION_CODE} eq $ActinicOrder::UNDEFINED_REGION) { $::g_LocationInfo{DELIVERY_REGION_CODE} = $::g_LocationInfo{INVOICE_REGION_CODE}; } if(!$bSeparateShip) { if(defined $$::g_pLocationList{DELIVERPOSTALCODE} && $$::g_pLocationList{DELIVERPOSTALCODE} ne '' && $$::g_pLocationList{DELIVERPOSTALCODE} ne '' && !defined $$::g_pLocationList{INVOICEPOSTALCODE}) { $::g_LocationInfo{INVOICEPOSTALCODE} = $::g_LocationInfo{DELIVERPOSTALCODE}; } if((!defined $$::g_pLocationList{INVOICEADDRESS4} || $$::g_pLocationList{INVOICEADDRESS4}) && defined $$::g_pLocationList{DELIVERADDRESS4} && $$::g_pLocationList{DELIVERADDRESS4}) { $::g_LocationInfo{INVOICE_REGION_CODE} = $::g_LocationInfo{DELIVERY_REGION_CODE}; } } } if(!$bSeparateShip) { if($$::g_pLocationList{EXPECT_DELIVERY} && !$$::g_pLocationList{EXPECT_INVOICE}) { $::g_LocationInfo{INVOICE_COUNTRY_CODE} = $::g_LocationInfo{DELIVERY_COUNTRY_CODE}; $::g_LocationInfo{INVOICE_REGION_CODE} = $::g_LocationInfo{DELIVERY_REGION_CODE}; $::g_LocationInfo{INVOICEPOSTALCODE} = $::g_LocationInfo{DELIVERPOSTALCODE}; $::g_LocationInfo{INVOICERESIDENTIAL} = $::g_LocationInfo{DELIVERRESIDENTIAL}; } elsif(!$$::g_pLocationList{EXPECT_DELIVERY} && $$::g_pLocationList{EXPECT_INVOICE}) { $::g_LocationInfo{DELIVERY_COUNTRY_CODE} = $::g_LocationInfo{INVOICE_COUNTRY_CODE}; $::g_LocationInfo{DELIVERY_REGION_CODE} = $::g_LocationInfo{INVOICE_REGION_CODE}; $::g_LocationInfo{DELIVERPOSTALCODE} = $::g_LocationInfo{INVOICEPOSTALCODE}; $::g_LocationInfo{DELIVERRESIDENTIAL} = $::g_LocationInfo{INVOICERESIDENTIAL}; } } else { if($$::g_pLocationList{EXPECT_DELIVERY} && !$$::g_pLocationList{EXPECT_INVOICE}) { $::g_LocationInfo{INVOICE_COUNTRY_CODE} = ''; $::g_LocationInfo{INVOICE_REGION_CODE} = ''; } elsif(!$$::g_pLocationList{EXPECT_DELIVERY} && $$::g_pLocationList{EXPECT_INVOICE}) { $::g_LocationInfo{DELIVERY_COUNTRY_CODE} = ''; $::g_LocationInfo{DELIVERY_REGION_CODE} = ''; } } if ($sOldInvoiceCountry ne $::g_LocationInfo{INVOICE_COUNTRY_CODE}) { if ($$::g_pLocationList{EXPECT_INVOICE}) { if($::g_LocationInfo{INVOICE_COUNTRY_CODE} && $::g_LocationInfo{INVOICE_COUNTRY_CODE} ne $ActinicOrder::REGION_NOT_SUPPLIED) { $::g_BillContact{'COUNTRY'} = ACTINIC::GetCountryName($::g_LocationInfo{INVOICE_COUNTRY_CODE}); } } if (!$$::g_pLocationList{EXPECT_DELIVERY} && $::g_ShipContact{COUNTRY} eq ACTINIC::GetCountryName($sOldInvoiceCountry)) { if($::g_LocationInfo{INVOICE_COUNTRY_CODE} && $::g_LocationInfo{INVOICE_COUNTRY_CODE} ne $ActinicOrder::REGION_NOT_SUPPLIED) { $::g_ShipContact{'COUNTRY'} = ACTINIC::GetCountryName($::g_LocationInfo{INVOICE_COUNTRY_CODE}); } } } if ($sOldDeliveryCountry ne $::g_LocationInfo{DELIVERY_COUNTRY_CODE}) { if ($$::g_pLocationList{EXPECT_DELIVERY}) { if($::g_LocationInfo{DELIVERY_COUNTRY_CODE} && $::g_LocationInfo{DELIVERY_COUNTRY_CODE} ne $ActinicOrder::REGION_NOT_SUPPLIED) { $::g_ShipContact{COUNTRY} = ACTINIC::GetCountryName($::g_LocationInfo{DELIVERY_COUNTRY_CODE}); } } if (!$$::g_pLocationList{EXPECT_INVOICE} && !$bSeparateShip && $::g_BillContact{COUNTRY} eq ACTINIC::GetCountryName($sOldDeliveryCountry)) { if($::g_LocationInfo{DELIVERY_COUNTRY_CODE} && $::g_LocationInfo{DELIVERY_COUNTRY_CODE} ne $ActinicOrder::REGION_NOT_SUPPLIED) { $::g_BillContact{'COUNTRY'} = ACTINIC::GetCountryName($::g_LocationInfo{DELIVERY_COUNTRY_CODE}); } } } if ($$::g_pLocationList{EXPECT_DELIVERY} && $$::g_pLocationList{EXPECT_INVOICE}) { if ($::g_LocationInfo{INVOICE_COUNTRY_CODE} ne $::g_LocationInfo{DELIVERY_COUNTRY_CODE} || $::g_LocationInfo{INVOICE_REGION_CODE} ne $::g_LocationInfo{DELIVERY_REGION_CODE}) { } } if (($::g_LocationInfo{DELIVERY_COUNTRY_CODE} ne $::g_LocationInfo{INVOICE_COUNTRY_CODE}) && ($::g_LocationInfo{INVOICE_COUNTRY_CODE} eq $ActinicOrder::REGION_NOT_SUPPLIED) && !$bSeparateShip) { $::g_LocationInfo{INVOICE_COUNTRY_CODE} = $::g_LocationInfo{DELIVERY_COUNTRY_CODE}; } my ($sError); if (!$bActuallyValidate) { return ($sError); } if ($$::g_pLocationList{EXPECT_BOTH}) { if (($::g_LocationInfo{DELIVERY_COUNTRY_CODE} ne $::g_LocationInfo{INVOICE_COUNTRY_CODE}) && ($::g_LocationInfo{INVOICE_COUNTRY_CODE} ne $ActinicOrder::REGION_NOT_SUPPLIED) && !$bSeparateShip) { $sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 171) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". ACTINIC::GetPhrase(-1, 2068) . "
\n"; } elsif ($::g_LocationInfo{DELIVERY_REGION_CODE} ne $::g_LocationInfo{INVOICE_REGION_CODE} && (exists $$::g_pLocationList{INVOICEADDRESS4} && $$::g_pLocationList{INVOICEADDRESS4} && exists $$::g_pLocationList{DELIVERADDRESS4} && $$::g_pLocationList{DELIVERADDRESS4}) && !$bSeparateShip) { $sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 171) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". ACTINIC::GetPhrase(-1, 2069) . "
\n"; } elsif ($::g_LocationInfo{DELIVERY_COUNTRY_CODE} eq $::g_LocationInfo{INVOICE_COUNTRY_CODE} && $::g_LocationInfo{INVOICE_COUNTRY_CODE} eq $ActinicOrder::REGION_NOT_SUPPLIED) { $sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 171) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". ACTINIC::GetPhrase(-1, 2273) . "
\n"; } } if ($$::g_pLocationList{EXPECT_INVOICE}) { if ($::g_LocationInfo{INVOICE_COUNTRY_CODE} eq '') { $sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 191) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". ACTINIC::GetPhrase(-1, 195) . "
\n"; } if ($::g_LocationInfo{INVOICE_COUNTRY_CODE} ne '' && $::g_LocationInfo{INVOICE_COUNTRY_CODE} ne $ActinicOrder::REGION_NOT_SUPPLIED && # not the 'None of the above' is selected $::g_LocationInfo{INVOICE_REGION_CODE} ne $ActinicOrder::UNDEFINED_REGION && $::g_LocationInfo{INVOICE_REGION_CODE} !~ /^$::g_LocationInfo{INVOICE_COUNTRY_CODE}\./) { $sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 191) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". ACTINIC::GetPhrase(-1, 196) . "
\n"; } } if ($$::g_pLocationList{EXPECT_DELIVERY}) { if ($::g_LocationInfo{DELIVERY_COUNTRY_CODE} eq '') { $sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 171) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". ACTINIC::GetPhrase(-1, 195) . "
\n"; } if ($::g_LocationInfo{DELIVERY_COUNTRY_CODE} ne '' && $::g_LocationInfo{DELIVERY_REGION_CODE} ne $ActinicOrder::UNDEFINED_REGION && $::g_LocationInfo{DELIVERY_REGION_CODE} !~ /^$::g_LocationInfo{DELIVERY_COUNTRY_CODE}\./) { $sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 171) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - ". ACTINIC::GetPhrase(-1, 196) . "
\n"; } } my $sDigest = $ACTINIC::B2B->Get('UserDigest'); if($sDigest ne '') { my ($Status, $sMessage, $pBuyer, $pAccount) = ACTINIC::GetBuyerAndAccount($sDigest, ACTINIC::GetPath()); if ($Status != $::SUCCESS) { $sError .= $sMessage; } my ($pAddress, $plistValidAddresses, $plistValidInvoiceAddresses, $plistValidDeliveryAddresses); ($Status, $sMessage, $plistValidInvoiceAddresses, $plistValidDeliveryAddresses) = ACTINIC::GetCustomerAddressLists($pBuyer, $pAccount); if ($Status != $::SUCCESS) { $sError .= $sMessage; } my $sRegion; if($#$plistValidInvoiceAddresses == -1 && ($pAccount->{InvoiceAddressRule} == 1 || $pBuyer->{InvoiceAddressRule} != 2)) { if($::g_LocationInfo{INVOICE_REGION_CODE} eq $ActinicOrder::UNDEFINED_REGION) { $sRegion = ACTINIC::GetCountryName($::g_LocationInfo{INVOICE_COUNTRY_CODE}); } else { $sRegion = ACTINIC::GetCountryName($::g_LocationInfo{INVOICE_REGION_CODE}); } $sError .= ACTINIC::GetPhrase(-1, 1949, $sRegion) . "
"; } if($#$plistValidDeliveryAddresses == -1 && ($pBuyer->{DeliveryAddressRule} != 2)) { if($::g_LocationInfo{DELIVERY_REGION_CODE} eq $ActinicOrder::UNDEFINED_REGION) { $sRegion = ACTINIC::GetCountryName($::g_LocationInfo{DELIVERY_COUNTRY_CODE}); } else { $sRegion = ACTINIC::GetCountryName($::g_LocationInfo{DELIVERY_REGION_CODE}); } $sError .= ACTINIC::GetPhrase(-1, 1950, $sRegion) . "
"; } if($sError eq '') { my $plistValidTaxableAddresses; if ($$::g_pTaxSetupBlob{TAX_BY} != $::eTaxByDelivery) { $plistValidTaxableAddresses = $plistValidInvoiceAddresses; } else { $plistValidTaxableAddresses = $plistValidDeliveryAddresses; } SetCustomerTaxExemption($plistValidTaxableAddresses); } ACTINIC::CloseCustomerAddressIndex(); # The customer index is left open for multiple access, so clean it up here } if(exists $$::g_pLocationList{INVOICEPOSTALCODE} && $$::g_pLocationList{INVOICEPOSTALCODE} && $::g_LocationInfo{INVOICEPOSTALCODE} eq '') { $sError .= ACTINIC::GetRequiredMessage(0, 8); } if(exists $$::g_pLocationList{DELIVERPOSTALCODE} && $$::g_pLocationList{DELIVERPOSTALCODE} && $::g_LocationInfo{DELIVERPOSTALCODE} eq '') { $sError .= ACTINIC::GetRequiredMessage(1, 8); } if (!$sError) { if ($$::g_pSetupBlob{'MAKE_SHIPPING_CHARGE'}) { my ($nStatus, $sMessage, $pCartObject) = $::Session->GetCartObject(); if($nStatus == $::SUCCESS) { my @Response = $pCartObject->SummarizeOrder($::FALSE); if ($Response[0] != $::SUCCESS) { $sMessage = $Response[1]; } else { @Response = $pCartObject->GetShippingPluginResponse(); if (${$Response[2]}{ValidatePreliminaryInput} != $::SUCCESS) { $sMessage = ${$Response[3]}{ValidatePreliminaryInput}; } elsif (${$Response[2]}{ValidateFinalInput} != $::SUCCESS) { $sMessage = ${$Response[3]}{ValidateFinalInput}; } } } if($sMessage ne '') { $sError .= ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . ACTINIC::GetPhrase(-1, 171) . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970) . " - " . $sMessage . "
\n"; } } } if ($sError ne "") { $sError = ACTINIC::GetPhrase(-1, 1974) . ACTINIC::GetPhrase(-1, 1971, $::g_sRequiredColor) . $sError . ACTINIC::GetPhrase(-1, 1975) . ACTINIC::GetPhrase(-1, 1970); } return ($sError); } sub SetCustomerTaxExemption { my ($plistValidTaxableAddresses) = @_; if($#$plistValidTaxableAddresses == -1) { return; } my (%hTax1ID, %hTax2ID, %hTax1Exempt, %hTax2Exempt, %hTax1ExemptionData, %hTax2ExemptionData); my $pAddress; foreach $pAddress (@$plistValidTaxableAddresses) { $hTax1ID{$pAddress->{Tax1ID}} = 0; $hTax1Exempt{$pAddress->{ExemptTax1}} = 0; $hTax1ExemptionData{$pAddress->{Tax1ExemptData}} = 0; $hTax2ID{$pAddress->{Tax2ID}} = 0; $hTax2Exempt{$pAddress->{ExemptTax2}} = 0; $hTax2ExemptionData{$pAddress->{Tax2ExemptData}} = 0; } my($nTaxID, $bTaxExempt, $sTaxExemptionData); $pAddress = $plistValidTaxableAddresses->[0]; if(keys %hTax1ID == 1 && keys %hTax1Exempt == 1 && keys %hTax1ExemptionData == 1 && $pAddress->{Tax1ID} != -1) { $::g_TaxInfo{'EXEMPT1'} = $pAddress->{'ExemptTax1'} ? 1 : 0; $::g_TaxInfo{'EXEMPT1DATA'} = $pAddress->{'Tax1ExemptData'}; } else { $::g_TaxInfo{'EXEMPT1'} = 0; $::g_TaxInfo{'EXEMPT1DATA'} = ''; } if(keys %hTax2ID == 1 && keys %hTax2Exempt == 1 && keys %hTax2ExemptionData == 1 && $pAddress->{Tax2ID} != -1) { $::g_TaxInfo{'EXEMPT2'} = $pAddress->{'ExemptTax2'} ? 1 : 0; $::g_TaxInfo{'EXEMPT2DATA'} = $pAddress->{'Tax2ExemptData'}; } else { $::g_TaxInfo{'EXEMPT2'} = 0; $::g_TaxInfo{'EXEMPT2DATA'} = ''; } } sub ValidateTax { if ($#_ < 0) { ACTINIC::ReportError(ACTINIC::GetPhrase(-1, 12, 'ValidateTax'), ACTINIC::GetPath()); } my ($bActuallyValidate) = $_[0]; my ($bCheckout) = $::TRUE; if ($#_ == 1) { $bCheckout = $_[1]; } my @Response = ParseAdvancedTax(); if ($Response[0] != $::SUCCESS) { return($Response[1]); } my $bTaxAndShipEarly = $$::g_pSetupBlob{'TAX_AND_SHIP_EARLY'}; my $bNoTaxesEnabled = !(defined $$::g_pTaxSetupBlob{'TAX_1'} || defined $$::g_pTaxSetupBlob{'TAX_2'}); if ($bNoTaxesEnabled || $bCheckout) { $::g_TaxInfo{'DONE'} = $::TRUE; } if (IsPhaseDone($::TAXCHARGEPHASE) || !$bCheckout || $bNoTaxesEnabled) { return(''); } if(!$::g_InputHash{ADDRESSSELECT} ) { $::g_TaxInfo{'EXEMPT1'} = ($::g_InputHash{'TAXEXEMPT1'} eq "" ? $::FALSE : $::TRUE); $::g_TaxInfo{'EXEMPT2'} = ($::g_InputHash{'TAXEXEMPT2'} eq "" ? $::FALSE : $::TRUE); if (defined $::g_InputHash{'TAXEXEMPT1DATA'}) { $::g_TaxInfo{'EXEMPT1DATA'} = $::g_InputHash{'TAXEXEMPT1DATA'}; } else { $::g_TaxInfo{'EXEMPT1DATA'} = ""; } if(defined $::g_InputHash{'TAXEXEMPT2DATA'}) { $::g_TaxInfo{'EXEMPT2DATA'} = $::g_InputHash{'TAXEXEMPT2DATA'}; } else { $::g_TaxInfo{'EXEMPT2DATA'} = ""; } } $::g_TaxInfo{'USERDEFINED'} = $::g_InputHash{'TAXUSERDEFINED'}; ACTINIC::TrimHashEntries(\%::g_TaxInfo); my ($sError, $nTax); if (!$bActuallyValidate) { return ($sError); } foreach $nTax (1 .. 2) { $sError .= CheckTaxExemption($nTax); } if (ACTINIC::IsPromptRequired(3, 2) && $::g_TaxInfo{'USERDEFINED'} eq "") { $sError .= ACTINIC::GetRequiredMessage(3, 2); } if ($sError ne "") { $sError = "" . ACTINIC::GetPhrase(-1, 150) . "" . ACTINIC::GetPhrase(-1, 1961, $sError); } return ($sError); } sub IsTaxInfoChanged { my $sTaxDump = (join "|", keys %::g_TaxInfo) . (join "|", values %::g_TaxInfo); if ($::g_sTaxDump ne $sTaxDump) { $::g_sTaxDump = $sTaxDump; return $::TRUE; } return $::FALSE; } sub IsShippingInfoChanged { my $sShippingDump = (join "|", keys %::g_ShipInfo) . (join "|", values %::g_ShipInfo); if ($::g_sShippingDump ne $sShippingDump) { $::g_sShippingDump = $sShippingDump; return $::TRUE; } return $::FALSE; } sub TaxIsKnown { if ($$::g_pTaxSetupBlob{TAX_BY} != $::eTaxAlways) { my $sKeyPrefix = ($$::g_pTaxSetupBlob{TAX_BY} == $::eTaxByInvoice) ? 'INVOICE_' : 'DELIVERY_'; my ($sTargetCountry, $sTargetRegion); $sTargetCountry = $::g_LocationInfo{$sKeyPrefix . 'COUNTRY_CODE'}; $sTargetRegion = $::g_LocationInfo{$sKeyPrefix . 'REGION_CODE'}; if($sTargetCountry eq '') { return($::FALSE); } } return($::g_TaxInfo{'DONE'} == $::TRUE); } sub CheckTaxExemption { my ($nTax) = @_; my ($sExemptKey, $sExemptDataKey); $sExemptKey = 'EXEMPT' . $nTax; $sExemptDataKey = $sExemptKey . 'DATA'; if($::g_pTaxSetupBlob->{MODEL} == 1 && $::g_TaxInfo{$sExemptKey} && defined $::g_TaxInfo{$sExemptDataKey}) { if($::g_TaxInfo{$sExemptDataKey} eq '') { return(ACTINIC::GetPhrase(-1, 298)); } } return(''); } sub DisplayPreliminaryInfoPhase { my ($bCheckout) = $::TRUE; if ($#_ == 0) { $bCheckout = $_[0]; } undef %ActinicOrder::s_VariableTable; undef %ActinicOrder::s_SelectTable; undef @ActinicOrder::s_DeleteDelimiters; undef @ActinicOrder::s_KeepDelimiters; my $bLocationPageNotApplicable = (!$bCheckout && !$$::g_pSetupBlob{'TAX_AND_SHIP_EARLY'}) || ($bCheckout && $$::g_pSetupBlob{'TAX_AND_SHIP_EARLY'} && $::g_InputHash{ACTION} eq ACTINIC::GetPhrase(-1, 113)); # and this isn't the start page if (IsPhaseComplete($::PRELIMINARYINFOPHASE) || $bLocationPageNotApplicable || !($$::g_pLocationList{EXPECT_DELIVERY} || $$::g_pLocationList{EXPECT_INVOICE}) || IsPhaseHidden($::PRELIMINARYINFOPHASE)) { push (@ActinicOrder::s_DeleteDelimiters, 'PRELIMINARYINFORMATION'); return ($::SUCCESS, '', \%ActinicOrder::s_VariableTable, \@ActinicOrder::s_DeleteDelimiters, \@ActinicOrder::s_KeepDelimiters); } else { push (@ActinicOrder::s_KeepDelimiters, 'PRELIMINARYINFORMATION'); } if (0 < length $::g_LocationInfo{INVOICE_COUNTRY_CODE}) { $ActinicOrder::s_SelectTable{LocationInvoiceCountry} = $::g_LocationInfo{INVOICE_COUNTRY_CODE}; } if (0 < length $::g_LocationInfo{INVOICE_REGION_CODE}) { $ActinicOrder::s_SelectTable{LocationInvoiceRegion} = $::g_LocationInfo{INVOICE_REGION_CODE}; } if (0 < length $::g_LocationInfo{DELIVERY_COUNTRY_CODE}) { $ActinicOrder::s_SelectTable{LocationDeliveryCountry} = $::g_LocationInfo{DELIVERY_COUNTRY_CODE}; } if (0 < length $::g_LocationInfo{DELIVERY_REGION_CODE}) { $ActinicOrder::s_SelectTable{LocationDeliveryRegion} = $::g_LocationInfo{DELIVERY_REGION_CODE}; } $ActinicOrder::s_VariableTable{'NETQUOTEVAR:DELIVERPOSTALCODE'} = $::g_LocationInfo{'DELIVERPOSTALCODE'}; $ActinicOrder::s_VariableTable{'NETQUOTEVAR:DELIVERRESIDENTIAL'} = $::g_LocationInfo{'DELIVERRESIDENTIAL'} ? 'CHECKED' : ''; $ActinicOrder::s_VariableTable{'NETQUOTEVAR:INVOICESEPARATECHECKSTATUS'} = $::g_LocationInfo{'SEPARATESHIP'} ? 'CHECKED' : ''; if ((scalar keys %::ActinicOrder::s_VariableTable) == 0) { $ActinicOrder::s_VariableTable{"