Skip to content

Commit

Permalink
Fix: Currency in payment, order problem
Browse files Browse the repository at this point in the history
Refactor: None
Feat: None
  • Loading branch information
jiloysss authored and jiloysss committed Aug 29, 2019
1 parent 9acbad0 commit 2cb1a86
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/container/ListingContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ export default class ListingContainer extends React.Component {
onPrintBarcode={this.onPrintBarcode}
status={this.props.stateStore.listing_state[0].itemStatus}
currency={getCountryCode(this.props.printerStore)}
isCurrencyDisabled={this.props.stateStore.isCurrencyDisabled}
/>
</TabComponent>
</Tab>
Expand Down
1 change: 1 addition & 0 deletions src/container/PaymentContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@ export default class PaymentContainer extends React.Component {
: ""
}
useDefaultCustomer={this.props.stateStore.useDefaultCustomer}
isCurrencyDisabled={this.props.stateStore.isCurrencyDisabled}
/>
);
}
Expand Down
9 changes: 8 additions & 1 deletion src/container/SalesContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ export default class SalesContainer extends React.Component {
takeAway = values => {
const { queueOrigin } = this.props.stateStore;
const { defaultReceipt, unselectReceiptLine } = this.props.receiptStore;
const { orderType, tableNo } = values;
let { orderType, tableNo } = values;

let items = [];
defaultReceipt.setOrderType(orderType);
Expand All @@ -743,6 +743,13 @@ export default class SalesContainer extends React.Component {
items.push(tailOrderLine(line));
}

if (
orderType === "Takeaway" ||
orderType === "Online" ||
orderType === "Delivery"
) {
tableNo = null;
}
const order = getOrder(orderType, items, tableNo);

sendOrder(queueOrigin, order)
Expand Down
1 change: 0 additions & 1 deletion src/store/PosStore/ReceiptStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export const Receipt = types
if (netTotal <= 0) {
netTotal = 0;
}

return netTotal;
},
get grandQuantity() {
Expand Down
8 changes: 6 additions & 2 deletions src/stories/components/CardShiftFinishedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export default class CardShiftFinishedComponent extends React.Component {
fontSize: 36,
}}
>
{mc.moneyFormat(formatNumber(this.props.cashBeginning))}
{this.props.isCurrencyDisabled
? formatNumber(this.props.cashBeginning)
: mc.moneyFormat(formatNumber(this.props.cashBeginning))}
</Text>
<Text
style={{
Expand All @@ -129,7 +131,9 @@ export default class CardShiftFinishedComponent extends React.Component {
fontSize: 36,
}}
>
{mc.moneyFormat(formatNumber(this.props.cashEnd))}
{this.props.isCurrencyDisabled
? formatNumber(this.props.cashEnd)
: mc.moneyFormat(formatNumber(this.props.cashEnd))}
</Text>
<Text
style={{
Expand Down
6 changes: 5 additions & 1 deletion src/stories/components/NumberKeysComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export default class NumberKeysComponent extends React.PureComponent {
<Input
editable={false}
placeholder={strings.AmountPaid}
value={mc.moneyFormat(this.props.value)}
value={
this.props.isCurrencyDisabled
? this.props.value
: mc.moneyFormat(this.props.value)
}
style={{ color: "black", textAlign: "right" }}
underlineColorAndroid="transparent"
/>
Expand Down
5 changes: 2 additions & 3 deletions src/stories/screens/InputItem/frm.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ export default class Form {
this._setState({ category });
};

onChangePrice = price => {
const newPrice = price.slice(1);
onChangePrice = (price, isCurrencyDisabled) => {
const newPrice = isCurrencyDisabled ? price : price.slice(1);
this._setState({ price: newPrice });
};

setSoldByEach = () => {
this._setState({ soldBy: "Each" });
};
Expand Down
10 changes: 8 additions & 2 deletions src/stories/screens/InputItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,18 @@ export default class InputItem extends React.Component {
<ListingLabel text={strings.Price} />
<ListingItem>
<Input
value={mc.moneyFormat(this.state.price)}
value={
this.props.isCurrencyDisabled
? this.state.price
: mc.moneyFormat(this.state.price)
}
keyboardType="numeric"
placeholder={strings.Price}
onBlur={this.onBlur}
onFocus={this.onFocus}
onChangeText={this.frm.onChangePrice}
onChangeText={value =>
this.frm.onChangePrice(value, this.props.isCurrencyDisabled)
}
/>
</ListingItem>
</ListingColumn>
Expand Down
13 changes: 11 additions & 2 deletions src/stories/screens/Payment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default class Payment extends React.PureComponent {
<Col size={35} style={styles.contentLeft}>
<View style={styles.leftView}>
<NumberKeys
isCurrencyDisabled={this.props.isCurrencyDisabled}
currency={this.props.currency}
onPay={this.onPay}
value={this.props.paymentValue}
Expand All @@ -129,7 +130,11 @@ export default class Payment extends React.PureComponent {
<Input
editable={false}
keyboardType="numeric"
value={mc.moneyFormat(formatNumber(this.props.amountDue))}
value={
this.props.isCurrencyDisabled
? formatNumber(this.props.amountDue)
: mc.moneyFormat(formatNumber(this.props.amountDue))
}
/>
</Item>
</View>
Expand All @@ -139,7 +144,11 @@ export default class Payment extends React.PureComponent {
<Input
editable={false}
keyboardType="numeric"
value={mc.moneyFormat(formatNumber(change))}
value={
this.props.isCurrencyDisabled
? formatNumber(change)
: mc.moneyFormat(formatNumber(change))
}
/>
</Item>
</View>
Expand Down
4 changes: 2 additions & 2 deletions src/stories/screens/SalesReceipt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SalesReceipt extends React.Component {
isViewingOrder,
isCurrencyDisabled,
} = this.props;

const totalPayment = receipt ? receipt.netTotal.toFixed(2) : "0.00";
return (
<Container>
<Content style={styles.content}>
Expand All @@ -49,7 +49,7 @@ class SalesReceipt extends React.Component {
subtotal={receipt ? receipt.subtotal.toFixed(2) : "0.00"}
discount={receipt ? receipt.discounts.toFixed(2) : "0.00"}
taxesValue={receipt ? receipt.get_tax_total.toFixed(2) : "0.00"}
totalPayment={receipt ? receipt.netTotal.toFixed(2) : "0.00"}
totalPayment={totalPayment}
/>
</Content>
<FooterTicketComponent
Expand Down

0 comments on commit 2cb1a86

Please sign in to comment.