Skip to content

Commit

Permalink
Merge pull request #101 from Coral-erm/pr63
Browse files Browse the repository at this point in the history
Pr63
  • Loading branch information
jsavell authored Aug 26, 2016
2 parents 2b71c3e + 65ff3dc commit 7dbcbea
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 18 deletions.
36 changes: 31 additions & 5 deletions resources/ajax_forms/getCostForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
// Table geometry is different if enhanced cost history is enabled
$baseWidth = 345;
$numCols = 6;
if ($enhancedCostFlag)
{
$baseWidth += 388;
$numCols += 5; // year, sub start, sub end, cost details, invoice num
if ($enhancedCostFlag){
$baseWidth += 688;
$numCols += 8; // year, sub start, sub end, cost details, invoice num
}

?>

<div id='div_resourceForm'>
Expand All @@ -69,6 +69,11 @@
<th><?php echo _("Sub End");?></th>
<?php } ?>
<th><?php echo _("Fund");?></th>
<?php if ($enhancedCostFlag){ ?>
<th><?php echo _("Tax Excl.");?></th>
<th><?php echo _("Tax Rate");?></th>
<th><?php echo _("Tax Incl.");?></th>
<?php } ?>
<th><?php echo _("Payment");?></th>
<th><?php echo _("Currency");?></th>
<th><?php echo _("Type");?></th>
Expand Down Expand Up @@ -111,9 +116,20 @@
?>
</select>
</td>
<?php if ($enhancedCostFlag){ ?>
<td>
<input type='text' value='' style='width:60px;' class='changeDefaultWhite changeInput priceTaxExcluded' />
</td>
<td>
<input type='text' value='' style='width:60px;' class='changeDefaultWhite changeInput taxRate' />
</td>
<td>
<input type='text' value='' style='width:60px;' class='changeDefaultWhite changeInput priceTaxIncluded' />
</td>
<td>
<input type='text' value='' class='changeDefaultWhite changeInput paymentAmount costHistoryPayment' />
</td>
<?php } ?>
<td>
<select class='changeSelect currencyCode costHistoryCurrency'>
<?php
Expand Down Expand Up @@ -228,6 +244,17 @@
?>
</select>
</td>
<?php if ($enhancedCostFlag){ ?>
<td>
<input type='text' value='<?php echo integer_to_cost($payment['priceTaxExcluded']); ?>' style='width:60px;' class='changeInput priceTaxExcluded' />
</td>
<td>
<input type='text' value='<?php echo integer_to_cost($payment['taxRate']); ?>' style='width:60px;' class='changeInput taxRate' />
</td>
<td>
<input type='text' value='<?php echo integer_to_cost($payment['priceTaxIncluded']); ?>' style='width:60px;' class='changeInput priceTaxIncluded' />
</td>
<?php } ?>
<td>
<input type='text' value='<?php echo integer_to_cost($payment['paymentAmount']); ?>' class='changeInput paymentAmount costHistoryPayment' />
</td>
Expand Down Expand Up @@ -266,7 +293,6 @@
?>
</select>
</td>

<?php if ($enhancedCostFlag){ ?>
<td>
<select class='changeSelect costDetailsID costHistoryCostDetails'>
Expand Down
31 changes: 22 additions & 9 deletions resources/ajax_htmldata/getAcquisitionsDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
$enhancedCostFlag = ((isset($config->settings->enhancedCostHistory)) && (strtoupper($config->settings->enhancedCostHistory) == 'Y')) ? 1 : 0;
$enhancedCostFlag = (strtoupper($config->settings->enhancedCostHistory) == 'Y') ? 1 : 0;
if ($enhancedCostFlag){
$numCols = 9;
$numCols = 12;
$tableWidth = 760;
$formWidth = 784;
$formWidth = 1084;
?>
<!-- Hide the helpful links, etc. -->
<script>
Expand Down Expand Up @@ -183,6 +183,11 @@
<th><?php echo _("Sub End");?></th>
<?php } ?>
<th><?php echo _("Fund");?></th>
<?php if ($enhancedCostFlag){ ?>
<th><?php echo _("Tax Excl.");?></th>
<th><?php echo _("Tax Rate");?></th>
<th><?php echo _("Tax Incl.");?></th>
<?php } ?>
<th><?php echo _("Payment");?></th>
<?php if ($enhancedCostFlag && 0){ ?>
<th style='text-align: right'>%</th>
Expand Down Expand Up @@ -213,11 +218,14 @@
$subStart = $payment['subscriptionStartDate'] ? normalize_date($payment['subscriptionStartDate']) : "&nbsp;";
$subEnd = $payment['subscriptionEndDate'] ? normalize_date($payment['subscriptionEndDate']) : "&nbsp;";
$fundCode = $payment['fundCode'] ? $payment['fundCode'] : "&nbsp;";
if (integer_to_cost($payment['paymentAmount'])){
$cost = $payment['currencyCode'] . " " . integer_to_cost($payment['paymentAmount']);
}else{
$cost = "&nbsp;";
}
$taxRate = $payment['taxRate'] ? integer_to_cost($payment['taxRate']) . '&nbsp;%' : "&nbsp;";
foreach (Array('priceTaxExcluded', 'priceTaxIncluded', 'paymentAmount') as $amount) {
if (integer_to_cost($payment[$amount])){
$cost[$amount] = $payment['currencyCode'] . " " . integer_to_cost($payment[$amount]);
}else{
$cost[$amount] = "&nbsp;";
}
}
$costDetails = $payment['costDetails'] ? $payment['costDetails'] : "&nbsp;";
$costNote = $payment['costNote'] ? $payment['costNote'] : "&nbsp;";
$invoiceNum = $payment['invoiceNum'] ? $payment['invoiceNum'] : "&nbsp;";
Expand All @@ -230,10 +238,15 @@
<td <?php echo $classAdd;?>><?php echo $subEnd; ?></td>
<?php } ?>
<td <?php echo $classAdd;?>><?php echo $fundCode; ?></td>
<td <?php echo $classAdd;?>><?php echo $cost; ?></td>
<?php if ($enhancedCostFlag && 0){ ?>
<td <?php echo $classAdd;?> style='text-align: right'><?php echo $payment['amountChange']; ?></td>
<?php } ?>
<?php } ?>
<?php if ($enhancedCostFlag){ ?>
<td <?php echo $classAdd;?>><?php echo $cost['priceTaxExcluded']; ?></td>
<td <?php echo $classAdd;?>><?php echo $taxRate; ?></td>
<td <?php echo $classAdd;?>><?php echo $cost['priceTaxIncluded']; ?></td>
<?php } ?>
<td <?php echo $classAdd;?>><?php echo $cost['paymentAmount']; ?></td>
<td <?php echo $classAdd;?>><?php echo $payment['orderType']; ?></td>
<?php if ($enhancedCostFlag){ ?>
<td <?php echo $classAdd;?>><?php echo $costDetails; ?></td>
Expand Down
6 changes: 6 additions & 0 deletions resources/ajax_processing/submitCost.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
$subStartArray = array(); $subStartArray = explode(':::',$_POST['subStarts']);
$subEndArray = array(); $subEndArray = explode(':::',$_POST['subEnds']);
$fundIDArray = array(); $fundIDArray = explode(':::',$_POST['fundIDs']);
$pteArray = array(); $pteArray = explode(':::',$_POST['pricesTaxExcluded']);
$taxRateArray = array(); $taxRateArray = explode(':::',$_POST['taxRates']);
$ptiArray = array(); $ptiArray = explode(':::',$_POST['pricesTaxIncluded']);
$paymentAmountArray = array(); $paymentAmountArray = explode(':::',$_POST['paymentAmounts']);
$currencyCodeArray = array(); $currencyCodeArray = explode(':::',$_POST['currencyCodes']);
$orderTypeArray = array(); $orderTypeArray = explode(':::',$_POST['orderTypes']);
Expand All @@ -28,6 +31,9 @@
$resourcePayment->subscriptionStartDate = $start;
$resourcePayment->subscriptionEndDate = $end;
$resourcePayment->fundID = $fundIDArray[$key];
$resourcePayment->priceTaxExcluded = cost_to_integer($pteArray[$key]);
$resourcePayment->taxRate = cost_to_integer($taxRateArray[$key]);
$resourcePayment->priceTaxIncluded = cost_to_integer($ptiArray[$key]);
$resourcePayment->paymentAmount = cost_to_integer($paymentAmountArray[$key]);
$resourcePayment->currencyCode = $currencyCodeArray[$key];
$resourcePayment->orderTypeID = $value;
Expand Down
5 changes: 4 additions & 1 deletion resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,9 @@ table.noMargin { border:0px;margin:0px; padding:0px;text-align:center; }
table.noMargin tr { border:0px;margin:0px; padding:0px; vertical-align:center; }
table.noMargin td { border:0px;margin:0px; padding:0px; }

table.newPaymentTable td { padding:2px;}
table.paymentTable td { padding-right:8px;}


.formText {font-weight:bold;}

Expand Down Expand Up @@ -3273,4 +3276,4 @@ input#archiveInd {
top: 5vh !important;
margin-top: 0px !important;
overflow-x: hidden !important;
}
}
3 changes: 3 additions & 0 deletions resources/install/protected/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ CREATE TABLE `ResourcePayment` (
`resourceID` int(10) unsigned NOT NULL,
`fundID` int(10) default NULL,
`selectorLoginID` varchar(45) default NULL,
`priceTaxExcluded` int(10) unsigned default NULL,
`taxRate` int(10) unsigned default NULL,
`priceTaxIncluded` int(10) unsigned default NULL,
`paymentAmount` int(10) unsigned default NULL,
`orderTypeID` int(10) unsigned default NULL,
`currencyCode` varchar(3) NOT NULL,
Expand Down
3 changes: 3 additions & 0 deletions resources/install/update_acquisitions_enhancements.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE ResourcePayment ADD COLUMN `priceTaxExcluded` int(10) unsigned default NULL AFTER selectorLoginID;
ALTER TABLE ResourcePayment ADD COLUMN `taxRate` int(10) unsigned default NULL AFTER priceTaxExcluded;
ALTER TABLE ResourcePayment ADD COLUMN `priceTaxIncluded` int(10) unsigned default NULL AFTER taxRate;
58 changes: 55 additions & 3 deletions resources/js/forms/costForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ $(function(){
});




$(".remove").live('click', function () {
$(this).parent().parent().parent().fadeTo(400, 0, function () {
$(this).next().remove(); //remove the error line first
Expand All @@ -92,14 +90,35 @@ $(function(){
return false;
});

$(".priceTaxExcluded").change(function() {
pte = $(this).val();
taxRate = $(this).parent().next().children(".taxRate").val();
if (pte && taxRate) {
amount = parseFloat(pte) + (pte * taxRate / 100);
$(this).parent().next().next().children(".priceTaxIncluded").val(amount);
$(this).parent().next().next().next().children(".paymentAmount").val(amount);
}
});

$(".taxRate").change(function() {
taxRate = $(this).val();
pte = $(this).parent().prev().children(".priceTaxExcluded").val();
if (pte && taxRate) {
amount = parseFloat(pte) + (pte * taxRate / 100);
$(this).parent().next().children(".priceTaxIncluded").val(amount);
$(this).parent().next().next().children(".paymentAmount").val(amount);
}
});

$(".addPayment").click(function () {

var y = $('.newPaymentTable').find('.year').val();
var ssd = $('.newPaymentTable').find('.susbcriptionStartDate').val();
var sed = $('.newPaymentTable').find('.susbcriptionEndDate').val();
var fName = $('.newPaymentTable').find('.fundName').val();
var pte = $('.newPaymentTable').find('.priceTaxExcluded').val();
var tr = $('.newPaymentTable').find('.taxRate').val();
var pti = $('.newPaymentTable').find('.priceTaxIncluded').val();
var typeID = $('.newPaymentTable').find('.orderTypeID').val();
var detailsID = $('.newPaymentTable').find('.costDetailsID').val();
var pAmount = $('.newPaymentTable').find('.paymentAmount').val();
Expand Down Expand Up @@ -131,6 +150,9 @@ $(function(){
$('.newPaymentTable').find('.subscriptionStartDate').val('');
$('.newPaymentTable').find('.subscriptionEndDate').val('');
$('.newPaymentTable').find('.fundID').val('');
$('.newPaymentTable').find('.priceTaxExcluded').val('');
$('.newPaymentTable').find('.taxRate').val('');
$('.newPaymentTable').find('.priceTaxIncluded').val('');
$('.newPaymentTable').find('.paymentAmount').val('');
$('.newPaymentTable').find('.orderTypeID').val('');
$('.newPaymentTable').find('.costDetailsID').val('');
Expand Down Expand Up @@ -191,11 +213,27 @@ function submitCostForm()
fundNameList ='';
$(".paymentTable").find(".fundID").each(function(id) {
fundNameList += $(this).val() + ":::";
});


priceTaxExcludedList ='';
$(".priceTaxExcluded").each(function(id) {
priceTaxExcludedList += $(this).val() + ":::";
});

taxRateList ='';
$(".taxRate").each(function(id) {
taxRateList += $(this).val() + ":::";
});

priceTaxIncludedList ='';
$(".priceTaxIncluded").each(function(id) {
priceTaxIncludedList += $(this).val() + ":::";
});

paymentAmountList ='';
$(".paymentTable").find(".paymentAmount").each(function(id) {
paymentAmountList += $(this).val() + ":::";
paymentAmountList += $(this).val() + ":::";
});

currencyCodeList ='';
Expand Down Expand Up @@ -234,6 +272,9 @@ function submitCostForm()
subStarts: subStartList,
subEnds: subEndList,
fundIDs: fundNameList,
pricesTaxExcluded: priceTaxExcludedList,
taxRates: taxRateList,
pricesTaxIncluded: priceTaxIncludedList,
paymentAmounts: paymentAmountList,
currencyCodes: currencyCodeList,
orderTypes: orderTypeList,
Expand Down Expand Up @@ -277,6 +318,8 @@ function validateTable(objRows)
var pAmount = $(objRows[currentRow]).find('.paymentAmount').val();
var typeID = $(objRows[currentRow]).find('.orderTypeID').val();
var detailsID = $(objRows[currentRow]).find('.costDetailsID').val();
var pte = $(objRows[currentRow]).find('.priceTaxIncluded').val();
var pti = $(objRows[currentRow]).find('.priceTaxExcluded').val();
var cNote = $(objRows[currentRow]).find('.costNote').val();
var invoiceNum = $(objRows[currentRow]).find('.invoiceNum').val();

Expand All @@ -295,6 +338,15 @@ function validateTable(objRows)
$(objRows[currentRow+1]).find('.div_errorPayment').html(_("Error - price is not numeric"));
hasNoErrors = false;
}
else if ((pte != '') && (pte != null) && (isAmount(pte) === false)){
$(objRows[currentRow+1]).find('.div_errorPayment').html('Error - Price (tax excluded) is not numeric');
hasNoErrors = false;
}
else if ((pti != '') && (pti != null) && (isAmount(pti) === false)){
$(objRows[currentRow+1]).find('.div_errorPayment').html('Error - Price (tax included) is not numeric');
hasNoErrors = false;
}

currentRow += 2;
}
return hasNoErrors;
Expand Down

0 comments on commit 7dbcbea

Please sign in to comment.